Merge pull request #2250 from esdrubal/master
[mono.git] / mcs / class / System.Web / Test / System.Web.UI.WebControls / TreeNodeStyleTest.cs
1 //
2 // Tests for System.Web.UI.WebControls.ImageMap.cs
3 //
4 // Author:
5 //  Hagit Yidov (hagity@mainsoft.com
6 //
7 // (C) 2005 Mainsoft Corporation (http://www.mainsoft.com)
8 //
9 // Permission is hereby granted, free of charge, to any person obtaining
10 // a copy of this software and associated documentation files (the
11 // "Software"), to deal in the Software without restriction, including
12 // without limitation the rights to use, copy, modify, merge, publish,
13 // distribute, sublicense, and/or sell copies of the Software, and to
14 // permit persons to whom the Software is furnished to do so, subject to
15 // the following conditions:
16 // 
17 // The above copyright notice and this permission notice shall be
18 // included in all copies or substantial portions of the Software.
19 // 
20 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
24 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
25 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 //
28
29 using NUnit.Framework;
30 using System;
31 using System.IO;
32 using System.Globalization;
33 using System.Web;
34 using System.Web.UI;
35 using System.Web.UI.WebControls;
36 using MonoTests.stand_alone.WebHarness;
37 using MonoTests.SystemWeb.Framework;
38 using System.Threading;
39
40 namespace MonoTests.System.Web.UI.WebControls {
41         [TestFixture]
42         public class TreeNodeStyleTest {
43
44                 [Test]
45                 public void TreeNodeStyle_DefaultProperties () {
46                         TreeNodeStyle tns = new TreeNodeStyle ();
47                         Assert.AreEqual (0.0, tns.ChildNodesPadding.Value, "ChildNodesPadding");
48                         Assert.AreEqual (0.0, tns.HorizontalPadding.Value, "HorizontalPadding");
49                         Assert.AreEqual ("", tns.ImageUrl, "ImageUrl");
50                         Assert.AreEqual (0.0, tns.NodeSpacing.Value, "NodeSpacing");
51                         Assert.AreEqual (0.0, tns.VerticalPadding.Value, "VerticalPadding");
52                 }
53
54                 [Test]
55                 public void TreeNodeStyle_AssignToDefaultProperties () {
56                         TreeNodeStyle tns = new TreeNodeStyle ();
57                         tns.ChildNodesPadding = 0;
58                         Assert.AreEqual (0.0, tns.ChildNodesPadding.Value, "ChildNodesPadding");
59                         tns.HorizontalPadding = 0;
60                         Assert.AreEqual (0.0, tns.HorizontalPadding.Value, "HorizontalPadding");
61                         tns.ImageUrl = "";
62                         Assert.AreEqual ("", tns.ImageUrl, "ImageUrl");
63                         tns.NodeSpacing = 0;
64                         Assert.AreEqual (0.0, tns.NodeSpacing.Value, "NodeSpacing");
65                         tns.VerticalPadding = 0;
66                         Assert.AreEqual (0.0, tns.VerticalPadding.Value, "VerticalPadding");
67                 }
68
69                 [Test]
70                 public void TreeNodeStyle_Method_CopyFrom () {
71                         TreeNodeStyle tns = new TreeNodeStyle ();
72                         TreeNodeStyle copy = new TreeNodeStyle ();
73                         tns.BorderStyle = BorderStyle.Double;
74                         tns.BorderWidth = 3;
75                         tns.ChildNodesPadding = 4;
76                         tns.Height = 5;
77                         tns.HorizontalPadding = 6;
78                         tns.ImageUrl = "ImageUrl";
79                         tns.NodeSpacing = 7;
80                         tns.VerticalPadding = 8;
81                         tns.Width = 9;
82                         copy.CopyFrom (tns);
83                         Assert.AreEqual (tns.BorderStyle, copy.BorderStyle, "BorderStyle");
84                         Assert.AreEqual (tns.BorderWidth, copy.BorderWidth, "Borderidth");
85                         Assert.AreEqual (tns.ChildNodesPadding, copy.ChildNodesPadding, "ChildNodesPadding");
86                         Assert.AreEqual (tns.Height, copy.Height, "Height");
87                         Assert.AreEqual (tns.HorizontalPadding, copy.HorizontalPadding, "HorizontalPadding");
88                         Assert.AreEqual (tns.ImageUrl, copy.ImageUrl, "ImageUrl");
89                         Assert.AreEqual (tns.NodeSpacing, copy.NodeSpacing, "NodeSpacing");
90                         Assert.AreEqual (tns.VerticalPadding, copy.VerticalPadding, "VerticalPadding");
91                         Assert.AreEqual (tns.Width, copy.Width, "Width");
92                 }
93
94                 [Test]
95                 public void TreeNodeStyle_Method_MergeWith () {
96                         TreeNodeStyle tns = new TreeNodeStyle ();
97                         TreeNodeStyle copy = new TreeNodeStyle ();
98                         tns.BorderStyle = BorderStyle.Double;
99                         tns.BorderWidth = 3;
100                         tns.ChildNodesPadding = 4;
101                         tns.Height = 5;
102                         tns.HorizontalPadding = 6;
103                         tns.ImageUrl = "ImageUrl";
104                         tns.NodeSpacing = 7;
105                         tns.VerticalPadding = 8;
106                         tns.Width = 9;
107                         copy.ImageUrl = "NewImageUrl";
108                         copy.NodeSpacing = 10;
109                         copy.VerticalPadding = 11;
110                         copy.Width = 12;
111                         copy.MergeWith (tns);
112                         Assert.AreEqual (tns.BorderStyle, copy.BorderStyle, "BorderStyle");
113                         Assert.AreEqual (tns.BorderWidth, copy.BorderWidth, "Borderidth");
114                         Assert.AreEqual (tns.ChildNodesPadding, copy.ChildNodesPadding, "ChildNodesPadding");
115                         Assert.AreEqual (tns.Height, copy.Height, "Height");
116                         Assert.AreEqual (tns.HorizontalPadding, copy.HorizontalPadding, "HorizontalPadding");
117                         Assert.AreEqual ("NewImageUrl", copy.ImageUrl, "ImageUrl1");
118                         Assert.AreEqual (Unit.Pixel (10), copy.NodeSpacing, "NodeSpacing1");
119                         Assert.AreEqual (Unit.Pixel (11), copy.VerticalPadding, "VerticalPadding1");
120                         Assert.AreEqual (Unit.Pixel (12), copy.Width, "Width1");
121                         Assert.AreEqual ("NewImageUrl", copy.ImageUrl, "ImageUrl2");
122                         Assert.AreEqual (10.0, copy.NodeSpacing.Value, "NodeSpacing2");
123                         Assert.AreEqual (11.0, copy.VerticalPadding.Value, "VerticalPadding2");
124                         Assert.AreEqual (12.0, copy.Width.Value, "Width2");
125                 }
126
127                 [Test]
128                 public void TreeNodeStyle_Method_Reset () {
129                         TreeNodeStyle tns = new TreeNodeStyle ();
130                         tns.BorderStyle = BorderStyle.Double;
131                         tns.BorderWidth = 3;
132                         tns.ChildNodesPadding = 4;
133                         tns.Height = 5;
134                         tns.HorizontalPadding = 6;
135                         tns.ImageUrl = "ImageUrl";
136                         tns.NodeSpacing = 7;
137                         tns.VerticalPadding = 8;
138                         tns.Width = 9;
139                         Assert.AreEqual (BorderStyle.Double, tns.BorderStyle, "BorderStyle1");
140                         Assert.AreEqual (3.0, tns.BorderWidth.Value, "BorderWidth1");
141                         Assert.AreEqual (4.0, tns.ChildNodesPadding.Value, "ChildNodesPadding1");
142                         Assert.AreEqual (5.0, tns.Height.Value, "Height1");
143                         Assert.AreEqual (6.0, tns.HorizontalPadding.Value, "HorizontalPadding1");
144                         Assert.AreEqual ("ImageUrl", tns.ImageUrl, "ImageUrl1");
145                         Assert.AreEqual (7.0, tns.NodeSpacing.Value, "NodeSpacing1");
146                         Assert.AreEqual (8.0, tns.VerticalPadding.Value, "VerticalPadding1");
147                         Assert.AreEqual (9.0, tns.Width.Value, "Width1");
148                         tns.Reset ();
149                         Assert.AreEqual (0.0, tns.BorderWidth.Value, "BorderWidth2");
150                         Assert.AreEqual (0.0, tns.ChildNodesPadding.Value, "ChildNodesPadding2");
151                         Assert.AreEqual (0.0, tns.Height.Value, "Height2");
152                         Assert.AreEqual (0.0, tns.HorizontalPadding.Value, "HorizontalPadding2");
153                         Assert.AreEqual ("", tns.ImageUrl, "ImageUrl2");
154                         Assert.AreEqual (0.0, tns.NodeSpacing.Value, "NodeSpacing2");
155                         Assert.AreEqual (0.0, tns.VerticalPadding.Value, "VerticalPadding2");
156                         Assert.AreEqual (0.0, tns.Width.Value, "Width2");
157                 }
158
159                 [Test]
160                 public void TreeNodeStyle_ViewState () {
161
162                         TreeNodeStyle orig = new TreeNodeStyle ();
163                         ((IStateManager) orig).TrackViewState ();
164                         TreeNodeStyle copy = new TreeNodeStyle ();
165
166                         Assert.AreEqual (true, orig.IsEmpty, "TreeNodeStyle_ViewState");
167                         orig.ChildNodesPadding = 4;
168                         orig.HorizontalPadding = 6;
169                         orig.ImageUrl = "ImageUrl";
170                         orig.NodeSpacing = 7;
171                         orig.VerticalPadding = 8;
172                         Assert.AreEqual (false, orig.IsEmpty, "TreeNodeStyle_ViewState");
173
174                         object state = ((IStateManager) orig).SaveViewState ();
175                         ((IStateManager) copy).LoadViewState (state);
176
177                         Assert.AreEqual (false, copy.IsEmpty, "TreeNodeStyle_ViewState");
178                         Assert.AreEqual (4.0, copy.ChildNodesPadding.Value, "TreeNodeStyle_ViewState");
179                         Assert.AreEqual (6.0, copy.HorizontalPadding.Value, "TreeNodeStyle_ViewState");
180                         Assert.AreEqual ("ImageUrl", copy.ImageUrl, "TreeNodeStyle_ViewState");
181                         Assert.AreEqual (7.0, copy.NodeSpacing.Value, "TreeNodeStyle_ViewState");
182                         Assert.AreEqual (8.0, copy.VerticalPadding.Value, "TreeNodeStyle_ViewState");
183                 }
184
185         }
186 }
187
188