+2002-04-08 Kral Ferch <kral_ferch@hotmail.com>
+
+ * XmlAttributes.cs: InnerXml getter, WriteContentTo, and WriteTo
+ implementations.
+
+ * XmlDeclaration.cs: WriteTo implementation.
+
+ * XmlDocument.cs: InnerXml getter implementation.
+
+ * XmlElement.cs: InnerXml getter implementation.
+
+ * XmlNode.cs: Removed MonoTODO attrib on OuterXml.
+
+ * XmlSignificantWhitespace.cs: WriteTo implementation.
+
+ * XmlText.cs: WriteContentTo and WriteTo implementation.
+
+ * XmlTextWriter.cs: WriteRaw implementation.
+
+ * XmlWhitespace.cs: WriteContentTo and WriteTo implementations.
+
2002-04-05 Kral Ferch <kral_ferch@hotmail.com>
* XmlAttributes.cs: Added reminder MonoTODO to set NamespaceURI
}
}
- [MonoTODO]
+ [MonoTODO ("Setter.")]
public override string InnerXml {
get {
- throw new NotImplementedException ();
+ // Not sure why this is an override. Passing through for now.
+ return base.InnerXml;
}
set {
this.ownerElement = ownerElement;
}
- [MonoTODO]
public override void WriteContentTo (XmlWriter w)
{
- throw new NotImplementedException ();
+ w.WriteString (Value);
}
- [MonoTODO]
public override void WriteTo (XmlWriter w)
{
- throw new NotImplementedException ();
+ w.WriteAttributeString (prefix, localName, namespaceURI, Value);
}
#endregion
return new XmlDeclaration (Version, Encoding, standalone, OwnerDocument);
}
- public override void WriteContentTo (XmlWriter w)
- {
- // Nothing to do - no children.
- }
+ public override void WriteContentTo (XmlWriter w) {}
- [MonoTODO]
public override void WriteTo (XmlWriter w)
{
- if ((Standalone == String.Empty) || (Encoding == String.Empty))
- return;
+ // This doesn't seem to match up very well with w.WriteStartDocument()
+ // so writing out custom here.
+ w.WriteRaw (String.Format ("<?xml {0}?>", Value));
}
void ParseInput (string input)
get { throw new NotImplementedException(); }
}
- [MonoTODO]
+ [MonoTODO ("Setter.")]
public override string InnerXml {
- get { throw new NotImplementedException(); }
+ get {
+ // Not sure why this is an override. Passing through for now.
+ return base.InnerXml;
+ }
set { throw new NotImplementedException(); }
}
throw new NotImplementedException ();
}
- [MonoTODO]
public XmlAttribute CreateAttribute (string name)
{
return CreateAttribute (name, String.Empty);
}
- [MonoTODO]
public XmlAttribute CreateAttribute (string qualifiedName, string namespaceURI)
{
string prefix;
set { throw new NotImplementedException (); }
}
- [MonoTODO]
+ [MonoTODO ("Setter.")]
public override string InnerXml {
- get { throw new NotImplementedException (); }
-
+ get {
+ // Not sure why this is an override. Passing through for now.
+ return base.InnerXml;
+ }
set { throw new NotImplementedException (); }
}
public abstract XmlNodeType NodeType { get; }
- [MonoTODO]
public virtual string OuterXml {
get {
StringWriter sw = new StringWriter ();
-//\r
-// System.Xml.XmlSignificantWhitespace.cs\r
-//\r
-// Author:\r
-// Duncan Mak (duncan@ximian.com)\r
-//\r
-// (C) Ximian, Inc. http://www.ximian.com\r
-//\r
-\r
-using System;\r
-\r
-namespace System.Xml\r
-{\r
- public class XmlSignificantWhitespace : XmlCharacterData\r
- {\r
- // Constructor\r
- protected internal XmlSignificantWhitespace (string strData, XmlDocument doc)\r
- : base (strData, doc)\r
- {\r
- }\r
- \r
- // Properties\r
- public override string LocalName {\r
- get { return "#significant-whitespace"; }\r
- }\r
-\r
- public override string Name {\r
- get { return "#significant-whitespace"; }\r
- }\r
-\r
- public override XmlNodeType NodeType {\r
- get { return XmlNodeType.SignificantWhitespace; }\r
- }\r
-\r
- public override string Value {\r
- get { return Data; }\r
- set {}\r
- }\r
-\r
- // Methods\r
- public override XmlNode CloneNode (bool deep)\r
- {\r
- return new XmlSignificantWhitespace (Data, OwnerDocument);\r
- }\r
-\r
- [MonoTODO]\r
- public override void WriteContentTo (XmlWriter w)\r
- { \r
- }\r
-\r
- [MonoTODO]\r
- public override void WriteTo (XmlWriter w)\r
- { \r
- }\r
- }\r
-}\r
+//
+// System.Xml.XmlSignificantWhitespace.cs
+//
+// Author:
+// Duncan Mak (duncan@ximian.com)
+//
+// (C) Ximian, Inc. http://www.ximian.com
+//
+
+using System;
+
+namespace System.Xml
+{
+ public class XmlSignificantWhitespace : XmlCharacterData
+ {
+ // Constructor
+ protected internal XmlSignificantWhitespace (string strData, XmlDocument doc)
+ : base (strData, doc)
+ {
+ }
+
+ // Properties
+ public override string LocalName {
+ get { return "#significant-whitespace"; }
+ }
+
+ public override string Name {
+ get { return "#significant-whitespace"; }
+ }
+
+ public override XmlNodeType NodeType {
+ get { return XmlNodeType.SignificantWhitespace; }
+ }
+
+ public override string Value {
+ get { return Data; }
+ set {}
+ }
+
+ // Methods
+ public override XmlNode CloneNode (bool deep)
+ {
+ return new XmlSignificantWhitespace (Data, OwnerDocument);
+ }
+
+ public override void WriteContentTo (XmlWriter w) {}
+
+ public override void WriteTo (XmlWriter w)
+ {
+ w.WriteWhitespace (Data);
+ }
+ }
+}
throw new NotImplementedException ();
}
- [MonoTODO]
- public override void WriteContentTo (XmlWriter w)
- {
- throw new NotImplementedException ();
- }
+ public override void WriteContentTo (XmlWriter w) {}
- [MonoTODO]
public override void WriteTo (XmlWriter w)
{
- throw new NotImplementedException ();
+ w.WriteString (Data);
}
#endregion
throw new NotImplementedException ();
}
- [MonoTODO]
public override void WriteRaw (string data)
{
- throw new NotImplementedException ();
+ WriteStringInternal (data, false);
}
[MonoTODO]
if (ws == WriteState.Prolog)
throw new InvalidOperationException ("Token content in state Prolog would result in an invalid XML document.");
+ WriteStringInternal (text, true);
+ }
+
+ public void WriteStringInternal (string text, bool entitize)
+ {
if (text == null)
text = String.Empty;
- if (text != String.Empty) {
+ if (text != String.Empty)
+ {
CheckState ();
- text = text.Replace ("&", "&");
- text = text.Replace ("<", "<");
- text = text.Replace (">", ">");
-
- if (openAttribute) {
- if (quoteChar == '"')
- text = text.Replace ("\"", """);
- else
- text = text.Replace ("'", "'");
+ if (entitize)
+ {
+ text = text.Replace ("&", "&");
+ text = text.Replace ("<", "<");
+ text = text.Replace (">", ">");
+
+ if (openAttribute)
+ {
+ if (quoteChar == '"')
+ text = text.Replace ("\"", """);
+ else
+ text = text.Replace ("'", "'");
+ }
}
if (!openAttribute)
if (!openXmlLang && !openXmlSpace)
w.Write (text);
- else {
+ else
+ {
if (openXmlLang)
xmlLang = text;
- else {
- switch (text) {
+ else
+ {
+ switch (text)
+ {
case "default":
xmlSpace = XmlSpace.Default;
break;
return new XmlWhitespace (Data, OwnerDocument);
}
- [MonoTODO]
- public override void WriteContentTo (XmlWriter w)
- {
- }
+ public override void WriteContentTo (XmlWriter w) {}
- [MonoTODO]
public override void WriteTo (XmlWriter w)
- {
+ {
+ w.WriteWhitespace (Data);
}
}
}
public static ITest Suite {
get {
TestSuite suite = new TestSuite ();
+ suite.AddTest (new TestSuite (typeof (XmlProcessingInstructionTests)));
+ suite.AddTest (new TestSuite (typeof (XmlTextTests)));
suite.AddTest (new TestSuite (typeof (XmlTextReaderTests)));
suite.AddTest (new TestSuite (typeof (XmlTextWriterTests)));
suite.AddTest (new TestSuite (typeof (XmlNamespaceManagerTests)));
+2002-04-08 Kral Ferch <kral_ferch@hotmail.com>
+
+ * AllTests.cs: added XmlProcessingInstructionTests and XmlTextTests.
+
+ * MonoMicro.Test.csproj: Added XmlProcessingInstructionTests.cs and
+ XmlTextTests.cs.
+
+ * XmlAttributeTests.cs: Added TestAttributeInnerAndOuterXml.
+
+ * XmlCDataSectionTests.cs: Added TestXmlCDataSectionInnerAndOuterXml.
+
+ * XmlCommentTests.cs: Added TestXmlCommentInnerAndOuterXml.
+
+ * XmlDeclarationTests.cs: Added TestInnerAndOuterXml.
+
+ * XmlDocumentTests.cs: Added TestInnerAndOuterXml.
+
+ * XmlElementTests.cs: Added TestInnerAndOuterXml.
+
+ * XmlProcessingInstructionTests.cs: Initial check-in.
+
+ * XmlSignificantWhitespaceTests.cs: Added TestInnerAndOuterXml.
+
+ * XmlTextTests.cs: Initial check-in.
+
+ * XmlTextWriterTests.cs: Added TestWriteRaw, TestWriteRawInvalidInAttribute,
+ and TestXmlSpaceRaw.
+
+ * XmlWhiteSpacesTests.cs: Added TestInnerAndOuterXml.
+
2002-04-05 Kral Ferch <kral_ferch@hotmail.com>
* XmlDocumentTests.cs: CreateNode tests.
AssemblyName = "NUnitCore"
HintPath = "..\..\..\nunit\NUnitCore.dll"
/>
+ <Reference
+ Name = "System.Data"
+ AssemblyName = "System.Data"
+ HintPath = "..\..\..\..\..\WINDOWS\Microsoft.NET\Framework\v1.0.3705\System.Data.dll"
+ />
<Reference
Name = "System.XML"
AssemblyName = "System.XML"
- HintPath = "..\..\..\..\..\WINDOWS\Microsoft.NET\Framework\v1.0.3705\System.XML.dll"
+ HintPath = "..\obj\Debug\System.XML.dll"
/>
</References>
</Build>
SubType = "Code"
BuildAction = "Compile"
/>
+ <File
+ RelPath = "XmlProcessingInstructionTests.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
<File
RelPath = "XmlSignificantWhitespaceTests.cs"
SubType = "Code"
SubType = "Code"
BuildAction = "Compile"
/>
+ <File
+ RelPath = "XmlTextTests.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
<File
RelPath = "XmlTextWriterTests.cs"
SubType = "Code"
AssertNull(attr.Attributes);
}
+ public void TestAttributeInnerAndOuterXml ()
+ {
+ attr = doc.CreateAttribute ("foo", "bar", "http://abc.def");
+ attr.Value = "baz";
+ AssertEquals ("baz", attr.InnerXml);
+ AssertEquals ("foo:bar=\"baz\"", attr.OuterXml);
+ }
+
public void TestAttributeWithNoValue ()
{
XmlAttribute attribute = doc.CreateAttribute ("name");
Assert ("Copies, not pointers", !Object.ReferenceEquals (original,cloned));
}
+ public void TestXmlCDataSectionInnerAndOuterXml ()
+ {
+ section = document.CreateCDataSection ("foo");
+ AssertEquals (String.Empty, section.InnerXml);
+ AssertEquals ("<![CDATA[foo]]>", section.OuterXml);
+ }
+
public void TestXmlCDataSectionName ()
{
AssertEquals (section.NodeType + " Name property broken",
XmlNode deep;
XmlNode shallow;
- public XmlCommentTests ()
- : base ("Ximian.Mono.Tests.XmlCommentTests testsuite")
- {
- }
+ public XmlCommentTests () : base ("Ximian.Mono.Tests.XmlCommentTests testsuite") {}
- public XmlCommentTests (string name)
- : base (name)
- {
- }
+ public XmlCommentTests (string name) : base (name) {}
protected override void SetUp ()
{
document = new XmlDocument ();
- document.LoadXml ("<root><foo></foo></root>");
- comment = document.CreateComment ("Comment");
}
- internal void TestXmlNodeBaseProperties (XmlNode original, XmlNode cloned)
+ public void TestXmlCommentCloneNode ()
{
-// assertequals (original.nodetype + " was incorrectly cloned.",
-// original.baseuri, cloned.baseuri);
+ document.LoadXml ("<root><foo></foo></root>");
+ comment = document.CreateComment ("Comment");
+ original = comment;
- AssertNull (cloned.ParentNode);
+ shallow = comment.CloneNode (false); // shallow
+ TestXmlNodeBaseProperties (original, shallow);
+
+ deep = comment.CloneNode (true); // deep
+ TestXmlNodeBaseProperties (original, deep);
AssertEquals ("Value incorrectly cloned",
- original.Value, cloned.Value);
+ original.Value, deep.Value);
- Assert ("Copies, not pointers", !Object.ReferenceEquals (original,cloned));
+ AssertEquals ("deep cloning differs from shallow cloning",
+ deep.OuterXml, shallow.OuterXml);
}
-
- public void TestXmlCommentName ()
+
+ public void TestXmlCommentInnerAndOuterXml ()
{
- AssertEquals (comment.NodeType + " Name property broken",
- comment.Name, "#comment");
+ comment = document.CreateComment ("foo");
+ AssertEquals (String.Empty, comment.InnerXml);
+ AssertEquals ("<!--foo-->", comment.OuterXml);
+ }
+
+ public void TestXmlCommentIsReadOnly ()
+ {
+ document.LoadXml ("<root><foo></foo></root>");
+ comment = document.CreateComment ("Comment");
+ AssertEquals ("XmlComment IsReadOnly property broken",
+ comment.IsReadOnly, false);
}
public void TestXmlCommentLocalName ()
{
+ document.LoadXml ("<root><foo></foo></root>");
+ comment = document.CreateComment ("Comment");
AssertEquals (comment.NodeType + " LocalName property broken",
comment.LocalName, "#comment");
}
+ public void TestXmlCommentName ()
+ {
+ document.LoadXml ("<root><foo></foo></root>");
+ comment = document.CreateComment ("Comment");
+ AssertEquals (comment.NodeType + " Name property broken",
+ comment.Name, "#comment");
+ }
+
public void TestXmlCommentNodeType ()
{
+ document.LoadXml ("<root><foo></foo></root>");
+ comment = document.CreateComment ("Comment");
AssertEquals ("XmlComment NodeType property broken",
comment.NodeType.ToString (), "Comment");
}
- public void TestXmlCommentIsReadOnly ()
+ internal void TestXmlNodeBaseProperties (XmlNode original, XmlNode cloned)
{
- AssertEquals ("XmlComment IsReadOnly property broken",
- comment.IsReadOnly, false);
- }
+ document.LoadXml ("<root><foo></foo></root>");
+ comment = document.CreateComment ("Comment");
- public void TestXmlCommentCloneNode ()
- {
- original = comment;
+ // assertequals (original.nodetype + " was incorrectly cloned.",
+ // original.baseuri, cloned.baseuri);
- shallow = comment.CloneNode (false); // shallow
- TestXmlNodeBaseProperties (original, shallow);
-
- deep = comment.CloneNode (true); // deep
- TestXmlNodeBaseProperties (original, deep);
+ AssertNull (cloned.ParentNode);
AssertEquals ("Value incorrectly cloned",
- original.Value, deep.Value);
+ original.Value, cloned.Value);
- AssertEquals ("deep cloning differs from shallow cloning",
- deep.OuterXml, shallow.OuterXml);
+ Assert ("Copies, not pointers", !Object.ReferenceEquals (original,cloned));
}
+
}
}
XmlDocument document;
XmlDeclaration declaration;
- public XmlDeclarationTests ()
- : base ("Ximian.Mono.Tests.XmlDeclarationTests testsuite")
- {
- }
+ public XmlDeclarationTests () : base ("Ximian.Mono.Tests.XmlDeclarationTests testsuite") {}
- public XmlDeclarationTests (string name)
- : base (name)
- {
- }
+ public XmlDeclarationTests (string name) : base (name) {}
protected override void SetUp ()
{
declaration = document.CreateXmlDeclaration ("1.0", null, null);
}
+ public void TestInnerAndOuterXml ()
+ {
+ declaration = document.CreateXmlDeclaration ("1.0", null, null);
+ AssertEquals (String.Empty, declaration.InnerXml);
+ AssertEquals ("<?xml version=\"1.0\"?>", declaration.OuterXml);
+
+ declaration = document.CreateXmlDeclaration ("1.0", "doesn't check", null);
+ AssertEquals (String.Empty, declaration.InnerXml);
+ AssertEquals ("<?xml version=\"1.0\" encoding=\"doesn't check\"?>", declaration.OuterXml);
+
+ declaration = document.CreateXmlDeclaration ("1.0", null, "yes");
+ AssertEquals (String.Empty, declaration.InnerXml);
+ AssertEquals ("<?xml version=\"1.0\" standalone=\"yes\"?>", declaration.OuterXml);
+
+ declaration = document.CreateXmlDeclaration ("1.0", "foo", "no");
+ AssertEquals (String.Empty, declaration.InnerXml);
+ AssertEquals ("<?xml version=\"1.0\" encoding=\"foo\" standalone=\"no\"?>", declaration.OuterXml);
+ }
+
internal void TestXmlNodeBaseProperties (XmlNode original, XmlNode cloned)
{
// assertequals (original.nodetype + " was incorrectly cloned.",
AssertEquals ("Incorrect output for empty document.", "", document.OuterXml);
}
+ public void TestInnerAndOuterXml ()
+ {
+ AssertEquals (String.Empty, document.InnerXml);
+ AssertEquals (document.InnerXml, document.OuterXml);
+
+ XmlDeclaration declaration = document.CreateXmlDeclaration ("1.0", null, null);
+ document.AppendChild (declaration);
+ AssertEquals ("<?xml version=\"1.0\"?>", document.InnerXml);
+ AssertEquals (document.InnerXml, document.OuterXml);
+
+ XmlElement element = document.CreateElement ("foo");
+ document.AppendChild (element);
+ AssertEquals ("<?xml version=\"1.0\"?><foo />", document.InnerXml);
+ AssertEquals (document.InnerXml, document.OuterXml);
+
+ XmlComment comment = document.CreateComment ("bar");
+ document.DocumentElement.AppendChild (comment);
+ AssertEquals ("<?xml version=\"1.0\"?><foo><!--bar--></foo>", document.InnerXml);
+ AssertEquals (document.InnerXml, document.OuterXml);
+
+ XmlText text = document.CreateTextNode ("baz");
+ document.DocumentElement.AppendChild (text);
+ AssertEquals ("<?xml version=\"1.0\"?><foo><!--bar-->baz</foo>", document.InnerXml);
+ AssertEquals (document.InnerXml, document.OuterXml);
+
+ element = document.CreateElement ("quux");
+ element.SetAttribute ("quuux", "squonk");
+ document.DocumentElement.AppendChild (element);
+ AssertEquals ("<?xml version=\"1.0\"?><foo><!--bar-->baz<quux quuux=\"squonk\" /></foo>", document.InnerXml);
+ AssertEquals (document.InnerXml, document.OuterXml);
+ }
+
public void TestLoadXmlCDATA ()
{
document.LoadXml ("<foo><![CDATA[bar]]></foo>");
//AssertEquals (attributesCount, element.Attributes.Count);
}
+ public void TestCloneNode ()
+ {
+ XmlElement element = document.CreateElement ("foo");
+ XmlElement child = document.CreateElement ("bar");
+ XmlElement grandson = document.CreateElement ("baz");
+
+ element.SetAttribute ("attr1", "val1");
+ element.SetAttribute ("attr2", "val2");
+ element.AppendChild (child);
+ child.SetAttribute ("attr3", "val3");
+ child.AppendChild (grandson);
+
+ document.AppendChild (element);
+ XmlNode deep = element.CloneNode (true);
+ // AssertEquals ("These should be the same", deep.OuterXml, element.OuterXml);
+ AssertNull ("This is not null", deep.ParentNode);
+ Assert ("Copies, not pointers", !Object.ReferenceEquals (element,deep));
+
+ XmlNode shallow = element.CloneNode (false);
+ AssertNull ("This is not null", shallow.ParentNode);
+ Assert ("Copies, not pointers", !Object.ReferenceEquals (element,shallow));
+ AssertEquals ("Shallow clones shalt have no children!", false, shallow.HasChildNodes);
+ }
+
public void TestCreateElement1 ()
{
XmlElement element = document.CreateElement ("name");
AssertElement (element, "prefix", "localName", "namespaceURI", 0);
}
- public void TestSetGetAttribute ()
+ public void TestInnerAndOuterXml ()
{
- XmlElement element = document.CreateElement ("foo");
- element.SetAttribute ("attr1", "val1");
- element.SetAttribute ("attr2", "val2");
- AssertEquals ("val1", element.GetAttribute ("attr1"));
- AssertEquals ("val2", element.GetAttribute ("attr2"));
+ XmlElement element;
+ XmlText text;
+ XmlComment comment;
+
+ element = document.CreateElement ("foo");
+ AssertEquals (String.Empty, element.InnerXml);
+ AssertEquals ("<foo />", element.OuterXml);
+
+ text = document.CreateTextNode ("bar");
+ element.AppendChild (text);
+ AssertEquals ("bar", element.InnerXml);
+ AssertEquals ("<foo>bar</foo>", element.OuterXml);
+
+ element.SetAttribute ("baz", "quux");
+ AssertEquals ("bar", element.InnerXml);
+ AssertEquals ("<foo baz=\"quux\">bar</foo>", element.OuterXml);
+
+ comment = document.CreateComment ("squonk");
+ element.AppendChild (comment);
+ AssertEquals ("bar<!--squonk-->", element.InnerXml);
+ AssertEquals ("<foo baz=\"quux\">bar<!--squonk--></foo>", element.OuterXml);
+
+
}
- public void TestCloneNode ()
+ public void TestSetGetAttribute ()
{
XmlElement element = document.CreateElement ("foo");
- XmlElement child = document.CreateElement ("bar");
- XmlElement grandson = document.CreateElement ("baz");
-
element.SetAttribute ("attr1", "val1");
element.SetAttribute ("attr2", "val2");
- element.AppendChild (child);
- child.SetAttribute ("attr3", "val3");
- child.AppendChild (grandson);
-
- document.AppendChild (element);
- XmlNode deep = element.CloneNode (true);
- // AssertEquals ("These should be the same", deep.OuterXml, element.OuterXml);
- AssertNull ("This is not null", deep.ParentNode);
- Assert ("Copies, not pointers", !Object.ReferenceEquals (element,deep));
-
- XmlNode shallow = element.CloneNode (false);
- AssertNull ("This is not null", shallow.ParentNode);
- Assert ("Copies, not pointers", !Object.ReferenceEquals (element,shallow));
- AssertEquals ("Shallow clones shalt have no children!", false, shallow.HasChildNodes);
+ AssertEquals ("val1", element.GetAttribute ("attr1"));
+ AssertEquals ("val2", element.GetAttribute ("attr2"));
}
}
}
public class XmlSignificantWhitespaceTests : TestCase
{
XmlDocument document;
+ XmlDocument doc2;
XmlSignificantWhitespace whitespace;
XmlSignificantWhitespace broken;
- XmlNode original;
- XmlNode deep;
- XmlNode shallow;
+ XmlNode original;
+ XmlNode deep;
+ XmlNode shallow;
- public XmlSignificantWhitespaceTests ()
- : base ("Ximian.Mono.Tests.XmlWhitespaceTests testsuite")
- {
- }
-
- public XmlSignificantWhitespaceTests (string name)
- : base (name)
- {
- }
+ public XmlSignificantWhitespaceTests () : base ("Ximian.Mono.Tests.XmlWhitespaceTests testsuite") {}
+ public XmlSignificantWhitespaceTests (string name) : base (name) {}
protected override void SetUp ()
{
XmlElement element = document.CreateElement ("foo");
whitespace = document.CreateSignificantWhitespace ("\r\n");
element.AppendChild (whitespace);
+
+ doc2 = new XmlDocument ();
}
+ public void TestInnerAndOuterXml ()
+ {
+ whitespace = doc2.CreateSignificantWhitespace ("\r\n\t ");
+ AssertEquals (String.Empty, whitespace.InnerXml);
+ AssertEquals ("\r\n\t ", whitespace.OuterXml);
+ }
+
internal void TestXmlNodeBaseProperties (XmlNode original, XmlNode cloned)
{
// assertequals (original.nodetype + " was incorrectly cloned.",
AssertEquals ("<foo></foo><bar foo='bar'></bar><baz bar=''></baz>", StringWriterText);
}
+ public void TestWriteRaw ()
+ {
+ xtw.WriteRaw("&<>\"'");
+ AssertEquals ("&<>\"'", StringWriterText);
+
+ xtw.WriteRaw(null);
+ AssertEquals ("&<>\"'", StringWriterText);
+
+ xtw.WriteRaw("");
+ AssertEquals ("&<>\"'", StringWriterText);
+ }
+
+ public void TestWriteRawInvalidInAttribute ()
+ {
+ xtw.WriteStartElement ("foo");
+ xtw.WriteStartAttribute ("bar", null);
+ xtw.WriteRaw ("&<>\"'");
+ xtw.WriteEndAttribute ();
+ xtw.WriteEndElement ();
+ AssertEquals ("<foo bar='&<>\"'' />", StringWriterText);
+ }
+
public void TestWriteState ()
{
AssertEquals (WriteState.Start, xtw.WriteState);
AssertEquals (XmlSpace.Preserve, xtw.XmlSpace);
AssertEquals ("<foo><bar xml:space='preserve'><baz xml:space='preserve'", StringWriterText);
-
xtw.WriteStartElement ("quux");
xtw.WriteStartAttribute ("xml", "space", null);
AssertEquals (XmlSpace.Preserve, xtw.XmlSpace);
xtw.WriteWhitespace ("x");
} catch (ArgumentException) { }
}
+
+ public void TestXmlSpaceRaw ()
+ {
+ xtw.WriteStartElement ("foo");
+ xtw.WriteStartAttribute ("xml", "space", null);
+ AssertEquals (XmlSpace.None, xtw.XmlSpace);
+ AssertEquals ("<foo xml:space='", StringWriterText);
+
+ xtw.WriteString ("default");
+ AssertEquals (XmlSpace.None, xtw.XmlSpace);
+ AssertEquals ("<foo xml:space='", StringWriterText);
+
+ xtw.WriteEndAttribute ();
+ AssertEquals (XmlSpace.Default, xtw.XmlSpace);
+ AssertEquals ("<foo xml:space='default'", StringWriterText);
+ }
}
}
public class XmlWhitespaceTests : TestCase
{
XmlDocument document;
+ XmlDocument doc2;
XmlWhitespace whitespace;
XmlWhitespace broken;
- XmlNode original;
- XmlNode deep;
- XmlNode shallow;
+ XmlNode original;
+ XmlNode deep;
+ XmlNode shallow;
- public XmlWhitespaceTests ()
- : base ("Ximian.Mono.Tests.XmlWhitespaceTests testsuite")
- {
- }
-
- public XmlWhitespaceTests (string name)
- : base (name)
- {
- }
+ public XmlWhitespaceTests () : base ("Ximian.Mono.Tests.XmlWhitespaceTests testsuite") {}
+ public XmlWhitespaceTests (string name) : base (name) {}
protected override void SetUp ()
{
XmlElement element = document.CreateElement ("foo");
whitespace = document.CreateWhitespace ("\r\n");
element.AppendChild (whitespace);
+
+ doc2 = new XmlDocument ();
}
+ public void TestInnerAndOuterXml ()
+ {
+ whitespace = doc2.CreateWhitespace ("\r\n\t ");
+ AssertEquals (String.Empty, whitespace.InnerXml);
+ AssertEquals ("\r\n\t ", whitespace.OuterXml);
+ }
+
internal void TestXmlNodeBaseProperties (XmlNode original, XmlNode cloned)
{
// assertequals (original.nodetype + " was incorrectly cloned.",