コード例 #1
0
        public void SerializationEmitsPropertyWhenUsingEmitDefaultsAndDefaultValueAttribute()
        {
            var writer = new StringWriter();
            var obj    = new DefaultsExample {
                Value = DefaultsExample.DefaultValue
            };

            SerializerBuilder.EmitDefaults().Build().Serialize(writer, obj);
            var serialized = writer.ToString();

            serialized.Should().Contain("Value");
        }
コード例 #2
0
        public void SerializationEmitsPropertyWhenValueDifferFromDefaultValueAttribute()
        {
            var writer = new StringWriter();
            var obj    = new DefaultsExample {
                Value = "non-default"
            };

            Serializer.Serialize(writer, obj);
            var serialized = writer.ToString();

            serialized.Should().Contain("Value");
        }
コード例 #3
0
        public void SerializationSkipsPropertyWhenUsingDefaultValueAttribute()
        {
            var writer = new StringWriter();
            var obj    = new DefaultsExample {
                Value = DefaultsExample.DefaultValue
            };

            Serializer.Serialize(writer, obj);
            var serialized = writer.ToString();

            serialized.Should().NotContain("Value");
        }