+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
throw new NotImplementedException ();
}
- [MonoTODO]
public virtual void RemoveAll ()
{
- throw new NotImplementedException ();
+ while (this.Count > 0)
+ base.RemoveNamedItem (this.Item (0).Name);
+
}
[MonoTODO]
attributes.RemoveAll ();
}
- [MonoTODO]
public virtual void RemoveAllAttributes ()
{
- throw new NotImplementedException ();
+ attributes.RemoveAll ();
}
[MonoTODO]
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)));
+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
/>
<Reference
Name = "System.XML"
- AssemblyName = "System.XML"
+ AssemblyName = "System.Xml"
HintPath = "..\obj\Debug\System.XML.dll"
/>
</References>
SubType = "Code"
BuildAction = "Compile"
/>
+ <File
+ RelPath = "XmlAttributeCollectionTests.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
<File
RelPath = "XmlAttributeTests.cs"
SubType = "Code"
AllTests.cs
NameTableTests.cs
SelectNodesTests.cs
+XmlAttributeCollectionTests.cs
XmlAttributeTests.cs
XmlCDataSectionTests.cs
XmlCharacterDataTests.cs
--- /dev/null
+// 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"));
+ }
+
+ }
+}
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"));
+ }
}
}