comparison HowTo/Mapping/MapValueAttribute2.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 MapValue2
11 {
12 public enum Gender1
13 {
14 [/*[a]*/MapValue("F")/*[/a]*/] Female,
15 [/*[a]*/MapValue("M")/*[/a]*/] Male,
16 [/*[a]*/MapValue("U")/*[/a]*/] Unknown,
17 [/*[a]*/MapValue("O")/*[/a]*/] Other
18 }
19
20 [Test]
21 public void Test1()
22 {
23 object value = Map.EnumToValue(Gender1.Male);
24
25 Assert.AreEqual("M", value);
26 }
27
28 [/*[a]*/MapValue(Gender2.Female, 1)/*[/a]*/]
29 [/*[a]*/MapValue(Gender2.Male, 2)/*[/a]*/]
30 [/*[a]*/MapValue(Gender2.Unknown, 3)/*[/a]*/]
31 [/*[a]*/MapValue(Gender2.Other, 4)/*[/a]*/]
32 public enum Gender2
33 {
34 Female,
35 Male,
36 Unknown,
37 Other
38 }
39
40 [Test]
41 public void Test2()
42 {
43 Gender2 g = Map.ToEnum<Gender2>(2);
44
45 Assert.AreEqual(Gender2.Male, g);
46 }
47 }
48 }