Example #1
0
        public void Value_List_WithNullElement()
        {
            var expected = Value.ForList(Value.ForString("x"), Value.ForNull(), Value.ForString("y"));
            var actual   = Value.Parser.ParseText("[\"x\", null, \"y\"]");

            Assert.Equal(expected, actual);
        }
Example #2
0
        public void StructValue_NullElement()
        {
            var expected = Value.ForStruct(new Struct {
                Fields = { { "x", Value.ForNull() } }
            });
            var actual = Value.Parser.ParseText("x: null");

            Assert.Equal(expected, actual);
        }
Example #3
0
        public void ExplicitNullValue()
        {
            string json    = "valueField: null";
            var    message = TextParser.Default.Parse <TestWellKnownTypes>(json);

            Assert.Equal(new TestWellKnownTypes {
                ValueField = Value.ForNull()
            }, message);
        }
Example #4
0
        public void SingularWrappers_ExplicitNulls()
        {
            // When we parse the "valueField": null part, we remember it... basically, it's one case
            // where explicit default values don't fully roundtrip.
            var message = new TestWellKnownTypes {
                ValueField = Value.ForNull()
            };
            var json   = TextFormatter.Default.Format(message);
            var parsed = TextParser.Default.Parse <TestWellKnownTypes>(json);

            Assert.Equal(message, parsed);
        }