XmlTextWriterTests.cs: Fixed tests where not run when an expected exception had been...
[mono.git] / mcs / class / System.XML / Test / System.Xml / XmlCDataSectionTests.cs
1 //
2 // System.Xml.XmlCDataSectionTests.cs
3 //
4 // Authors:
5 //      Duncan Mak  (duncan@ximian.com)
6 //      Martin Willemoes Hansen (mwh@sysrq.dk)
7 //
8 // (C) Ximian, Inc.
9 // (C) 2003 Martin Willemoes Hansen
10 //
11
12 using System;
13 using System.Xml;
14
15 using NUnit.Framework;
16
17 namespace MonoTests.System.Xml
18 {
19         [TestFixture]
20         public class XmlCDataSectionTests : Assertion
21         {
22                 XmlDocument document;
23                 XmlCDataSection section;
24                 XmlNode original;
25                 XmlNode deep;
26                 XmlNode shallow;
27
28                 [SetUp]
29                 public void GetReady ()
30                 {
31                         document = new XmlDocument ();
32                         document.LoadXml ("<root><foo></foo></root>");
33                         section = document.CreateCDataSection ("CDataSection");
34                 }
35
36                 internal void XmlNodeBaseProperties (XmlNode original, XmlNode cloned)
37                 {
38                         // AssertEquals (original.nodetype + " was incorrectly cloned.",
39                         //               original.baseuri, cloned.baseuri);                     
40                         AssertNull (cloned.ParentNode);
41                         Assert ("Copies, not pointers", !Object.ReferenceEquals (original,cloned));
42                 }
43                
44                 [Test]
45                 public void XmlCDataSectionInnerAndOuterXml ()
46                 {
47                         section = document.CreateCDataSection ("foo");
48                         AssertEquals (String.Empty, section.InnerXml);
49                         AssertEquals ("<![CDATA[foo]]>", section.OuterXml);
50                 }
51
52                 [Test]
53                 public void XmlCDataSectionName ()
54                 {
55                         AssertEquals (section.NodeType + " Name property broken",
56                                       section.Name, "#cdata-section");
57                 }
58
59                 [Test]
60                 public void XmlCDataSectionLocalName ()
61                 {
62                         AssertEquals (section.NodeType + " LocalName property broken",
63                                       section.LocalName, "#cdata-section");
64                 }
65
66                 [Test]
67                 public void XmlCDataSectionNodeType ()
68                 {
69                         AssertEquals ("XmlCDataSection NodeType property broken",
70                                       section.NodeType.ToString (), "CDATA");
71                 }
72
73                 [Test]
74                 public void XmlCDataSectionIsReadOnly ()
75                 {
76                         AssertEquals ("XmlCDataSection IsReadOnly property broken",
77                                       section.IsReadOnly, false);
78                 }
79
80                 [Test]
81                 public void XmlCDataSectionCloneNode ()
82                 {
83                         original = section;
84
85                         shallow = section.CloneNode (false); // shallow
86                         XmlNodeBaseProperties (original, shallow);
87                         AssertEquals ("Value incorrectly cloned",
88                                       original.Value, shallow.Value);
89                         
90                         deep = section.CloneNode (true); // deep
91                         XmlNodeBaseProperties (original, deep);
92                         AssertEquals ("Value incorrectly cloned",
93                                        original.Value, deep.Value);
94
95                         AssertEquals ("deep cloning differs from shallow cloning",
96                                       deep.OuterXml, shallow.OuterXml);
97                 }
98         }
99 }