Skip to content

Commit b20f6be

Browse files
committed
Added test for null assigned property not being rendered to prevent regressions.
1 parent a862405 commit b20f6be

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

Tests/Schema.NET.Test/SerializationTest.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,5 +84,23 @@ public void ToHtmlEscapedString_UnsafeBookData_ReturnsExpectedJsonLd() =>
8484
[Fact]
8585
public void ToStringWithCustomSerializerSettings_UnsafeAuthorData_ReturnsExpectedJsonLd() =>
8686
Assert.Equal(this.jsonCustom, Person.ToString(this.customSerializerSettings));
87+
88+
[Fact]
89+
public void ToStringWithNullAssignedProperty_ReturnsExpectedJsonLd()
90+
{
91+
var localBusiness = new LocalBusiness()
92+
{
93+
PriceRange = "$$$",
94+
Address = null
95+
};
96+
var actual = localBusiness.ToString();
97+
var expected =
98+
"{" +
99+
"\"@context\":\"http://schema.org\"," +
100+
"\"@type\":\"LocalBusiness\"," +
101+
"\"priceRange\":\"$$$\"" +
102+
"}";
103+
Assert.Equal(expected, actual);
104+
}
87105
}
88106
}

0 commit comments

Comments
 (0)