Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit c575106

Browse files
committed
Fix tests to pass when running on Desktop (Win10)
1 parent 39cbff9 commit c575106

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

src/System.Xml.XPath.XDocument/tests/XDocument/NavigatorComparer.cs

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ private static void CompareNavigators(XPathNavigator a, XPathNavigator b)
2929

3030
if (AreComparableNodes(a.NodeType, b.NodeType))
3131
{
32-
Assert.Equal(a.Value, b.Value);
33-
Assert.Equal(a.Value, b.Value);
32+
CompareValues(a, b);
3433
Assert.Equal(a.Name, b.Name);
3534
}
3635
#endif
@@ -69,6 +68,15 @@ private static void CompareNodeTypes(XPathNodeType a, XPathNodeType b)
6968
Assert.Equal(a, b);
7069
}
7170
}
71+
72+
private static void CompareValues(XPathNavigator a, XPathNavigator b)
73+
{
74+
// In order to account for Desktop vs CoreCLR difference in implementation of XmlDocument we need to normalize line endings to conform XML specification.
75+
string sa = a.Value.Replace("\r\n", "\n").Replace("\r", "\n");
76+
string sb = b.Value.Replace("\r\n", "\n").Replace("\r", "\n");
77+
78+
Assert.Equal(sa, sb);
79+
}
7280

7381
public NavigatorComparer(XPathNavigator nav1, XPathNavigator nav2)
7482
{
@@ -620,18 +628,16 @@ public override string Value
620628
{
621629
get
622630
{
623-
var r1 = _nav1.Value;
624-
var r2 = _nav2.Value;
625631
#if CHECK_ATTRIBUTE_ORDER
626-
Assert.Equal(r1, r2);
632+
CompareValues(_nav1, _nav2);
627633
#else
628634
CompareNodeTypes(_nav1.NodeType, _nav2.NodeType);
629635
if (!IsNamespaceOrAttribute(_nav1.NodeType))
630636
{
631-
Assert.Equal(r1, r2);
637+
CompareValues(_nav1, _nav2);
632638
}
633639
#endif
634-
return r1;
640+
return _nav1.Value;
635641
}
636642
}
637643
public override object ValueAs(Type value)

0 commit comments

Comments
 (0)