implementing XmlElement.SetAttributeNode(localName, namespaceURI) and
[mono.git] / mcs / class / System.XML / Test / XmlCommentTests.cs
1 //
2 // System.Xml.XmlCommentTests.cs
3 //
4 // Author:
5 //      Duncan Mak  (duncan@ximian.com)
6 //
7 // (C) Ximian, Inc.
8 //
9
10 using System;
11 using System.Xml;
12
13 using NUnit.Framework;
14
15 namespace MonoTests.System.Xml
16 {
17         public class XmlCommentTests : TestCase
18         {
19                 XmlDocument document;
20                 XmlComment comment;
21                 XmlNode original;
22                 XmlNode deep;
23                 XmlNode shallow;
24
25                 public XmlCommentTests () : base ("MonoTests.System.Xml.XmlCommentTests testsuite") {}
26
27                 public XmlCommentTests (string name) : base (name) {}
28
29                 protected override void SetUp ()
30                 {
31                         document = new XmlDocument ();
32                 }
33
34                 public void TestXmlCommentCloneNode ()
35                 {
36                         document.LoadXml ("<root><foo></foo></root>");
37                         comment = document.CreateComment ("Comment");
38                         original = comment;
39
40                         shallow = comment.CloneNode (false); // shallow
41                         TestXmlNodeBaseProperties (original, shallow);
42                         
43                         deep = comment.CloneNode (true); // deep
44                         TestXmlNodeBaseProperties (original, deep);
45                         AssertEquals ("Value incorrectly cloned",
46                                 original.Value, deep.Value);
47
48                         AssertEquals ("deep cloning differs from shallow cloning",
49                                 deep.OuterXml, shallow.OuterXml);
50                 }
51
52                 public void TestXmlCommentInnerAndOuterXml ()
53                 {
54                         comment = document.CreateComment ("foo");
55                         AssertEquals (String.Empty, comment.InnerXml);
56                         AssertEquals ("<!--foo-->", comment.OuterXml);
57                 }
58
59                 public void TestXmlCommentIsReadOnly ()
60                 {
61                         document.LoadXml ("<root><foo></foo></root>");
62                         comment = document.CreateComment ("Comment");
63                         AssertEquals ("XmlComment IsReadOnly property broken",
64                                 comment.IsReadOnly, false);
65                 }
66
67                 public void TestXmlCommentLocalName ()
68                 {
69                         document.LoadXml ("<root><foo></foo></root>");
70                         comment = document.CreateComment ("Comment");
71                         AssertEquals (comment.NodeType + " LocalName property broken",
72                                       comment.LocalName, "#comment");
73                 }
74
75                 public void TestXmlCommentName ()
76                 {
77                         document.LoadXml ("<root><foo></foo></root>");
78                         comment = document.CreateComment ("Comment");
79                         AssertEquals (comment.NodeType + " Name property broken",
80                                 comment.Name, "#comment");
81                 }
82
83                 public void TestXmlCommentNodeType ()
84                 {
85                         document.LoadXml ("<root><foo></foo></root>");
86                         comment = document.CreateComment ("Comment");
87                         AssertEquals ("XmlComment NodeType property broken",
88                                       comment.NodeType.ToString (), "Comment");
89                 }
90
91                 internal void TestXmlNodeBaseProperties (XmlNode original, XmlNode cloned)
92                 {
93                         document.LoadXml ("<root><foo></foo></root>");
94                         comment = document.CreateComment ("Comment");
95
96                         //                      assertequals (original.nodetype + " was incorrectly cloned.",
97                         //                                    original.baseuri, cloned.baseuri);                        
98
99                         AssertNull (cloned.ParentNode);
100                         AssertEquals ("Value incorrectly cloned",
101                                 original.Value, cloned.Value);
102
103                         Assert ("Copies, not pointers", !Object.ReferenceEquals (original,cloned));
104                 }
105        
106         }
107 }