public void TestCanDeserializeObjectWithNull()
        {
            var data = new SimpleClass();
            var deserializedObject = DeserializeObject<SimpleClass>(@"{""NormalDateTime"":" + CalculateValue(data.NormalDateTime) + @",""NullableDateTime"":null}");

            Assert.Equal(data.NormalDateTime, deserializedObject.NormalDateTime);
            Assert.Equal(data.NullableDateTime, deserializedObject.NullableDateTime);
        }
        public void TestCanDeserializeObjectWithNullableAssigned()
        {
            var data = new SimpleClass {
                NullableDateTime = new DateTimeOffset(2016, 04, 11, 14, 59, 59, TimeSpan.Zero),
                NormalDateTime = new DateTimeOffset(2015, 4, 12, 5, 03, 59, TimeSpan.Zero)
            };
            var normalValue = CalculateValue(data.NormalDateTime);
            var nullableValue = CalculateValue(data.NullableDateTime.Value);

            var deserializdeObject = DeserializeObject<SimpleClass>(@"{""NormalDateTime"":" + normalValue + @",""NullableDateTime"":" + nullableValue + "}");
            Assert.Equal(data.NormalDateTime, deserializdeObject.NormalDateTime);
            Assert.Equal(data.NullableDateTime, deserializdeObject.NullableDateTime);
        }
Esempio n. 3
0
 public void TestSerializesObjectWithExplicitValueCorrectly()
 {
     var originalObject = new SimpleClass {
         Value = SimpleEnum.Second
     };
     var result = SerializeObject(originalObject);
     Assert.Equal(@"{""Value"":""_second""}", result);
 }
Esempio n. 4
0
 public void TestSerializesObjectWithDefaultCorrectly()
 {
     var originalObject = new SimpleClass();
     var result = SerializeObject(originalObject);
     Assert.Equal(@"{""Value"":""_first""}", result);
 }
 public void TestCanSerializeObjectWithNull()
 {
     var data = new SimpleClass();
     Assert.Equal(@"{""NormalDateTime"":" + CalculateValue(data.NormalDateTime) + @",""NullableDateTime"":null}", SerializeObject(data));
 }