NameTableTests.cs 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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 ("#1", "get1", testGet);
  55. AssertEquals ("#2", testGet, table.Get (get1));
  56. AssertSame ("#3", get1, testGet );
  57. }
  58. //
  59. // Tests System.Xml.NameTable.Get (char[], int, int)
  60. //
  61. [Test]
  62. public void Get2 ()
  63. {
  64. char[] test = new char [4] { 'g', 'e', 't', '2' };
  65. int index = 0;
  66. int length = 3; // "get"
  67. string testGet = table.Add (test, index, length);
  68. AssertEquals ("#1", "get", testGet);
  69. AssertEquals ("#2", testGet, table.Get ("get"));
  70. AssertEquals ("#3", testGet, table.Get (test, index, length));
  71. }
  72. //
  73. // Tests System.Xml.NameTable.Get (char[], int, 0)
  74. //
  75. [Test]
  76. public void Get3 ()
  77. {
  78. char[] test = new char [4] { 't', 'e', 's', 't' };
  79. int index = 0;
  80. int length = 0;
  81. AssertEquals (String.Empty, table.Get (test, index, length));
  82. }
  83. }
  84. }