This repository was archived by the owner on Dec 24, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +47
-0
lines changed
tests/ServiceStack.Text.Tests Expand file tree Collapse file tree 2 files changed +47
-0
lines changed Original file line number Diff line number Diff line change
1
+ using System ;
2
+ using System . Runtime . Serialization ;
3
+ using NUnit . Framework ;
4
+ using ServiceStack . Html ;
5
+
6
+ namespace ServiceStack . Text . Tests . JsonTests
7
+ {
8
+ [ TestFixture ]
9
+ public class RouteValueDictionaryTests : TestBase
10
+ {
11
+ [ Test ]
12
+ public void Does_deserialize_RouteValueDictionary ( )
13
+ {
14
+ var item = new TestObject
15
+ {
16
+ PropA = "foo" ,
17
+ Values = new RouteValueDictionary { { "something" , "lies here" } }
18
+ } ;
19
+
20
+ var jsonSerialized = JsonSerializer . SerializeToString ( item ) ;
21
+ var typeSerialized = TypeSerializer . SerializeToString ( item ) ;
22
+
23
+ var jsonResult = JsonSerializer . DeserializeFromString < TestObject > ( jsonSerialized ) ;
24
+ var typeResult = TypeSerializer . DeserializeFromString < TestObject > ( typeSerialized ) ;
25
+
26
+ Assert . AreEqual ( item . PropA , jsonResult . PropA ) ;
27
+ Assert . NotNull ( jsonResult . Values ) ;
28
+ Assert . AreEqual ( item . Values . Count , jsonResult . Values . Count ) ;
29
+ Assert . AreEqual ( item . Values [ "something" ] , jsonResult . Values [ "something" ] ) ;
30
+
31
+ Assert . AreEqual ( item . PropA , typeResult . PropA ) ;
32
+ Assert . NotNull ( typeResult . Values ) ;
33
+ Assert . AreEqual ( item . Values . Count , typeResult . Values . Count ) ;
34
+ Assert . AreEqual ( item . Values [ "something" ] , typeResult . Values [ "something" ] ) ;
35
+ }
36
+
37
+ [ DataContract ]
38
+ class TestObject
39
+ {
40
+ [ DataMember ]
41
+ public string PropA { get ; set ; }
42
+ [ DataMember ]
43
+ public RouteValueDictionary Values { get ; set ; }
44
+ }
45
+ }
46
+ }
Original file line number Diff line number Diff line change 178
178
<Compile Include =" JsonTests\BasicPropertiesTests.cs" />
179
179
<Compile Include =" JsonObjectTests.cs" />
180
180
<Compile Include =" JsonTests\AnonymousDeserializationTests.cs" />
181
+ <Compile Include =" JsonTests\RouteValueDictionaryTests.cs" />
181
182
<Compile Include =" JsonTests\CustomRawSerializerTests.cs" />
182
183
<Compile Include =" JsonTests\CustomSerializerTests.cs" />
183
184
<Compile Include =" JsonTests\CamelCaseTests.cs" />
You can’t perform that action at this time.
0 commit comments