Mercurial > pub > bltoolkit
comparison HowTo/Mapping/ValueToEnum.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.Mapping; | |
6 | |
7 namespace HowTo.Mapping | |
8 { | |
9 [TestFixture] | |
10 public class ValueToEnum | |
11 { | |
12 public enum Gender1 | |
13 { | |
14 [MapValue("F")] Female, | |
15 [MapValue("M")] Male, | |
16 [MapValue("U")] Unknown, | |
17 [MapValue("O")] Other | |
18 } | |
19 | |
20 [Test] | |
21 public void Test1() | |
22 { | |
23 Gender1 g = Map./*[a]*/ToEnum<Gender1>/*[/a]*/("M"); | |
24 | |
25 Assert.AreEqual(Gender1.Male, g); | |
26 } | |
27 | |
28 public enum Gender2 | |
29 { | |
30 [MapValue(1)] Female, | |
31 [MapValue(2)] Male, | |
32 [MapValue(3)] Unknown, | |
33 [MapValue(4)] Other | |
34 } | |
35 | |
36 [Test] | |
37 public void Test2() | |
38 { | |
39 Gender2 g = Map./*[a]*/ToEnum<Gender2>/*[/a]*/(2); | |
40 | |
41 Assert.AreEqual(Gender2.Male, g); | |
42 } | |
43 | |
44 public enum Gender3 | |
45 { | |
46 Female = 1, | |
47 Male = 2, | |
48 Unknown = 3, | |
49 Other = 4 | |
50 } | |
51 | |
52 [Test] | |
53 public void Test3() | |
54 { | |
55 Gender3 g = Map./*[a]*/ToEnum<Gender3>/*[/a]*/(2); | |
56 | |
57 Assert.AreEqual(Gender3.Male, g); | |
58 } | |
59 } | |
60 } |