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"); }
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"); }
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"); }