예제 #1
0
                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);
                }
예제 #2
0
                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);
                }