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: acbc93f6b92cd72d28d6e3b37fd88e846be6ada1 (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
//
// 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
	{
		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)
		{
			// Assert.AreEqual (// 		 original.baseuri, cloned.baseuri, original.nodetype + " was incorrectly cloned.");			
			Assert.IsNull (cloned.ParentNode);
                        Assert.IsTrue (!Object.ReferenceEquals (original, cloned), "Copies, not pointers");
		}
	       
		[Test]
		public void XmlCDataSectionInnerAndOuterXml ()
		{
			section = document.CreateCDataSection ("foo");
			Assert.AreEqual (String.Empty, section.InnerXml);
			Assert.AreEqual ("<![CDATA[foo]]>", section.OuterXml);
		}

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

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

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

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

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

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

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