AssertEquals ("#1", "x", doc.FirstChild.FirstChild.Prefix);
AssertEquals ("#2", "x", doc.FirstChild.FirstChild.Attributes [0].Prefix);
}
+
+ [Test]
+ public void ValueAs ()
+ {
+ string xml = "<root>1</root>";
+ XPathNavigator nav = new XPathDocument (XmlReader.Create (new StringReader (xml))).CreateNavigator ();
+ nav.MoveToFirstChild ();
+ nav.MoveToFirstChild ();
+ AssertEquals ("1", nav.ValueAs (typeof (string), null));
+ AssertEquals (1, nav.ValueAs (typeof (int), null));
+ }
+
+ [Test]
+ public void MoveToFollowingNodeTypeAll ()
+ {
+ XmlDocument doc = new XmlDocument ();
+ doc.LoadXml ("<root><child/><child2/></root>");
+ XPathNavigator nav = doc.CreateNavigator ();
+ Assert ("#1", nav.MoveToFollowing (XPathNodeType.All));
+ Assert ("#2", nav.MoveToFollowing (XPathNodeType.All));
+ AssertEquals ("#3", "child", nav.LocalName);
+ Assert ("#4", nav.MoveToNext (XPathNodeType.All));
+ AssertEquals ("#5", "child2", nav.LocalName);
+ }
+
+ [Test] // bug #324606.
+ public void XPathDocumentFromSubtreeNodes ()
+ {
+ string xml = "<root><child1><nest1><nest2>hello!</nest2></nest1></child1><child2/><child3/></root>";
+ XmlReader r = new XmlTextReader (new StringReader (xml));
+ while (r.Read ()) {
+ if (r.Name == "child1")
+ break;
+ }
+ XPathDocument d = new XPathDocument (r);
+ XPathNavigator n = d.CreateNavigator ();
+ string result = @"<child1>
+ <nest1>
+ <nest2>hello!</nest2>
+ </nest1>
+</child1>
+<child2 />
+<child3 />";
+ AssertEquals (result, n.OuterXml.Replace ("\r\n", "\n"));
+ }
+
+ [Test] // bug #376191
+ public void InnerXmlOnRoot ()
+ {
+ XmlDocument document = new XmlDocument ();
+ document.LoadXml (@"<test>
+ <node>z</node>
+ <node>a</node>
+ <node>b</node>
+ <node>q</node>
+ </test>");
+ XPathNavigator navigator = document.CreateNavigator();
+ AssertEquals (navigator.OuterXml, navigator.InnerXml);
+ }
#endif
}
}