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