Skip to content

Commit

Permalink
fix bug in VerifyXml (#938)
Browse files Browse the repository at this point in the history
  • Loading branch information
callmekoo committed Jul 16, 2023
1 parent e756bc8 commit f86da5d
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 3 deletions.
4 changes: 4 additions & 0 deletions src/Verify.Tests/XmlTests.EmptyTag.verified.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<body>
<empty />
<node>text</node>
</body>
4 changes: 4 additions & 0 deletions src/Verify.Tests/XmlTests.EmptyTagWithAttributes.verified.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<body>
<empty id="Guid_1" att="asdf" />
<node>text</node>
</body>
2 changes: 1 addition & 1 deletion src/Verify.Tests/XmlTests.IgnoreAttribute.verified.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<body>
<node att="Scrubbed"></node>
<node att="Scrubbed" />
</body>
2 changes: 1 addition & 1 deletion src/Verify.Tests/XmlTests.ScrubAttribute.verified.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<body>
<node></node>
<node />
</body>
8 changes: 8 additions & 0 deletions src/Verify.Tests/XmlTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,4 +110,12 @@ public Task IgnoreAttribute()
public Task XDocScrubMember() =>
Verify(XDocument.Parse(xml))
.ScrubMember("node");

[Fact]
public Task EmptyTag() =>
VerifyXml("<body><empty /><node>text</node></body>");

[Fact]
public Task EmptyTagWithAttributes() =>
VerifyXml($@"<body><empty id=""{Guid.NewGuid()}"" att=""asdf"" /><node>text</node></body>");
}
2 changes: 1 addition & 1 deletion src/Verify/Verifier/InnerVerifier_Xml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ async Task<VerifyResult> VerifyXml(XContainer? target)
attribute.Value = ConvertValue(serialization, attribute.Value);
}

if (node.HasElements)
if (node.IsEmpty || node.HasElements)
{
continue;
}
Expand Down

0 comments on commit f86da5d

Please sign in to comment.