Ejemplo n.º 1
0
        public void ClassOfInterfaceQuantity_SerializationRoundTrips()
        {
            var quantity       = new Mass(1.2, MassUnit.Milligram);
            var quantityObject = new TestInterfaceObject {
                Quantity = quantity
            };

            var payload = SerializeObject(quantityObject);
            var result  = DeserializeObject <TestInterfaceObject>(payload);

            Assert.Equal(quantity.Unit, result.Quantity.Unit);
            Assert.Equal(quantity.Value, result.Quantity.Value);
            Assert.Equal(quantity, result.Quantity);
        }
Ejemplo n.º 2
0
        public void ClassOfInterfaceDecimalQuantity_SerializationRoundTrips()
        {
            var quantity       = new Information(2, InformationUnit.Exabyte);
            var quantityObject = new TestInterfaceObject {
                Quantity = quantity
            };

            var payload = SerializeObject(quantityObject);
            var result  = DeserializeObject <TestInterfaceObject>(payload);

            Assert.Equal(quantity.Unit, result.Quantity.Unit);
            Assert.Equal(quantity.Value, ((IDecimalQuantity)result.Quantity).Value);
            Assert.Equal(quantity, result.Quantity);
            Assert.Equal("2", ((IDecimalQuantity)result.Quantity).Value.ToString(CultureInfo.InvariantCulture));
        }