public AreaJsonConverter(
     AreaJsonSerializationFormat serializationFormat           = AreaJsonSerializationFormat.AsSquareMetresWithUnit,
     LinearUnitJsonSerializationFormat unitSerializationFormat = LinearUnitJsonSerializationFormat.PredefinedAsString)
     : base(
         unitConverter: new AreaUnitJsonConverter(unitSerializationFormat),
         serializationFormat: (QuantityJsonSerializationFormat)serializationFormat)
 {
 }
Esempio n. 2
0
 public AreaSerializeTestData(
     Area value,
     AreaJsonSerializationFormat format,
     LinearUnitJsonSerializationFormat unitFormat,
     string expectedJsonPattern)
     : base(value, unitFormat, expectedJsonPattern)
 {
     Format = format;
 }
Esempio n. 3
0
        public void SerializeAndDeserializeWithSquareMetres_ShouldBeIdempotent(AreaJsonSerializationFormat format, LinearUnitJsonSerializationFormat unitFormat)
        {
            // arrange
            var area      = Fixture.Create <Area>();
            var converter = new AreaJsonConverter(format, unitFormat);

            // act
            string serializedArea1   = JsonConvert.SerializeObject(area, converter);
            var    deserializedArea1 = JsonConvert.DeserializeObject <Area>(serializedArea1, converter);
            string serializedArea2   = JsonConvert.SerializeObject(deserializedArea1, converter);
            var    deserializedArea2 = JsonConvert.DeserializeObject <Area>(serializedArea2, converter);

            // assert
            deserializedArea1.Should().Be(area);
            deserializedArea2.Should().Be(area);

            deserializedArea2.Should().Be(deserializedArea1);
            serializedArea2.Should().Be(serializedArea1);
        }