2 // TableSectionStyleTest.cs
3 // - Unit tests for System.Web.UI.WebControls.TableSectionStyle
6 // Sebastien Pouliot <sebastien@ximian.com>
8 // Copyright (C) 2005 Novell, Inc (http://www.novell.com)
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:
18 // The above copyright notice and this permission notice shall be
19 // included in all copies or substantial portions of the Software.
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.
35 using System.Web.UI.WebControls;
37 using NUnit.Framework;
39 namespace MonoTests.System.Web.UI.WebControls {
41 public class TestTableSectionStyle : TableSectionStyle {
43 public TestTableSectionStyle ()
49 get { return base.IsEmpty; }
52 public StateBag StateBag {
53 get { return base.ViewState; }
58 public class TableSectionStyleTest {
60 private void DefaultProperties (TestTableSectionStyle tss)
62 Assert.AreEqual (0, tss.StateBag.Count, "ViewState.Count");
64 Assert.IsTrue (tss.Visible, "Visible");
66 Assert.AreEqual (0, tss.StateBag.Count, "ViewState.Count-2");
68 Assert.AreEqual (0, tss.StateBag.Count, "Reset");
71 private void NullProperties (TestTableSectionStyle tss)
73 Assert.IsTrue (tss.Empty, "Empty");
76 Assert.IsFalse (tss.Visible, "Visible");
78 Assert.IsTrue (tss.Empty, "!Empty"); // strange !!!
80 Assert.AreEqual (1, tss.StateBag.Count, "ViewState.Count-1");
83 // strange results because TableSectionStyle doesn't override
85 Assert.AreEqual (1, tss.StateBag.Count, "Reset");
86 Assert.IsTrue (tss.Empty, "Empty/Reset");
90 public void Constructor_Default ()
92 TestTableSectionStyle tss = new TestTableSectionStyle ();
93 DefaultProperties (tss);
97 private TableSectionStyle GetTableSectionStyle ()
99 TableSectionStyle tss = new TableSectionStyle ();
106 public void CopyFrom_Null ()
108 TableSectionStyle tss = GetTableSectionStyle ();
110 Assert.IsFalse (tss.Visible, "Visible");
114 public void CopyFrom_Self ()
116 TableSectionStyle tss = GetTableSectionStyle ();
118 Assert.IsFalse (tss.Visible, "Visible");
122 public void CopyFrom_Empty ()
124 TestTableSectionStyle tss = new TestTableSectionStyle ();
125 tss.CopyFrom (new TableSectionStyle ());
126 DefaultProperties (tss);
130 public void CopyFrom_IsEmpty ()
132 TestTableSectionStyle c = new TestTableSectionStyle ();
133 TableSectionStyle s = new TableSectionStyle ();
135 s.BorderWidth = Unit.Empty;
137 Assert.IsTrue (c.Empty, "A1");
141 // BUG -- setting Visible doesn't change the "emptyness" of this class ;-)
142 Assert.IsTrue (c.Empty, "A2");
146 public void CopyFrom ()
148 TableSectionStyle tss = GetTableSectionStyle ();
151 tss.CopyFrom (GetTableSectionStyle ());
152 // BUG - CopyFrom isn't overriden !!!
153 Assert.IsTrue (tss.Visible, "Visible");
157 public void MergeWith_Null ()
159 TableSectionStyle tss = GetTableSectionStyle ();
160 tss.MergeWith (null);
161 Assert.IsFalse (tss.Visible, "Visible");
165 public void MergeWith_Self ()
167 TableSectionStyle tss = GetTableSectionStyle ();
169 Assert.IsFalse (tss.Visible, "Visible");
173 public void MergeWith_Empty ()
175 TestTableSectionStyle tss = new TestTableSectionStyle ();
176 tss.MergeWith (new TableSectionStyle ());
177 DefaultProperties (tss);
181 public void MergeWith ()
183 TableSectionStyle tss = new TableSectionStyle ();
186 tss.MergeWith (GetTableSectionStyle ());
188 Assert.IsTrue (tss.Visible, "Visible");