diff options
author | Jason Diamond <injektilo@mono-cvs.ximian.com> | 2002-08-23 09:09:53 +0400 |
---|---|---|
committer | Jason Diamond <injektilo@mono-cvs.ximian.com> | 2002-08-23 09:09:53 +0400 |
commit | d0cd6199a50148579b6755b641fc9c13bba93597 (patch) | |
tree | ce055e94c94316b04f4c174b2d6eb7b5b77e3120 /mcs/class | |
parent | db0e7930ea0a70dbcb582462fea71978eee2484a (diff) |
Implementation and tests for XmlAttributeCollection.RemoveAll and XmlElement.RemoveAllAttributes courtesy of Matt Hunter <xrkune@tconl.com>.
svn path=/trunk/mcs/; revision=6926
Diffstat (limited to 'mcs/class')
-rw-r--r-- | mcs/class/System.XML/System.Xml/ChangeLog | 5 | ||||
-rw-r--r-- | mcs/class/System.XML/System.Xml/XmlAttributeCollection.cs | 5 | ||||
-rw-r--r-- | mcs/class/System.XML/System.Xml/XmlElement.cs | 3 | ||||
-rw-r--r-- | mcs/class/System.XML/Test/AllTests.cs | 1 | ||||
-rw-r--r-- | mcs/class/System.XML/Test/ChangeLog | 7 | ||||
-rw-r--r-- | mcs/class/System.XML/Test/MonoMicro.Test.csproj | 7 | ||||
-rw-r--r-- | mcs/class/System.XML/Test/System.XML_linux_test.args | 1 | ||||
-rw-r--r-- | mcs/class/System.XML/Test/XmlAttributeCollectionTests.cs | 46 | ||||
-rw-r--r-- | mcs/class/System.XML/Test/XmlElementTests.cs | 17 |
9 files changed, 87 insertions, 5 deletions
diff --git a/mcs/class/System.XML/System.Xml/ChangeLog b/mcs/class/System.XML/System.Xml/ChangeLog index bb2e2a8ab7d..a44fce96d1b 100644 --- a/mcs/class/System.XML/System.Xml/ChangeLog +++ b/mcs/class/System.XML/System.Xml/ChangeLog @@ -1,5 +1,10 @@ 2002-08-22 Jason Diamond <jason@injektilo.org> + * XmlAttributeCollection.cs, XmlElement.cs: Implementation of RemoveAll + and RemoveAllAttributes courtesy of Matt Hunter <xrkune@tconl.com>. + +2002-08-22 Jason Diamond <jason@injektilo.org> + * XmlElement.cs: Correction to previous GetElementsByTagName patch courtesy of Matt Hunter <xrkune@tconl.com>. diff --git a/mcs/class/System.XML/System.Xml/XmlAttributeCollection.cs b/mcs/class/System.XML/System.Xml/XmlAttributeCollection.cs index 203d8d33f15..3c3afbf5385 100644 --- a/mcs/class/System.XML/System.Xml/XmlAttributeCollection.cs +++ b/mcs/class/System.XML/System.Xml/XmlAttributeCollection.cs @@ -96,10 +96,11 @@ namespace System.Xml throw new NotImplementedException (); } - [MonoTODO] public virtual void RemoveAll () { - throw new NotImplementedException (); + while (this.Count > 0) + base.RemoveNamedItem (this.Item (0).Name); + } [MonoTODO] diff --git a/mcs/class/System.XML/System.Xml/XmlElement.cs b/mcs/class/System.XML/System.Xml/XmlElement.cs index 11802a285ac..5c346024596 100644 --- a/mcs/class/System.XML/System.Xml/XmlElement.cs +++ b/mcs/class/System.XML/System.Xml/XmlElement.cs @@ -217,10 +217,9 @@ namespace System.Xml attributes.RemoveAll (); } - [MonoTODO] public virtual void RemoveAllAttributes () { - throw new NotImplementedException (); + attributes.RemoveAll (); } [MonoTODO] diff --git a/mcs/class/System.XML/Test/AllTests.cs b/mcs/class/System.XML/Test/AllTests.cs index a1b0583c08a..1ebb2952079 100644 --- a/mcs/class/System.XML/Test/AllTests.cs +++ b/mcs/class/System.XML/Test/AllTests.cs @@ -25,6 +25,7 @@ namespace MonoTests.System.Xml suite.AddTest (new TestSuite (typeof (XmlTextWriterTests))); suite.AddTest (new TestSuite (typeof (XmlNamespaceManagerTests))); suite.AddTest (new TestSuite (typeof (XmlAttributeTests))); + suite.AddTest (new TestSuite (typeof (XmlAttributeCollectionTests))); suite.AddTest (new TestSuite (typeof (XmlDocumentTests))); suite.AddTest (new TestSuite (typeof (NameTableTests))); suite.AddTest (new TestSuite (typeof (XmlElementTests))); diff --git a/mcs/class/System.XML/Test/ChangeLog b/mcs/class/System.XML/Test/ChangeLog index 86707218b62..cb73def2b85 100644 --- a/mcs/class/System.XML/Test/ChangeLog +++ b/mcs/class/System.XML/Test/ChangeLog @@ -1,5 +1,12 @@ 2002-08-22 Jason Diamond <jason@injektilo.org> + * AllTests.cs, System.XML_linux_test.args, + XmlAttributeCollectionTests.cs,XmlElementTests.cs: Added test for + RemoveAll and RemoveAllAttributes courtesy of Matt Hunter + <xrkune@tconl.com>. + +2002-08-22 Jason Diamond <jason@injektilo.org> + * XmlElementTests.cs: Correction to previous GetElementsByTagName patch courtesy of Matt Hunter <xrkune@tconl.com>. diff --git a/mcs/class/System.XML/Test/MonoMicro.Test.csproj b/mcs/class/System.XML/Test/MonoMicro.Test.csproj index a14116ecdf1..a90ea037a17 100644 --- a/mcs/class/System.XML/Test/MonoMicro.Test.csproj +++ b/mcs/class/System.XML/Test/MonoMicro.Test.csproj @@ -74,7 +74,7 @@ /> <Reference Name = "System.XML" - AssemblyName = "System.XML" + AssemblyName = "System.Xml" HintPath = "..\obj\Debug\System.XML.dll" /> </References> @@ -101,6 +101,11 @@ BuildAction = "Compile" /> <File + RelPath = "XmlAttributeCollectionTests.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File RelPath = "XmlAttributeTests.cs" SubType = "Code" BuildAction = "Compile" diff --git a/mcs/class/System.XML/Test/System.XML_linux_test.args b/mcs/class/System.XML/Test/System.XML_linux_test.args index a2ea8457396..51c948e9812 100644 --- a/mcs/class/System.XML/Test/System.XML_linux_test.args +++ b/mcs/class/System.XML/Test/System.XML_linux_test.args @@ -7,6 +7,7 @@ AllTests.cs NameTableTests.cs SelectNodesTests.cs +XmlAttributeCollectionTests.cs XmlAttributeTests.cs XmlCDataSectionTests.cs XmlCharacterDataTests.cs diff --git a/mcs/class/System.XML/Test/XmlAttributeCollectionTests.cs b/mcs/class/System.XML/Test/XmlAttributeCollectionTests.cs new file mode 100644 index 00000000000..218691fccb8 --- /dev/null +++ b/mcs/class/System.XML/Test/XmlAttributeCollectionTests.cs @@ -0,0 +1,46 @@ +// XmlAttributeCollectionTests.cs : Tests for the XmlAttributeCollection class +// +// Author: Matt Hunter <xrkune@tconl.com> +// +// <c> 2002 Matt Hunter + +using System; +using System.Xml; +using System.Text; +using System.IO; + +using NUnit.Framework; + +namespace MonoTests.System.Xml +{ + public class XmlAttributeCollectionTests : TestCase + { + public XmlAttributeCollectionTests() : base("MonoTests.System.Xml.XmlAttributeCollectionTests testsuite") { } + public XmlAttributeCollectionTests(string name) : base(name) { } + + private XmlDocument document; + + protected override void SetUp() + { + document = new XmlDocument (); + } + public void TestRemoveAll () + { + StringBuilder xml = new StringBuilder (); + xml.Append ("<?xml version=\"1.0\" ?><library><book type=\"non-fiction\" price=\"34.95\"> "); + xml.Append ("<title type=\"intro\">XML Fun</title> " ); + xml.Append ("<author>John Doe</author></book></library>"); + + MemoryStream memoryStream = new MemoryStream (Encoding.UTF8.GetBytes (xml.ToString ())); + document = new XmlDocument (); + document.Load (memoryStream); + XmlNodeList bookList = document.GetElementsByTagName ("book"); + XmlNode xmlNode = bookList.Item (0); + XmlElement xmlElement = xmlNode as XmlElement; + XmlAttributeCollection attributes = xmlElement.Attributes; + attributes.RemoveAll (); + AssertEquals ("not all attributes removed.", false, xmlElement.HasAttribute ("type")); + } + + } +} diff --git a/mcs/class/System.XML/Test/XmlElementTests.cs b/mcs/class/System.XML/Test/XmlElementTests.cs index a8561f39373..83a45b1e45f 100644 --- a/mcs/class/System.XML/Test/XmlElementTests.cs +++ b/mcs/class/System.XML/Test/XmlElementTests.cs @@ -188,5 +188,22 @@ namespace MonoTests.System.Xml XmlElement element = document.CreateElement ("foo", "bar", "#foo"); AssertEquals ("<foo:bar xmlns:foo=\"#foo\" />", element.OuterXml); } + + public void TestRemoveAllAttributes () + { + StringBuilder xml = new StringBuilder (); + xml.Append ("<?xml version=\"1.0\" ?><library><book type=\"non-fiction\" price=\"34.95\"> "); + xml.Append ("<title type=\"intro\">XML Fun</title> " ); + xml.Append ("<author>John Doe</author></book></library>"); + + MemoryStream memoryStream = new MemoryStream (Encoding.UTF8.GetBytes (xml.ToString ())); + document = new XmlDocument (); + document.Load (memoryStream); + XmlNodeList bookList = document.GetElementsByTagName ("book"); + XmlNode xmlNode = bookList.Item (0); + XmlElement xmlElement = xmlNode as XmlElement; + xmlElement.RemoveAllAttributes (); + AssertEquals ("attributes not properly removed.", false, xmlElement.HasAttribute ("type")); + } } } |