2
0

ConnectionInterfaceCollectionTest.cs 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. //
  2. // Tests for System.Web.UI.WebControls.WebParts.ConnectionInterfacesCollectoinTest.cs
  3. //
  4. // Author:
  5. // Chris Toshok ([email protected])
  6. //
  7. //
  8. // Copyright (C) 2005 Novell, Inc (http://www.novell.com)
  9. //
  10. // Permission is hereby granted, free of charge, to any person obtaining
  11. // a copy of this software and associated documentation files (the
  12. // "Software"), to deal in the Software without restriction, including
  13. // without limitation the rights to use, copy, modify, merge, publish,
  14. // distribute, sublicense, and/or sell copies of the Software, and to
  15. // permit persons to whom the Software is furnished to do so, subject to
  16. // the following conditions:
  17. //
  18. // The above copyright notice and this permission notice shall be
  19. // included in all copies or substantial portions of the Software.
  20. //
  21. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  22. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  23. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  24. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  25. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  26. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  27. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  28. //
  29. #if NET_2_0
  30. using System;
  31. using System.Collections;
  32. using NUnit.Framework;
  33. using CIC = System.Web.UI.WebControls.WebParts.ConnectionInterfaceCollection;
  34. namespace MonoTests.System.Web.UI.WebControls.WebParts
  35. {
  36. [TestFixture]
  37. public class ConnectionInterfaceCollectionTest
  38. {
  39. [Test]
  40. public void Empty ()
  41. {
  42. CIC col = CIC.Empty;
  43. Assert.AreEqual (0, col.Count, "A1");
  44. }
  45. [Test]
  46. public void Ctor0 ()
  47. {
  48. CIC col = new CIC ();
  49. Assert.AreEqual (0, col.Count, "A1");
  50. }
  51. [Test]
  52. public void Ctor1()
  53. {
  54. ArrayList a = new ArrayList ();
  55. a.Add (typeof (string));
  56. a.Add (typeof (object));
  57. CIC col = new CIC (a);
  58. Assert.AreEqual (2, col.Count, "A1");
  59. Assert.IsTrue (col.Contains (typeof (string)), "A2");
  60. Assert.IsTrue (col.Contains (typeof (object)), "A3");
  61. Assert.AreEqual (0, col.IndexOf (typeof (string)), "A4");
  62. Assert.AreEqual (1, col.IndexOf (typeof (object)), "A5");
  63. }
  64. [Test]
  65. public void Ctor1_dup ()
  66. {
  67. ArrayList a = new ArrayList ();
  68. a.Add (typeof (string));
  69. a.Add (typeof (string));
  70. CIC col = new CIC (a);
  71. Assert.AreEqual (2, col.Count, "A1");
  72. Assert.IsTrue (col.Contains (typeof (string)), "A2");
  73. Assert.AreEqual (0, col.IndexOf (typeof (string)), "A3");
  74. }
  75. [Test]
  76. public void Ctor2 ()
  77. {
  78. ArrayList a = new ArrayList ();
  79. a.Add (typeof (string));
  80. a.Add (typeof (object));
  81. CIC col1 = new CIC (a);
  82. a = new ArrayList ();
  83. a.Add (typeof (int));
  84. a.Add (typeof (short));
  85. CIC col2 = new CIC (col1, a);
  86. Assert.AreEqual (4, col2.Count, "A1");
  87. Assert.IsTrue (col2.Contains (typeof (string)), "A2");
  88. Assert.IsTrue (col2.Contains (typeof (object)), "A3");
  89. Assert.IsTrue (col2.Contains (typeof (int)), "A4");
  90. Assert.IsTrue (col2.Contains (typeof (short)), "A5");
  91. Assert.AreEqual (0, col2.IndexOf (typeof (string)), "A6");
  92. Assert.AreEqual (1, col2.IndexOf (typeof (object)), "A7");
  93. Assert.AreEqual (2, col2.IndexOf (typeof (int)), "A8");
  94. Assert.AreEqual (3, col2.IndexOf (typeof (short)), "A9");
  95. }
  96. [Test]
  97. public void Ctor2_dup ()
  98. {
  99. ArrayList a = new ArrayList ();
  100. a.Add (typeof (string));
  101. a.Add (typeof (object));
  102. CIC col1 = new CIC (a);
  103. a = new ArrayList ();
  104. a.Add (typeof (string));
  105. a.Add (typeof (object));
  106. CIC col2 = new CIC (col1, a);
  107. Assert.AreEqual (4, col2.Count, "A1");
  108. Assert.IsTrue (col2.Contains (typeof (string)), "A2");
  109. Assert.IsTrue (col2.Contains (typeof (object)), "A3");
  110. Assert.AreEqual (0, col2.IndexOf (typeof (string)), "A4");
  111. Assert.AreEqual (1, col2.IndexOf (typeof (object)), "A5");
  112. }
  113. }
  114. }
  115. #endif