Mercurial > pub > bltoolkit
comparison UnitTests/CS/Mapping/MemberMapperDefaultMappersTest.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 System.Collections.Generic; | |
3 using System.Linq; | |
4 | |
5 using BLToolkit.Mapping; | |
6 using BLToolkit.Mapping.MemberMappers; | |
7 | |
8 using NUnit.Framework; | |
9 | |
10 namespace Mapping | |
11 { | |
12 [TestFixture] | |
13 public class MemberMapperDefaultMappersTest | |
14 { | |
15 public class Object1 | |
16 { | |
17 [MemberMapper(typeof(XMLSerialisationMapper))] | |
18 public List<object> Lst1; | |
19 [MemberMapper(typeof(BinarySerialisationMapper))] | |
20 public List<object> Lst2; | |
21 [MemberMapper(typeof(BinarySerialisationToBase64StringMapper))] | |
22 public List<object> Lst3; | |
23 [MemberMapper(typeof(JSONSerialisationMapper))] | |
24 public List<object> Lst4; | |
25 } | |
26 | |
27 [Test] | |
28 public void DefaultMemberMapperTest() | |
29 { | |
30 ObjectMapper om = Map.GetObjectMapper(typeof(Object1)); | |
31 | |
32 Object1 o = new Object1(); | |
33 | |
34 o.Lst1 = new List<object>() { "Hello", "this", "is", "a", "test", 1, 2, 3 }; | |
35 o.Lst2 = o.Lst1; | |
36 o.Lst3 = o.Lst1; | |
37 o.Lst4 = o.Lst1; | |
38 | |
39 var xml = om.GetValue(o, "Lst1"); | |
40 var bytearr = om.GetValue(o, "Lst2"); | |
41 var base64 = om.GetValue(o, "Lst3"); | |
42 var json = om.GetValue(o, "Lst4"); | |
43 | |
44 var o2 = new Object1(); | |
45 om.SetValue(o2, "Lst1", xml); | |
46 om.SetValue(o2, "Lst2", bytearr); | |
47 om.SetValue(o2, "Lst3", base64); | |
48 om.SetValue(o2, "Lst4", json); | |
49 | |
50 Assert.IsTrue(o.Lst1.SequenceEqual(o2.Lst1)); | |
51 Assert.IsTrue(o.Lst2.SequenceEqual(o2.Lst2)); | |
52 Assert.IsTrue(o.Lst3.SequenceEqual(o2.Lst3)); | |
53 Assert.IsTrue(o.Lst4.SequenceEqual(o2.Lst4)); | |
54 } | |
55 } | |
56 } |