2 // System.Xml.XmlTextWriterTests
5 // Kral Ferch <kral_ferch@hotmail.com>
14 using NUnit.Framework;
16 namespace Ximian.Mono.Tests
18 public class XmlTextWriterTests : TestCase
20 public XmlTextWriterTests () : base ("Ximian.Mono.Tests.XmlTextWriterTests testsuite") {}
21 public XmlTextWriterTests (string name) : base (name) {}
26 protected override void SetUp ()
28 sw = new StringWriter ();
29 xtw = new XmlTextWriter (sw);
32 public void TestCData ()
34 xtw.WriteCData ("foo");
35 AssertEquals ("WriteCData had incorrect output.", sw.GetStringBuilder().ToString(), "<![CDATA[foo]]>");
38 public void TestComment ()
40 xtw.WriteComment ("foo");
41 AssertEquals ("WriteComment had incorrect output.", "<!--foo-->", sw.GetStringBuilder().ToString());
44 public void TestElementEmpty ()
46 xtw.WriteStartElement ("foo");
47 xtw.WriteEndElement ();
48 AssertEquals ("Incorrect output.", "<foo />", sw.GetStringBuilder().ToString());
51 public void TestElementWriteElementString ()
53 xtw.WriteElementString ("foo", "bar");
54 AssertEquals ("WriteElementString has incorrect output.", "<foo>bar</foo>", sw.GetStringBuilder().ToString());
57 public void TestProcessingInstructionInvalid ()
60 xtw.WriteProcessingInstruction("fo?>o", "bar");
61 Fail("Should have thrown an ArgumentException.");
62 } catch (ArgumentException) { }
65 xtw.WriteProcessingInstruction("foo", "ba?>r");
66 Fail("Should have thrown an ArgumentException.");
67 } catch (ArgumentException) { }
70 xtw.WriteProcessingInstruction("", "bar");
71 Fail("Should have thrown an ArgumentException.");
72 } catch (ArgumentException) { }
75 xtw.WriteProcessingInstruction(null, "bar");
76 Fail("Should have thrown an ArgumentException.");
77 } catch (ArgumentException) { }