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

XmlCommentTests.cs « Test « System.XML « class « mcs - github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 77ff9abe1b7ac9ec9b2abd22eae752b7bd02eb55 (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
100
101
102
103
104
105
106
107
//
// System.Xml.XmlCommentTests.cs
//
// Author:
//	Duncan Mak  (duncan@ximian.com)
//
// (C) Ximian, Inc.
//

using System;
using System.Xml;

using NUnit.Framework;

namespace MonoTests.System.Xml
{
	public class XmlCommentTests : TestCase
	{
		XmlDocument document;
		XmlComment comment;
		XmlNode original;
		XmlNode deep;
		XmlNode shallow;

		public XmlCommentTests () : base ("MonoTests.System.Xml.XmlCommentTests testsuite") {}

		public XmlCommentTests (string name) : base (name) {}

		protected override void SetUp ()
		{
			document = new XmlDocument ();
		}

		public void TestXmlCommentCloneNode ()
		{
			document.LoadXml ("<root><foo></foo></root>");
			comment = document.CreateComment ("Comment");
			original = comment;

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

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

		public void TestXmlCommentInnerAndOuterXml ()
		{
			comment = document.CreateComment ("foo");
			AssertEquals (String.Empty, comment.InnerXml);
			AssertEquals ("<!--foo-->", comment.OuterXml);
		}

		public void TestXmlCommentIsReadOnly ()
		{
			document.LoadXml ("<root><foo></foo></root>");
			comment = document.CreateComment ("Comment");
			AssertEquals ("XmlComment IsReadOnly property broken",
				comment.IsReadOnly, false);
		}

		public void TestXmlCommentLocalName ()
		{
			document.LoadXml ("<root><foo></foo></root>");
			comment = document.CreateComment ("Comment");
			AssertEquals (comment.NodeType + " LocalName property broken",
				      comment.LocalName, "#comment");
		}

		public void TestXmlCommentName ()
		{
			document.LoadXml ("<root><foo></foo></root>");
			comment = document.CreateComment ("Comment");
			AssertEquals (comment.NodeType + " Name property broken",
				comment.Name, "#comment");
		}

		public void TestXmlCommentNodeType ()
		{
			document.LoadXml ("<root><foo></foo></root>");
			comment = document.CreateComment ("Comment");
			AssertEquals ("XmlComment NodeType property broken",
				      comment.NodeType.ToString (), "Comment");
		}

		internal void TestXmlNodeBaseProperties (XmlNode original, XmlNode cloned)
		{
			document.LoadXml ("<root><foo></foo></root>");
			comment = document.CreateComment ("Comment");

			//			assertequals (original.nodetype + " was incorrectly cloned.",
			//				      original.baseuri, cloned.baseuri);			

			AssertNull (cloned.ParentNode);
			AssertEquals ("Value incorrectly cloned",
				original.Value, cloned.Value);

			Assert ("Copies, not pointers", !Object.ReferenceEquals (original,cloned));
		}
       
	}
}