Files
mono/mcs/class/System.XML/Test/System.Xml/NameTableTests.cs
T
2005-12-27 11:03:12 +00:00

99 lines
1.9 KiB
C#

//
// System.Xml.NameTableTests.cs
//
// Author: Duncan Mak ([email protected])
// Author: Martin Willemoes Hansen ([email protected])
//
// (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));
}
}
}