Welcome to mirror list, hosted at ThFree Co, Russian Federation.

XmlCDataSectionTests.cs « System.Xml « Test « System.XML « class « mcs - github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: a1ca07b9148b1cb946962666e010b4fa18022e0b (plain)
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
//
// System.Xml.XmlCDataSectionTests.cs
//
// Authors:
//	Duncan Mak  (duncan@ximian.com)
//      Martin Willemoes Hansen (mwh@sysrq.dk)
//
// (C) Ximian, Inc.
// (C) 2003 Martin Willemoes Hansen
//

using System;
using System.Xml;

using NUnit.Framework;

namespace MonoTests.System.Xml
{
	[TestFixture]
	public class XmlCDataSectionTests : Assertion
	{
		XmlDocument document;
		XmlCDataSection section;
		XmlNode original;
		XmlNode deep;
		XmlNode shallow;

		[SetUp]
		public void GetReady ()
		{
			document = new XmlDocument ();
			document.LoadXml ("<root><foo></foo></root>");
			section = document.CreateCDataSection ("CDataSection");
		}

		internal void XmlNodeBaseProperties (XmlNode original, XmlNode cloned)
		{
			// AssertEquals (original.nodetype + " was incorrectly cloned.",
			// 		 original.baseuri, cloned.baseuri);			
			AssertNull (cloned.ParentNode);
                        Assert ("Copies, not pointers", !Object.ReferenceEquals (original,cloned));
		}
	       
		[Test]
		public void XmlCDataSectionInnerAndOuterXml ()
		{
			section = document.CreateCDataSection ("foo");
			AssertEquals (String.Empty, section.InnerXml);
			AssertEquals ("<![CDATA[foo]]>", section.OuterXml);
		}

		[Test]
		public void XmlCDataSectionName ()
		{
			AssertEquals (section.NodeType + " Name property broken",
				      section.Name, "#cdata-section");
		}

		[Test]
		public void XmlCDataSectionLocalName ()
		{
			AssertEquals (section.NodeType + " LocalName property broken",
				      section.LocalName, "#cdata-section");
		}

		[Test]
		public void XmlCDataSectionNodeType ()
		{
			AssertEquals ("XmlCDataSection NodeType property broken",
				      section.NodeType.ToString (), "CDATA");
		}

		[Test]
		public void XmlCDataSectionIsReadOnly ()
		{
			AssertEquals ("XmlCDataSection IsReadOnly property broken",
				      section.IsReadOnly, false);
		}

		[Test]
		public void XmlCDataSectionCloneNode ()
		{
			original = section;

			shallow = section.CloneNode (false); // shallow
			XmlNodeBaseProperties (original, shallow);
			AssertEquals ("Value incorrectly cloned",
				      original.Value, shallow.Value);
			
			deep = section.CloneNode (true); // deep
			XmlNodeBaseProperties (original, deep);
			AssertEquals ("Value incorrectly cloned",
				       original.Value, deep.Value);

                        AssertEquals ("deep cloning differs from shallow cloning",
				      deep.OuterXml, shallow.OuterXml);
		}
	}
}