Skip to content

Commit 71509e3

Browse files
authored
Merge pull request #53 from xmlunit/deal-with-null-attrs
xmlunit/xmlunit#307 doesn't seem to happen …
2 parents a623faf + 4f1afc9 commit 71509e3

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

src/tests/net-core/Diff/DOMDifferenceEngineTest.cs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1171,6 +1171,33 @@ public void XPathKnowsAboutNodeFiltersForUnmatchedTestNodes() {
11711171
Assert.AreEqual("/Document[1]/Section[1]", diff.Differences.Last().Comparison.ControlDetails.ParentXPath);
11721172
}
11731173

1174+
[Test]
1175+
public void ProperlyHandlesNullAttributes() {
1176+
DOMDifferenceEngine d = new DOMDifferenceEngine();
1177+
DiffExpecter ex = new DiffExpecter(ComparisonType.ATTR_VALUE);
1178+
d.DifferenceListener += ex.ComparisonPerformed;
1179+
d.ComparisonController = ComparisonControllers.StopWhenDifferent;
1180+
1181+
XmlElement e1 = doc.CreateElement("foo");
1182+
e1.SetAttribute("x", null);
1183+
XmlElement e2 = doc.CreateElement("foo");
1184+
e2.SetAttribute("x", null);
1185+
XmlElement e3 = doc.CreateElement("foo");
1186+
e3.SetAttribute("x", "2137");
1187+
XmlElement e4 = doc.CreateElement("foo");
1188+
e4.SetAttribute("x", string.Empty);
1189+
1190+
Assert.AreEqual(Wrap(ComparisonResult.EQUAL),
1191+
d.CompareNodes(e1, new XPathContext(),
1192+
e2, new XPathContext()));
1193+
Assert.AreEqual(WrapAndStop(ComparisonResult.DIFFERENT),
1194+
d.CompareNodes(e1, new XPathContext(),
1195+
e3, new XPathContext()));
1196+
Assert.AreEqual(Wrap(ComparisonResult.EQUAL),
1197+
d.CompareNodes(e1, new XPathContext(),
1198+
e4, new XPathContext()));
1199+
}
1200+
11741201
private XmlDocument DocumentForString(string s) {
11751202
return Org.XmlUnit.Util.Convert.ToDocument(InputBuilder.FromString(s).Build());
11761203
}

0 commit comments

Comments
 (0)