public void SerializeObject_equality() { SimpleObj obj = new SimpleObj() { PropertyString = "Value String", PropertyInt = 42, PropertyObj = new SimpleSubObj { PropertyString = "Subobject String Value" }, PropertyListString = new List <string> { "String Value 1", "String Value 2", "String Value3" }, PropertyListInt = new List <int> { 5, 6, 7 }, PropertyListObj = new List <SimpleSubObj> { new SimpleSubObj { PropertyString = "Subobject String Value 1" }, new SimpleSubObj { PropertyString = "Subobject String Value 2" }, new SimpleSubObj { PropertyString = "Subobject String Value 3" } } }; string json = MetaJson.MetaJsonSerializer.Serialize(obj); SimpleObj obj2 = Newtonsoft.Json.JsonConvert.DeserializeObject <SimpleObj>(json); obj.VerifyEqualsTo(obj2); }
public void SerializeObject_null() { SimpleObj nullSimpleObj = null; string json = MetaJson.MetaJsonSerializer.Serialize(nullSimpleObj); Assert.Equal("null", json); }
public void SerializeObject_defaultProperties() { SimpleObj obj = new SimpleObj(); string json = MetaJson.MetaJsonSerializer.Serialize(obj); obj = Newtonsoft.Json.JsonConvert.DeserializeObject <SimpleObj>(json); obj.VerifyPropertiesAreDefaulted(); }
public void DeserializeObject_defaultProperties() { SimpleObj obj = new SimpleObj(); string json = Newtonsoft.Json.JsonConvert.SerializeObject(obj); MetaJson.MetaJsonSerializer.Deserialize(json, out SimpleObj obj2); obj2.VerifyPropertiesAreDefaulted(); }