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

NameTableTests.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: cd5780f7e8d0a3ac9d46fc5b9ac9180c8f876737 (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
//
// System.Xml.NameTableTests.cs
//
// Author: Duncan Mak (duncan@ximian.com)
// Author: 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 NameTableTests : Assertion
	{
		NameTable table;
		
		[SetUp]
		public void GetReady ()
		{
			table = new NameTable ();
		}

		//
		// Tests System.Xml.NameTable.Add (string)
		//		
		[Test]
		public void Add1 ()
		{
			string add = "add1";
			string testAdd = table.Add (add);
			AssertEquals (add, testAdd);
			AssertSame (add, testAdd);
		}

		//
		// Tests System.Xml.NameTable.Add (char[], int, int)
		//		
		[Test]
		public void Add2 ()
		{
			char[] test = new char [4] { 'a', 'd', 'd', '2' };
			int index = 0;
			int length = 3; // "add"			

			AssertEquals ("add", table.Add (test, index, length));
		}

		//
		// Tests System.Xml.NameTable.Get (string)
		//
		[Test]
		public void Get1 ()
		{
			string get1 = "get1";
			string testGet = table.Add (get1);
			AssertEquals ("#1", "get1", testGet);

			AssertEquals ("#2", testGet, table.Get (get1));
			AssertSame ("#3", get1, testGet );
		}

		//
		// Tests System.Xml.NameTable.Get (char[], int, int)
		//
		[Test]
		public void Get2 ()
		{						
			char[] test = new char [4] { 'g', 'e', 't', '2' };
			int index = 0; 
			int length = 3; // "get"
			
			string testGet = table.Add (test, index, length);
			AssertEquals ("#1", "get", testGet);

			AssertEquals ("#2", testGet, table.Get ("get"));
			AssertEquals ("#3", testGet, table.Get (test, index, length));
		}

		//
		// Tests System.Xml.NameTable.Get (char[], int, 0)
		//
		[Test]
		public void Get3 ()
		{
			char[] test = new char [4] { 't', 'e', 's', 't' };
			int index = 0;
			int length = 0;

			AssertEquals (String.Empty, table.Get (test, index, length));
		}
	}
}