1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
|
//
// System.Xml.XmlWhitespaceTests.cs
//
// Author:
// Duncan Mak (duncan@ximian.com)
//
// (C) Ximian, Inc.
//
using System;
using System.Xml;
using NUnit.Framework;
namespace MonoTests.System.Xml
{
public class XmlSignificantWhitespaceTests : TestCase
{
XmlDocument document;
XmlDocument doc2;
XmlSignificantWhitespace whitespace;
XmlSignificantWhitespace broken;
XmlNode original;
XmlNode deep;
XmlNode shallow;
public XmlSignificantWhitespaceTests () : base ("MonoTests.System.Xml.XmlWhitespaceTests testsuite") {}
public XmlSignificantWhitespaceTests (string name) : base (name) {}
protected override void SetUp ()
{
document = new XmlDocument ();
document.LoadXml ("<root><foo></foo></root>");
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.",
// original.baseuri, cloned.baseuri);
AssertNull (cloned.ParentNode);
AssertEquals ("Value incorrectly cloned",
cloned.Value, original.Value);
Assert ("Copies, not pointers", !Object.ReferenceEquals (original,cloned));
}
public void TestXmlSignificantWhitespaceBadConstructor ()
{
try {
broken = document.CreateSignificantWhitespace ("black");
} catch (ArgumentException) {
return;
} catch (Exception) {
Fail ("Incorrect Exception thrown.");
}
}
public void TestXmlSignificantWhitespaceConstructor ()
{
AssertEquals ("whitespace char didn't get copied right",
"\r\n", whitespace.Data);
}
public void TestXmlSignificantWhitespaceName ()
{
AssertEquals (whitespace.NodeType + " Name property broken",
whitespace.Name, "#significant-whitespace");
}
public void TestXmlSignificantWhitespaceLocalName ()
{
AssertEquals (whitespace.NodeType + " LocalName property broken",
whitespace.LocalName, "#significant-whitespace");
}
public void TestXmlSignificantWhitespaceNodeType ()
{
AssertEquals ("XmlSignificantWhitespace NodeType property broken",
whitespace.NodeType.ToString (), "SignificantWhitespace");
}
public void TestXmlSignificantWhitespaceIsReadOnly ()
{
AssertEquals ("XmlSignificantWhitespace IsReadOnly property broken",
whitespace.IsReadOnly, false);
}
public void TestXmlSignificantWhitespaceCloneNode ()
{
original = whitespace;
shallow = whitespace.CloneNode (false); // shallow
TestXmlNodeBaseProperties (original, shallow);
deep = whitespace.CloneNode (true); // deep
TestXmlNodeBaseProperties (original, deep);
AssertEquals ("deep cloning differs from shallow cloning",
deep.OuterXml, shallow.OuterXml);
}
}
}
|