|
|
@@ -11,6 +11,7 @@
|
|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
using System.IO;
|
|
|
+using System.Linq;
|
|
|
using System.Xml;
|
|
|
using System.Xml.XPath;
|
|
|
|
|
|
@@ -463,6 +464,7 @@ namespace MonoTests.System.Xml.XPath
|
|
|
Assert.AreEqual (5, nodes.Count, "#2");
|
|
|
}
|
|
|
|
|
|
+ // This test requires Linq.
|
|
|
[Test] // xamarin bug #3705
|
|
|
public void ReturnedNavigatorInstancesUnique ()
|
|
|
{
|
|
|
@@ -477,19 +479,28 @@ namespace MonoTests.System.Xml.XPath
|
|
|
var data = new XPathDocument (r);
|
|
|
var l = new List<XPathNavigator> ();
|
|
|
|
|
|
- // test PredicateIterator.
|
|
|
+ // test PredicateIterator wrapped by XPathNodeIteratorEnumerator.
|
|
|
var parent = data.CreateNavigator ().SelectSingleNode ("/Notes");
|
|
|
foreach (XPathNavigator n in parent.Select ("Note[Reference]")) {
|
|
|
Assert.IsFalse (l.Contains (n), "should not iterate the same XPathNavigator instance twice, regardless of whether position is same or not");
|
|
|
l.Add (n);
|
|
|
}
|
|
|
|
|
|
- // Same test for SimpleSlashIterator.
|
|
|
+ // Same test for SimpleSlashIterator wrapped by XPathNodeIteratorEnumerator.
|
|
|
l.Clear ();
|
|
|
foreach (XPathNavigator n in data.CreateNavigator ().Select ("/Notes/Note[Reference]")) {
|
|
|
Assert.IsFalse (l.Contains (n), "should not iterate the same XPathNavigator instance twice, regardless of whether position is same or not");
|
|
|
l.Add (n);
|
|
|
}
|
|
|
+
|
|
|
+ // test orderby too. In short, XPathNodeIteratorEnumerator is the key player that assures XPathNavigator uniqueness.
|
|
|
+ foreach (XPathNavigator n in data.CreateNavigator ()
|
|
|
+ .Select ("/Notes/Note[Reference]")
|
|
|
+ .Cast<XPathNavigator> ()
|
|
|
+ .OrderBy (nav => nav.SelectSingleNode ("Reference").Value)) {
|
|
|
+ Assert.IsFalse (l.Contains (n), "should not iterate the same XPathNavigator instance twice, regardless of whether position is same or not");
|
|
|
+ l.Add (n);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|