Ejemplo n.º 1
0
        public virtual void RoundTripNumberTypes()
        {
            NumberTypes expected = CreateNumberTypes();

            string      json = JsonSerializer.Serialize(expected, DefaultContext.NumberTypes);
            NumberTypes obj  = JsonSerializer.Deserialize(json, DefaultContext.NumberTypes);

            VerifyNumberTypes(expected, obj);
        }
Ejemplo n.º 2
0
        public override void RoundTripNumberTypes()
        {
            NumberTypes expected = CreateNumberTypes();

            string json = JsonSerializer.Serialize(expected, DefaultContext.NumberTypes);

            JsonTestHelper.AssertThrows_PropMetadataInit(() => JsonSerializer.Deserialize(json, DefaultContext.NumberTypes), typeof(NumberTypes));

            NumberTypes obj = JsonSerializer.Deserialize(json, ((ITestContext)MetadataWithPerTypeAttributeContext.Default).NumberTypes);

            VerifyNumberTypes(expected, obj);

            AssertFastPathLogicCorrect(json, obj, DefaultContext.NumberTypes);
        }
Ejemplo n.º 3
0
 protected static void VerifyNumberTypes(NumberTypes expected, NumberTypes obj)
 {
     Assert.Equal(expected.Single, obj.Single);
     Assert.Equal(expected.Double, obj.Double);
     Assert.Equal(expected.Decimal, obj.Decimal);
     Assert.Equal(expected.SByte, obj.SByte);
     Assert.Equal(expected.Byte, obj.Byte);
     Assert.Equal(expected.UShort, obj.UShort);
     Assert.Equal(expected.Short, obj.Short);
     Assert.Equal(expected.UInt, obj.UInt);
     Assert.Equal(expected.Int, obj.Int);
     Assert.Equal(expected.ULong, obj.ULong);
     Assert.Equal(expected.Long, obj.Long);
 }