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

XmlAttributeTests.cs « Test « System.XML « class « mcs - github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: dc9961bcd3d6cc711925ec33d282a2de88297230 (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
// XmlAttributeTests.cs : Tests for the XmlAttribute class
//
// Author: Mike Kestner <mkestner@speakeasy.net>
//
// <c> 2002 Mike Kestner

using System;
using System.Xml;

using NUnit.Framework;

namespace MonoTests.System.Xml
{
	public class XmlAttributeTests : TestCase
	{
		public XmlAttributeTests() : base("MonoTests.System.Xml.XmlAttributeTests testsuite") { }
		public XmlAttributeTests(string name) : base(name) { }

		XmlDocument doc;
		XmlAttribute attr;

		protected override void SetUp()
		{
			doc = new XmlDocument();
			attr = doc.CreateAttribute("attr1");
			attr.Value = "val1";
		}

		public void TestAttributes()
		{
			AssertNull(attr.Attributes);
		}

		public void TestAttributeInnerAndOuterXml ()
		{
			attr = doc.CreateAttribute ("foo", "bar", "http://abc.def");
			attr.Value = "baz";
			AssertEquals ("baz", attr.InnerXml);
			AssertEquals ("foo:bar=\"baz\"", attr.OuterXml);
		}

		public void TestAttributeWithNoValue ()
		{
			XmlAttribute attribute = doc.CreateAttribute ("name");
			AssertEquals (String.Empty, attribute.Value);
			Assert (!attribute.HasChildNodes);
			AssertNull (attribute.FirstChild);
			AssertNull (attribute.LastChild);
			AssertEquals (0, attribute.ChildNodes.Count);
		}

		public void TestAttributeWithValue ()
		{
			XmlAttribute attribute = doc.CreateAttribute ("name");
			attribute.Value = "value";
			AssertEquals ("value", attribute.Value);
			Assert (attribute.HasChildNodes);
			AssertNotNull (attribute.FirstChild);
			AssertNotNull (attribute.LastChild);
			AssertEquals (1, attribute.ChildNodes.Count);
			AssertEquals (XmlNodeType.Text, attribute.ChildNodes [0].NodeType);
			AssertEquals ("value", attribute.ChildNodes [0].Value);
		}

		public void TestHasChildNodes()
		{
			Assert(attr.HasChildNodes);
		}

		public void TestName()
		{
			AssertEquals("attr1", attr.Name);
		}

		public void TestNodeType()
		{
			AssertEquals(XmlNodeType.Attribute, attr.NodeType);
		}

		public void TestOwnerDocument()
		{
			AssertSame(doc, attr.OwnerDocument);
		}

		public void TestParentNode()
		{
			AssertNull("Attr parents not allowed", attr.ParentNode);
		}

		public void TestValue()
		{
			AssertEquals("val1", attr.Value);
		}
	}
}