public static void Parse_Ulong_InvalidNumber_Throw(ulong i, ulong j, SampleByteEnum e1, SampleUInt32Enum e2) { string json = $"{{ \"MyByteEnum\" : {i}, \"MyUInt32Enum\" : {j} }}"; Assert.Throws <JsonException>(() => JsonSerializer.Parse <SimpleTestClass>(json)); Assert.Throws <JsonException>(() => JsonSerializer.Parse <SimpleTestClass>($"{{ \"MyEnum\" : \"{i}\" }}")); Assert.Throws <JsonException>(() => JsonSerializer.Parse <SimpleTestClass>($"{{ \"MyByteEnum\" : \"{j}\" }}")); }
public static void Parse_Ulong_JsonWithAcceptableInvalidNumber_Success(ulong i, ulong j, SampleByteEnum e1, SampleUInt32Enum e2) { string json = $"{{ \"MyByteEnum\" : {i}, \"MyUInt32Enum\" : {j} }}"; SimpleTestClass result = JsonSerializer.Parse <SimpleTestClass>(json); Assert.Equal(e1, result.MyByteEnum); Assert.Equal(e2, result.MyUInt32Enum); Assert.Throws <JsonException>(() => JsonSerializer.Parse <SimpleTestClass>($"{{ \"MyEnum\" : \"{i}\" }}")); Assert.Throws <JsonException>(() => JsonSerializer.Parse <SimpleTestClass>($"{{ \"MyByteEnum\" : \"{j}\" }}")); }