comparison UnitTests/CS/DataAccess/CreateEntityTest.cs @ 0:f990fcb411a9

Копия текущей версии из github
author cin
date Thu, 27 Mar 2014 21:46:09 +0400
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:f990fcb411a9
1 using System;
2
3 using NUnit.Framework;
4
5 using BLToolkit.Reflection;
6 using BLToolkit.DataAccess;
7 using BLToolkit.Data;
8 using BLToolkit.TypeBuilder;
9
10 namespace DataAccess
11 {
12 [TestFixture]
13 public class CreateEntityTest
14 {
15 public abstract class Entity
16 {
17 public abstract int Id { get; set; }
18 public abstract String Name { get; set; }
19
20 public static Entity CreateInstance() { return TypeAccessor<Entity>.CreateInstanceEx(); }
21 }
22
23 public abstract class EntityAccessor : DataAccessor<Entity>
24 {
25 #if SQLITE || SQLCE
26 [SqlQuery("SELECT * FROM Person")]
27 #else
28 [SprocName("Person_SelectAll")]
29 #endif
30 public abstract int Insert(Entity entity);
31
32 public static EntityAccessor CreateInstance(DbManager dbManager)
33 {
34 return DataAccessor.CreateInstance<EntityAccessor>(dbManager);
35 }
36 }
37
38 [Test]
39 public void Test()
40 {
41 TypeFactory.SetGlobalAssembly("CreateEntityTest.dll");
42
43 DbManager db = new DbManager();
44
45 try
46 {
47 Entity entity = Entity.CreateInstance();
48 EntityAccessor accessor = EntityAccessor.CreateInstance(db);
49
50 accessor.Insert(entity);
51 }
52 finally
53 {
54 db.Dispose();
55 TypeFactory.SaveGlobalAssembly();
56 }
57 }
58 }
59 }