@@ -162,15 +162,16 @@ public class UiWindow
162162
163163 public class ValueTypesTest
164164 {
165- public byte TestByte ;
166- public char TestChar ;
167- public DateTime TestDateTime ;
168- public decimal TestDecimal ;
169- public sbyte TestSByte ;
170- public short TestShort ;
171- public ushort TestUShort ;
172- public uint TestUInt ;
173- public ulong TestULong ;
165+ public byte TestByte ;
166+ public char TestChar ;
167+ public DateTime TestDateTime ;
168+ public decimal TestDecimal ;
169+ public sbyte TestSByte ;
170+ public short TestShort ;
171+ public ushort TestUShort ;
172+ public uint TestUInt ;
173+ public ulong TestULong ;
174+ public DateTimeOffset TestDateTimeOffset ;
174175 }
175176
176177 public class NullableTypesTest
@@ -399,13 +400,17 @@ public void ExportValueTypesTest ()
399400 test . TestUShort = 30000 ;
400401 test . TestUInt = 90000000 ;
401402 test . TestULong = 0xFFFFFFFFFFFFFFFF ; // = =18446744073709551615
403+ test . TestDateTimeOffset =
404+ new DateTimeOffset ( 2019 , 9 , 18 , 16 , 47 ,
405+ 50 , 123 , TimeSpan . FromHours ( 8 ) ) . AddTicks ( 4567 ) ;
402406
403407 string json = JsonMapper . ToJson ( test ) ;
404408 string expected =
405409 "{\" TestByte\" :200,\" TestChar\" :\" P\" ,\" TestDateTime\" :" +
406410 "\" 12/22/2012 00:00:00\" ,\" TestDecimal\" :10.333," +
407411 "\" TestSByte\" :-5,\" TestShort\" :1024,\" TestUShort\" :30000" +
408- ",\" TestUInt\" :90000000,\" TestULong\" :18446744073709551615}" ;
412+ ",\" TestUInt\" :90000000,\" TestULong\" :18446744073709551615" +
413+ ",\" TestDateTimeOffset\" :\" 2019-09-18T16:47:50.1234567+08:00\" }" ;
409414
410415 Assert . AreEqual ( expected , json ) ;
411416 }
@@ -825,15 +830,16 @@ public void ImportValueTypesTest ()
825830 {
826831 string json = @"
827832{
828- ""TestByte"": 200,
829- ""TestChar"": 'P',
830- ""TestDateTime"": ""12/22/2012 00:00:00"",
831- ""TestDecimal"": 10.333,
832- ""TestSByte"": -5,
833- ""TestShort"": 1024,
834- ""TestUShort"": 30000,
835- ""TestUInt"": 90000000,
836- ""TestULong"": 18446744073709551615
833+ ""TestByte"": 200,
834+ ""TestChar"": 'P',
835+ ""TestDateTime"": ""12/22/2012 00:00:00"",
836+ ""TestDecimal"": 10.333,
837+ ""TestSByte"": -5,
838+ ""TestShort"": 1024,
839+ ""TestUShort"": 30000,
840+ ""TestUInt"": 90000000,
841+ ""TestULong"": 18446744073709551615,
842+ ""TestDateTimeOffset"": ""2019-09-18T16:47:50.1234567+08:00""
837843}" ;
838844
839845 ValueTypesTest test = JsonMapper . ToObject < ValueTypesTest > ( json ) ;
@@ -848,6 +854,10 @@ public void ImportValueTypesTest ()
848854 Assert . AreEqual ( 30000 , test . TestUShort , "A7" ) ;
849855 Assert . AreEqual ( 90000000 , test . TestUInt , "A8" ) ;
850856 Assert . AreEqual ( 18446744073709551615L , test . TestULong , "A9" ) ;
857+ Assert . AreEqual (
858+ new DateTimeOffset ( 2019 , 9 , 18 , 16 , 47 ,
859+ 50 , 123 , TimeSpan . FromHours ( 8 ) ) . AddTicks ( 4567 ) ,
860+ test . TestDateTimeOffset , "A10" ) ;
851861 }
852862
853863 [ Test ]
0 commit comments