NameTableTests.cs 1.7 KB

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