Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAtsushi Eno <atsushieno@gmail.com>2005-12-13 14:19:46 +0300
committerAtsushi Eno <atsushieno@gmail.com>2005-12-13 14:19:46 +0300
commitd3f0d5ba2845546e61363264656b59eece93f7b8 (patch)
tree9e31f252078749acb7210964dbaccfacabb52787 /mcs/class/System.XML
parentaba5cde6e552af5255f8c54b80c79a19f6f655c5 (diff)
2005-12-13 Atsushi Enomoto <atsushi@ximian.com>
* XPathNavigator.cs : PrependChild() should use AppendChild() when there is no child. * XPathEditableNavigatorTests.cs : added tests for PrependChild(). svn path=/trunk/mcs/; revision=54277
Diffstat (limited to 'mcs/class/System.XML')
-rw-r--r--mcs/class/System.XML/System.Xml.XPath/ChangeLog5
-rw-r--r--mcs/class/System.XML/System.Xml.XPath/XPathNavigator.cs3
-rw-r--r--mcs/class/System.XML/Test/System.Xml.XPath/ChangeLog4
-rw-r--r--mcs/class/System.XML/Test/System.Xml.XPath/XPathEditableNavigatorTests.cs94
4 files changed, 104 insertions, 2 deletions
diff --git a/mcs/class/System.XML/System.Xml.XPath/ChangeLog b/mcs/class/System.XML/System.Xml.XPath/ChangeLog
index f8cc3cc241c..a28c683ca28 100644
--- a/mcs/class/System.XML/System.Xml.XPath/ChangeLog
+++ b/mcs/class/System.XML/System.Xml.XPath/ChangeLog
@@ -1,5 +1,10 @@
2005-12-13 Atsushi Enomoto <atsushi@ximian.com>
+ * XPathNavigator.cs : PrependChild() should use AppendChild() when
+ there is no child.
+
+2005-12-13 Atsushi Enomoto <atsushi@ximian.com>
+
* XPathNavigator.cs : InsertAfter() should raise an error before
MoveToNext() when current node is either attribute or namespace.
diff --git a/mcs/class/System.XML/System.Xml.XPath/XPathNavigator.cs b/mcs/class/System.XML/System.Xml.XPath/XPathNavigator.cs
index 9f8a04a7ff2..e32ad8fe78c 100644
--- a/mcs/class/System.XML/System.Xml.XPath/XPathNavigator.cs
+++ b/mcs/class/System.XML/System.Xml.XPath/XPathNavigator.cs
@@ -1156,7 +1156,7 @@ namespace System.Xml.XPath
if (nav.MoveToFirstChild ())
return nav.InsertBefore ();
else
- return InsertBefore ();
+ return AppendChild ();
}
public virtual void PrependChild (string xmlFragments)
@@ -1164,7 +1164,6 @@ namespace System.Xml.XPath
PrependChild (CreateFragmentReader (xmlFragments));
}
- [MonoTODO]
public virtual void PrependChild (XmlReader reader)
{
using (XmlWriter w = PrependChild ()) {
diff --git a/mcs/class/System.XML/Test/System.Xml.XPath/ChangeLog b/mcs/class/System.XML/Test/System.Xml.XPath/ChangeLog
index 8943911a019..6861a21a445 100644
--- a/mcs/class/System.XML/Test/System.Xml.XPath/ChangeLog
+++ b/mcs/class/System.XML/Test/System.Xml.XPath/ChangeLog
@@ -1,5 +1,9 @@
2005-12-13 Atsushi Enomoto <atsushi@ximian.com>
+ * XPathEditableNavigatorTests.cs : added tests for PrependChild().
+
+2005-12-13 Atsushi Enomoto <atsushi@ximian.com>
+
* XPathEditableNavigatorTests.cs :
Added more tests for InsertAfter() and InsertBefore().
Added tests for DeleteRange() and ReplaceRange().
diff --git a/mcs/class/System.XML/Test/System.Xml.XPath/XPathEditableNavigatorTests.cs b/mcs/class/System.XML/Test/System.Xml.XPath/XPathEditableNavigatorTests.cs
index 8fd955dae9e..00501807e00 100644
--- a/mcs/class/System.XML/Test/System.Xml.XPath/XPathEditableNavigatorTests.cs
+++ b/mcs/class/System.XML/Test/System.Xml.XPath/XPathEditableNavigatorTests.cs
@@ -450,6 +450,100 @@ namespace MonoTests.System.Xml.XPath
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 ();
+ }
}
}