comparison HowTo/Mapping/EnumToValue.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 EnumToValue
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 object value = Map./*[a]*/EnumToValue/*[/a]*/(Gender1.Male);
24
25 Assert.AreEqual("M", value);
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 object value = Map./*[a]*/EnumToValue/*[/a]*/(Gender2.Male);
40
41 Assert.AreEqual(2, value);
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 object value = (int)Map./*[a]*/EnumToValue/*[/a]*/(Gender3.Male);
56
57 Assert.AreEqual(2, value);
58 }
59 }
60 }