TableSectionStyleTest.cs 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. //
  2. // TableSectionStyleTest.cs
  3. // - Unit tests for System.Web.UI.WebControls.TableSectionStyle
  4. //
  5. // Author:
  6. // Sebastien Pouliot <[email protected]>
  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.IO;
  32. using System.Web;
  33. using System.Web.UI;
  34. using System.Web.UI.WebControls;
  35. using NUnit.Framework;
  36. namespace MonoTests.System.Web.UI.WebControls {
  37. public class TestTableSectionStyle : TableSectionStyle {
  38. public TestTableSectionStyle ()
  39. : base ()
  40. {
  41. }
  42. public bool Empty {
  43. get { return base.IsEmpty; }
  44. }
  45. public StateBag StateBag {
  46. get { return base.ViewState; }
  47. }
  48. }
  49. [TestFixture]
  50. public class TableSectionStyleTest {
  51. private void DefaultProperties (TestTableSectionStyle tss)
  52. {
  53. Assert.AreEqual (0, tss.StateBag.Count, "ViewState.Count");
  54. Assert.IsTrue (tss.Visible, "Visible");
  55. Assert.AreEqual (0, tss.StateBag.Count, "ViewState.Count-2");
  56. tss.Reset ();
  57. Assert.AreEqual (0, tss.StateBag.Count, "Reset");
  58. }
  59. private void NullProperties (TestTableSectionStyle tss)
  60. {
  61. Assert.IsTrue (tss.Empty, "Empty");
  62. tss.Visible = false;
  63. Assert.IsFalse (tss.Visible, "Visible");
  64. Assert.IsTrue (tss.Empty, "!Empty"); // strange !!!
  65. Assert.AreEqual (1, tss.StateBag.Count, "ViewState.Count-1");
  66. tss.Reset ();
  67. // strange results because TableSectionStyle doesn't override
  68. // Reset
  69. Assert.AreEqual (1, tss.StateBag.Count, "Reset");
  70. Assert.IsTrue (tss.Empty, "Empty/Reset");
  71. }
  72. [Test]
  73. public void Constructor_Default ()
  74. {
  75. TestTableSectionStyle tss = new TestTableSectionStyle ();
  76. DefaultProperties (tss);
  77. NullProperties (tss);
  78. }
  79. private TableSectionStyle GetTableSectionStyle ()
  80. {
  81. TableSectionStyle tss = new TableSectionStyle ();
  82. tss.Visible = false;
  83. return tss;
  84. }
  85. [Test]
  86. public void CopyFrom_Null ()
  87. {
  88. TableSectionStyle tss = GetTableSectionStyle ();
  89. tss.CopyFrom (null);
  90. Assert.IsFalse (tss.Visible, "Visible");
  91. }
  92. [Test]
  93. public void CopyFrom_Self ()
  94. {
  95. TableSectionStyle tss = GetTableSectionStyle ();
  96. tss.CopyFrom (tss);
  97. Assert.IsFalse (tss.Visible, "Visible");
  98. }
  99. [Test]
  100. public void CopyFrom_Empty ()
  101. {
  102. TestTableSectionStyle tss = new TestTableSectionStyle ();
  103. tss.CopyFrom (new TableSectionStyle ());
  104. DefaultProperties (tss);
  105. }
  106. [Test]
  107. public void CopyFrom_IsEmpty ()
  108. {
  109. TestTableSectionStyle c = new TestTableSectionStyle ();
  110. TableSectionStyle s = new TableSectionStyle ();
  111. s.BorderWidth = Unit.Empty;
  112. c.CopyFrom (s);
  113. Assert.IsTrue (c.Empty, "A1");
  114. s.Visible = true;
  115. c.CopyFrom (s);
  116. // BUG -- setting Visible doesn't change the "emptyness" of this class ;-)
  117. Assert.IsTrue (c.Empty, "A2");
  118. }
  119. [Test]
  120. public void CopyFrom ()
  121. {
  122. TableSectionStyle tss = GetTableSectionStyle ();
  123. tss.Visible = true;
  124. tss.CopyFrom (GetTableSectionStyle ());
  125. // BUG - CopyFrom isn't overriden !!!
  126. Assert.IsTrue (tss.Visible, "Visible");
  127. }
  128. [Test]
  129. public void MergeWith_Null ()
  130. {
  131. TableSectionStyle tss = GetTableSectionStyle ();
  132. tss.MergeWith (null);
  133. Assert.IsFalse (tss.Visible, "Visible");
  134. }
  135. [Test]
  136. public void MergeWith_Self ()
  137. {
  138. TableSectionStyle tss = GetTableSectionStyle ();
  139. tss.MergeWith (tss);
  140. Assert.IsFalse (tss.Visible, "Visible");
  141. }
  142. [Test]
  143. public void MergeWith_Empty ()
  144. {
  145. TestTableSectionStyle tss = new TestTableSectionStyle ();
  146. tss.MergeWith (new TableSectionStyle ());
  147. DefaultProperties (tss);
  148. }
  149. [Test]
  150. public void MergeWith ()
  151. {
  152. TableSectionStyle tss = new TableSectionStyle ();
  153. tss.Visible = true;
  154. tss.MergeWith (GetTableSectionStyle ());
  155. Assert.IsTrue (tss.Visible, "Visible");
  156. }
  157. }
  158. }
  159. #endif