public virtual void RoundTripNumberTypes() { NumberTypes expected = CreateNumberTypes(); string json = JsonSerializer.Serialize(expected, DefaultContext.NumberTypes); NumberTypes obj = JsonSerializer.Deserialize(json, DefaultContext.NumberTypes); VerifyNumberTypes(expected, obj); }
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); }
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); }