public void DoubleInIComparable_ExpectUnitCorrectlyDeserialized() { var testObjWithIComparable = new TestObjectWithIComparable() { Value = 10.0 }; var json = SerializeObject(testObjWithIComparable); var deserializedTestObject = DeserializeObject <TestObjectWithIComparable>(json); Assert.IsType <double>(deserializedTestObject.Value); Assert.Equal(10d, (double)deserializedTestObject.Value); }
public void UnitInIComparable_ExpectUnitCorrectlyDeserialized() { var testObjWithIComparable = new TestObjectWithIComparable() { Value = Power.FromWatts(10) }; var json = SerializeObject(testObjWithIComparable); var deserializedTestObject = DeserializeObject <TestObjectWithIComparable>(json); Assert.IsType <Power>(deserializedTestObject.Value); Assert.Equal(Power.FromWatts(10), (Power)deserializedTestObject.Value); }
public void ClassInIComparable_ExpectUnitCorrectlyDeserialized() { var testObjWithIComparable = new TestObjectWithIComparable() { Value = new TestObjectWithValueAsIComparable() { Value = 10 } }; var json = SerializeObject(testObjWithIComparable, TypeNameHandling.Auto); var deserializedTestObject = DeserializeObject <TestObjectWithIComparable>(json, TypeNameHandling.Auto); Assert.IsType <TestObjectWithValueAsIComparable>(deserializedTestObject.Value); Assert.Equal(10d, ((TestObjectWithValueAsIComparable)deserializedTestObject.Value).Value); }