public void ListEvents() { SerializationEventTestList obj = new SerializationEventTestList { 1.1m, 2.222222222m, int.MaxValue, Convert.ToDecimal(Math.PI) }; Assert.AreEqual(11, obj.Member1); Assert.AreEqual("Hello World!", obj.Member2); Assert.AreEqual("This is a nonserialized value", obj.Member3); Assert.AreEqual(null, obj.Member4); string json = JsonConvertX.SerializeObject(obj, Formatting.Indented); StringAssert.AreEqual(@"[ -1.0, 1.1, 2.222222222, 2147483647.0, 3.14159265358979 ]", json); Assert.AreEqual(11, obj.Member1); Assert.AreEqual("This value was reset after serialization.", obj.Member2); Assert.AreEqual("This is a nonserialized value", obj.Member3); Assert.AreEqual(null, obj.Member4); obj = JsonConvertX.DeserializeObject <SerializationEventTestList>(json); Assert.AreEqual(11, obj.Member1); Assert.AreEqual("Hello World!", obj.Member2); Assert.AreEqual("This value was set during deserialization", obj.Member3); Assert.AreEqual("This value was set after deserialization.", obj.Member4); }
public void ListEvents() { SerializationEventTestList obj = new SerializationEventTestList { 1.1m, 2.222222222m, int.MaxValue, Convert.ToDecimal(Math.PI) }; Assert.AreEqual(11, obj.Member1); Assert.AreEqual("Hello World!", obj.Member2); Assert.AreEqual("This is a nonserialized value", obj.Member3); Assert.AreEqual(null, obj.Member4); string json = JsonConvert.SerializeObject(obj, Formatting.Indented); StringAssert.AreEqual(@"[ -1.0, 1.1, 2.222222222, 2147483647.0, 3.14159265358979 ]", json); Assert.AreEqual(11, obj.Member1); Assert.AreEqual("This value was reset after serialization.", obj.Member2); Assert.AreEqual("This is a nonserialized value", obj.Member3); Assert.AreEqual(null, obj.Member4); obj = JsonConvert.DeserializeObject<SerializationEventTestList>(json); Assert.AreEqual(11, obj.Member1); Assert.AreEqual("Hello World!", obj.Member2); Assert.AreEqual("This value was set during deserialization", obj.Member3); Assert.AreEqual("This value was set after deserialization.", obj.Member4); }