Mercurial > pub > bltoolkit
comparison HowTo/Mapping/ObjectToObject.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 ObjectToObject | |
11 { | |
12 public class SourceObject | |
13 { | |
14 public bool Value1 = true; | |
15 public string Value2 = "10"; | |
16 public string StrValue = "test"; | |
17 } | |
18 | |
19 public class DestObject | |
20 { | |
21 [MapField("Value1")] public bool BoolValue; | |
22 [MapField("Value2")] public int IntValue; | |
23 | |
24 // If the source and destination field/property names are equal, | |
25 // there is no need for using the MapField attribute. | |
26 // | |
27 public string StrValue; | |
28 } | |
29 | |
30 [Test] | |
31 public void Test1() | |
32 { | |
33 SourceObject source = new SourceObject(); | |
34 DestObject dest = Map./*[a]*/ObjectToObject/*[/a]*/<DestObject>(source); | |
35 | |
36 Assert.AreEqual(true, dest.BoolValue); | |
37 Assert.AreEqual(10, dest.IntValue); | |
38 Assert.AreEqual("test", dest.StrValue); | |
39 } | |
40 } | |
41 } |