public void WhenClassWithNullAndClassTypeThenSerializesOk() { // Arrange OptionConverterExample2 data = new OptionConverterExample2() { Value1 = 10, Value2 = OptionStrict <OptionConverterExample2> .Nothing }; // Act string json = jsonSerializer.SerializeObject(data); // Assert Assert.AreEqual("{\"Value1\":10,\"Value2\":null}", json); }
public void WhenJustAndClassTypeWithNestedOptionThenSerializesOk() { // Arrange OptionStrict <OptionConverterExample2> data = new OptionConverterExample2() { Value1 = 10, Value2 = new OptionConverterExample2() { Value1 = 20, Value2 = OptionStrict <OptionConverterExample2> .Nothing } }; // Act string json = jsonSerializer.SerializeObject(data); // Assert Assert.AreEqual("{\"Just\":{\"Value1\":10,\"Value2\":{\"Just\":{\"Value1\":20,\"Value2\":null}}}}", json); }