Author: atsushi
Date: 2005-12-13 06:19:46 -0500 (Tue, 13 Dec 2005)
New Revision: 54277
Modified:
trunk/mcs/class/System.XML/System.Xml.XPath/ChangeLog
trunk/mcs/class/System.XML/System.Xml.XPath/XPathNavigator.cs
trunk/mcs/class/System.XML/Test/System.Xml.XPath/ChangeLog
trunk/mcs/class/System.XML/Test/System.Xml.XPath/XPathEditableNavigatorTests.cs
Log:
2005-12-13 Atsushi Enomoto <[EMAIL PROTECTED]>
* XPathNavigator.cs : PrependChild() should use AppendChild() when
there is no child.
* XPathEditableNavigatorTests.cs : added tests for PrependChild().
Modified: trunk/mcs/class/System.XML/System.Xml.XPath/ChangeLog
===================================================================
--- trunk/mcs/class/System.XML/System.Xml.XPath/ChangeLog 2005-12-13
10:46:25 UTC (rev 54276)
+++ trunk/mcs/class/System.XML/System.Xml.XPath/ChangeLog 2005-12-13
11:19:46 UTC (rev 54277)
@@ -1,5 +1,10 @@
2005-12-13 Atsushi Enomoto <[EMAIL PROTECTED]>
+ * XPathNavigator.cs : PrependChild() should use AppendChild() when
+ there is no child.
+
+2005-12-13 Atsushi Enomoto <[EMAIL PROTECTED]>
+
* XPathNavigator.cs : InsertAfter() should raise an error before
MoveToNext() when current node is either attribute or namespace.
Modified: trunk/mcs/class/System.XML/System.Xml.XPath/XPathNavigator.cs
===================================================================
--- trunk/mcs/class/System.XML/System.Xml.XPath/XPathNavigator.cs
2005-12-13 10:46:25 UTC (rev 54276)
+++ trunk/mcs/class/System.XML/System.Xml.XPath/XPathNavigator.cs
2005-12-13 11:19:46 UTC (rev 54277)
@@ -1156,7 +1156,7 @@
if (nav.MoveToFirstChild ())
return nav.InsertBefore ();
else
- return InsertBefore ();
+ return AppendChild ();
}
public virtual void PrependChild (string xmlFragments)
@@ -1164,7 +1164,6 @@
PrependChild (CreateFragmentReader (xmlFragments));
}
- [MonoTODO]
public virtual void PrependChild (XmlReader reader)
{
using (XmlWriter w = PrependChild ()) {
Modified: trunk/mcs/class/System.XML/Test/System.Xml.XPath/ChangeLog
===================================================================
--- trunk/mcs/class/System.XML/Test/System.Xml.XPath/ChangeLog 2005-12-13
10:46:25 UTC (rev 54276)
+++ trunk/mcs/class/System.XML/Test/System.Xml.XPath/ChangeLog 2005-12-13
11:19:46 UTC (rev 54277)
@@ -1,5 +1,9 @@
2005-12-13 Atsushi Enomoto <[EMAIL PROTECTED]>
+ * XPathEditableNavigatorTests.cs : added tests for PrependChild().
+
+2005-12-13 Atsushi Enomoto <[EMAIL PROTECTED]>
+
* XPathEditableNavigatorTests.cs :
Added more tests for InsertAfter() and InsertBefore().
Added tests for DeleteRange() and ReplaceRange().
Modified:
trunk/mcs/class/System.XML/Test/System.Xml.XPath/XPathEditableNavigatorTests.cs
===================================================================
---
trunk/mcs/class/System.XML/Test/System.Xml.XPath/XPathEditableNavigatorTests.cs
2005-12-13 10:46:25 UTC (rev 54276)
+++
trunk/mcs/class/System.XML/Test/System.Xml.XPath/XPathEditableNavigatorTests.cs
2005-12-13 11:19:46 UTC (rev 54277)
@@ -450,6 +450,100 @@
end.MoveToFirstChild (); // child
nav.ReplaceRange (end);
}
+
+ [Test]
+ public void PrependChildXmlReader ()
+ {
+ XPathNavigator nav = GetInstance
("<root><foo>existing_child</foo></root>");
+ nav.MoveToFirstChild ();
+ nav.MoveToFirstChild (); // foo
+
+ XmlReader reader = new XmlTextReader (
+ "<child>text</child><next_sibling/>",
+ XmlNodeType.Element,
+ null);
+
+ nav.PrependChild (reader);
+
+ XmlAssert.AssertNode ("#0",
+ reader,
+ XmlNodeType.None,
+ 0, // Depth
+ false, // IsEmptyElement
+ String.Empty, // Name
+ String.Empty, // Prefix
+ String.Empty, // LocalName
+ String.Empty, // NamespaceURI
+ String.Empty, // Value
+ false, // HasValue
+ 0, // AttributeCount
+ false); // HasAttributes
+
+ AssertNavigator ("#1", nav,
+ XPathNodeType.Element,
+ String.Empty, // Prefix
+ "foo", // LocalName
+ String.Empty, // NamespaceURI
+ "foo", // Name
+ "textexisting_child", // Value
+ false, // HasAttributes
+ true, // HasChildren
+ false); // IsEmptyElement
+
+ Assert.IsTrue (nav.MoveToFirstChild (), "#1-2");
+
+ AssertNavigator ("#2", nav,
+ XPathNodeType.Element,
+ String.Empty, // Prefix
+ "child", // LocalName
+ String.Empty, // NamespaceURI
+ "child", // Name
+ "text", // Value
+ false, // HasAttributes
+ true, // HasChildren
+ false); // IsEmptyElement
+
+ Assert.IsTrue (nav.MoveToNext (), "#2-2");
+
+ AssertNavigator ("#3", nav,
+ XPathNodeType.Element,
+ String.Empty, // Prefix
+ "next_sibling", // LocalName
+ String.Empty, // NamespaceURI
+ "next_sibling", // Name
+ String.Empty, // Value
+ false, // HasAttributes
+ false, // HasChildren
+ true); // IsEmptyElement
+
+ Assert.IsTrue (nav.MoveToNext (), "#3-2");
+
+ AssertNavigator ("#4", nav,
+ XPathNodeType.Text,
+ String.Empty, // Prefix
+ String.Empty, // LocalName
+ String.Empty, // NamespaceURI
+ String.Empty, // Name
+ "existing_child",// Value
+ false, // HasAttributes
+ false, // HasChildren
+ false); // IsEmptyElement
+ }
+
+ [Test]
+ [ExpectedException (typeof (InvalidOperationException))]
+ public void PrependChildInvalid ()
+ {
+ XPathNavigator nav = GetInstance
("<root><foo>existing_child</foo></root>");
+ nav.MoveToFirstChild ();
+ nav.MoveToFirstChild (); // foo
+
+ XmlWriter w = nav.PrependChild ();
+
+ w.WriteStartAttribute ("whoa");
+ w.WriteEndAttribute ();
+ w.Close ();
+ }
}
}
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches