NameTableTests.cs 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. //
  2. // System.Xml.NameTableTests.cs
  3. //
  4. // Author: Duncan Mak ([email protected])
  5. // Author: Martin Willemoes Hansen ([email protected])
  6. //
  7. // (C) Ximian, Inc.
  8. // (C) 2003 Martin Willemoes Hansen
  9. //
  10. using System;
  11. using System.Xml;
  12. using NUnit.Framework;
  13. namespace MonoTests.System.Xml
  14. {
  15. [TestFixture]
  16. public class NameTableTests : Assertion
  17. {
  18. NameTable table;
  19. [SetUp]
  20. public void GetReady ()
  21. {
  22. table = new NameTable ();
  23. }
  24. //
  25. // Tests System.Xml.NameTable.Add (string)
  26. //
  27. [Test]
  28. public void Add1 ()
  29. {
  30. string add = "add1";
  31. string testAdd = table.Add (add);
  32. AssertEquals (add, testAdd);
  33. AssertSame (add, testAdd);
  34. }
  35. //
  36. // Tests System.Xml.NameTable.Add (char[], int, int)
  37. //
  38. [Test]
  39. public void Add2 ()
  40. {
  41. char[] test = new char [4] { 'a', 'd', 'd', '2' };
  42. int index = 0;
  43. int length = 3; // "add"
  44. AssertEquals ("add", table.Add (test, index, length));
  45. }
  46. //
  47. // Tests System.Xml.NameTable.Get (string)
  48. //
  49. [Test]
  50. public void Get1 ()
  51. {
  52. string get1 = "get1";
  53. string testGet = table.Add (get1);
  54. AssertEquals (table.Get (get1), testGet);
  55. AssertSame (get1, testGet );
  56. }
  57. //
  58. // Tests System.Xml.NameTable.Get (char[], int, int)
  59. //
  60. [Test]
  61. public void Get2 ()
  62. {
  63. char[] test = new char [4] { 'g', 'e', 't', '2' };
  64. int index = 0;
  65. int length = 3; // "get"
  66. string testGet = table.Add (test, index, length);
  67. AssertEquals (table.Get (test, index, length), testGet);
  68. }
  69. //
  70. // Tests System.Xml.NameTable.Get (char[], int, 0)
  71. //
  72. [Test]
  73. public void Get3 ()
  74. {
  75. char[] test = new char [4] { 't', 'e', 's', 't' };
  76. int index = 0;
  77. int length = 0;
  78. AssertEquals (table.Get (test, index, length), String.Empty);
  79. }
  80. }
  81. }