Mercurial > pub > bltoolkit
comparison UnitTests/CS/DataAccess/EnumTest.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 using BLToolkit.Data; | |
3 using NUnit.Framework; | |
4 | |
5 using BLToolkit.DataAccess; | |
6 using BLToolkit.Mapping; | |
7 | |
8 namespace DataAccess | |
9 { | |
10 [TestFixture] | |
11 public class EnumTest | |
12 { | |
13 public enum Gender | |
14 { | |
15 [MapValue("F")] E_Female, | |
16 [MapValue("M")] E_Male, | |
17 [MapValue("U")] E_Unknown, | |
18 [MapValue("O")] E_Other | |
19 } | |
20 | |
21 public enum RefEnum | |
22 { | |
23 [MapValue("A")] E_A, | |
24 [MapValue("B")] E_B, | |
25 [MapValue("BB")] E_BB | |
26 } | |
27 | |
28 public abstract class TestAccessor : DataAccessor | |
29 { | |
30 #if SQLITE || SQLCE | |
31 [SqlQuery(@"INSERT INTO Person(FirstName, MiddleName, LastName, Gender) | |
32 VALUES(@FirstName, @MiddleName, @LastName, @Gender)")] | |
33 #endif | |
34 public abstract int Person_Insert( | |
35 string @FirstName, string @MiddleName, string @LastName, Gender @Gender); | |
36 | |
37 #if ACCESS || SQLITE || SQLCE | |
38 #if SQLITE || SQLCE | |
39 [SqlQuery(@"SELECT * FROM Person WHERE FirstName = @FirstName AND LastName = @LastName")] | |
40 #endif | |
41 public abstract int Person_SelectByName( | |
42 string @FirstName, string @LastName ); | |
43 #endif | |
44 | |
45 #if SQLITE || SQLCE | |
46 [SqlQuery(@"DELETE FROM Person WHERE PersonID = @PersonID")] | |
47 #endif | |
48 public abstract void Person_Delete(int @personID); | |
49 | |
50 public abstract void OutRefEnumTest( | |
51 string @str, out RefEnum @outputStr, ref RefEnum @inputOutputStr); | |
52 | |
53 } | |
54 | |
55 [Test] | |
56 public void Test() | |
57 { | |
58 TestAccessor ta = (TestAccessor)DataAccessor.CreateInstance(typeof(TestAccessor)); | |
59 | |
60 int id = ta.Person_Insert("Crazy", null, "Frog", Gender.E_Unknown); | |
61 | |
62 #if ACCESS || SQLITE || SQLCE | |
63 Assert.AreEqual(0, id); | |
64 id = ta.Person_SelectByName("Crazy", "Frog"); | |
65 #endif | |
66 | |
67 Assert.IsTrue(id > 0); | |
68 ta.Person_Delete(id); | |
69 } | |
70 | |
71 #if !ACCESS && !SQLITE && !SQLCE | |
72 [Test] | |
73 public void RefTest() | |
74 { | |
75 TestAccessor ta = (TestAccessor)DataAccessor.CreateInstance(typeof(TestAccessor)); | |
76 | |
77 RefEnum a; | |
78 RefEnum b = RefEnum.E_B; | |
79 | |
80 ta.OutRefEnumTest("B", out a, ref b); | |
81 | |
82 Assert.AreEqual(RefEnum.E_B, a); | |
83 Assert.AreEqual(RefEnum.E_BB, b); | |
84 } | |
85 #endif | |
86 } | |
87 } |