Skip to content

Commit 42e6730

Browse files
committed
.
1 parent 89c6547 commit 42e6730

File tree

7 files changed

+34
-4
lines changed

7 files changed

+34
-4
lines changed

docs/verify-xml.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public Task XmlIgnoreMember() =>
6666
VerifyXml(xml)
6767
.IgnoreMember("node");
6868
```
69-
<sup><a href='/src/Verify.Tests/XmlTests.cs#L46-L53' title='Snippet source file'>snippet source</a> | <a href='#snippet-XmlIgnoreMember' title='Start of snippet'>anchor</a></sup>
69+
<sup><a href='/src/Verify.Tests/XmlTests.cs#L64-L71' title='Snippet source file'>snippet source</a> | <a href='#snippet-XmlIgnoreMember' title='Start of snippet'>anchor</a></sup>
7070
<!-- endSnippet -->
7171

7272
Will produce
@@ -92,7 +92,7 @@ public Task XmlScrubMember() =>
9292
VerifyXml(xml)
9393
.ScrubMember("node");
9494
```
95-
<sup><a href='/src/Verify.Tests/XmlTests.cs#L55-L62' title='Snippet source file'>snippet source</a> | <a href='#snippet-XmlScrubMember' title='Start of snippet'>anchor</a></sup>
95+
<sup><a href='/src/Verify.Tests/XmlTests.cs#L73-L80' title='Snippet source file'>snippet source</a> | <a href='#snippet-XmlScrubMember' title='Start of snippet'>anchor</a></sup>
9696
<!-- endSnippet -->
9797

9898
Will produce
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-

1+
<person><![CDATA[name is John Doe]]></person>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<person><![CDATA[name is John Doe]]>value</person>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<person><![CDATA[replaced]]>replaced</person>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<person><![CDATA[replaced]]></person>

src/Verify.Tests/XmlTests.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,15 @@ public Task CData() =>
3535
<person><![CDATA[name is John Doe]]></person>
3636
""");
3737

38+
[Fact]
39+
public Task CData_WithScrub() =>
40+
VerifyXml(
41+
"""
42+
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
43+
<person><![CDATA[value]]></person>
44+
""")
45+
.AddScrubber(_ => _.Replace("value", "replaced"));
46+
3847
[Fact]
3948
public Task CDataMix() =>
4049
VerifyXml(
@@ -43,6 +52,15 @@ public Task CDataMix() =>
4352
<person><![CDATA[name is John Doe]]>value</person>
4453
""");
4554

55+
[Fact]
56+
public Task CDataMix_WithScrub() =>
57+
VerifyXml(
58+
"""
59+
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
60+
<person><![CDATA[value]]>value</person>
61+
""")
62+
.AddScrubber(_ => _.Replace("value", "replaced"));
63+
4664
#region XmlIgnoreMember
4765

4866
[Fact]

src/Verify/Verifier/InnerVerifier_Xml.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,16 @@ Task<VerifyResult> VerifyXml(XContainer? target)
8787

8888
foreach (var node in target.DescendantNodes())
8989
{
90-
Debug.WriteLine(node);
90+
if (node is XText text)
91+
{
92+
text.Value = ConvertValue(serialization, text.Value);
93+
continue;
94+
}
95+
if (node is XCData cdata)
96+
{
97+
cdata.Value = ConvertValue(serialization, cdata.Value);
98+
continue;
99+
}
91100
}
92101

93102
return VerifyString(target.ToString(), "xml");

0 commit comments

Comments
 (0)