implementing XmlElement.SetAttributeNode(localName, namespaceURI) and
[mono.git] / mcs / class / System.XML / Test / NameTableTests.cs
1 //
2 // System.Xml.NameTableTests.cs
3 //
4 // Author: Duncan Mak (duncan@ximian.com)
5 //
6 // (C) Ximian, Inc.
7 //
8
9 using System;
10 using System.Xml;
11
12 using NUnit.Framework;
13
14 namespace MonoTests.System.Xml
15 {
16         public class NameTableTests : TestCase
17         {
18                 NameTable table;
19                 
20                 public NameTableTests (string name)
21                         : base (name)
22                 {
23                 }
24
25                 protected override void SetUp ()
26                 {
27                         table = new NameTable ();
28                 }
29
30                 //
31                 // Tests System.Xml.NameTable.Add (string)
32                 //              
33                 public void TestAdd1 ()
34                 {
35                         string add = "add1";
36                         string testAdd = table.Add (add);
37                         AssertEquals (add, testAdd);
38                         AssertSame (add, testAdd);
39                 }
40
41                 //
42                 // Tests System.Xml.NameTable.Add (char[], int, int)
43                 //              
44                 public void TestAdd2 ()
45                 {
46                         char[] test = new char [4] { 'a', 'd', 'd', '2' };
47                         int index = 0;
48                         int length = 3; // "add"                        
49
50                         AssertEquals ("add", table.Add (test, index, length));
51                 }
52
53                 //
54                 // Tests System.Xml.NameTable.Get (string)
55                 //
56                 public void TestGet1 ()
57                 {
58                         string get1 = "get1";
59                         string testGet = table.Add (get1);                      
60
61                         AssertEquals (table.Get (get1), testGet);
62                         AssertSame (get1, testGet );
63                 }
64
65                 //
66                 // Tests System.Xml.NameTable.Get (char[], int, int)
67                 //
68                 public void TestGet2 ()
69                 {                                               
70                         char[] test = new char [4] { 'g', 'e', 't', '2' };
71                         int index = 0; 
72                         int length = 3; // "get"
73                         
74                         string testGet = table.Add (test, index, length);                       
75
76                         AssertEquals (table.Get (test, index, length), testGet);
77                 }
78
79                 //
80                 // Tests System.Xml.NameTable.Get (char[], int, 0)
81                 //
82                 public void TestGet3 ()
83                 {
84                         char[] test = new char [4] { 't', 'e', 's', 't' };
85                         int index = 0;
86                         int length = 0;
87
88                         AssertEquals (table.Get (test, index, length), String.Empty);
89                 }
90         }
91 }