2 // Tests for System.Web.UI.WebControls.ImageMap.cs
5 // Hagit Yidov (hagity@mainsoft.com
7 // (C) 2005 Mainsoft Corporation (http://www.mainsoft.com)
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:
17 // The above copyright notice and this permission notice shall be
18 // included in all copies or substantial portions of the Software.
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.
29 using NUnit.Framework;
32 using System.Globalization;
35 using System.Web.UI.WebControls;
36 using MonoTests.stand_alone.WebHarness;
37 using MonoTests.SystemWeb.Framework;
38 using System.Threading;
40 namespace MonoTests.System.Web.UI.WebControls {
42 public class TreeNodeStyleTest {
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");
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");
62 Assert.AreEqual ("", tns.ImageUrl, "ImageUrl");
64 Assert.AreEqual (0.0, tns.NodeSpacing.Value, "NodeSpacing");
65 tns.VerticalPadding = 0;
66 Assert.AreEqual (0.0, tns.VerticalPadding.Value, "VerticalPadding");
70 public void TreeNodeStyle_Method_CopyFrom () {
71 TreeNodeStyle tns = new TreeNodeStyle ();
72 TreeNodeStyle copy = new TreeNodeStyle ();
73 tns.BorderStyle = BorderStyle.Double;
75 tns.ChildNodesPadding = 4;
77 tns.HorizontalPadding = 6;
78 tns.ImageUrl = "ImageUrl";
80 tns.VerticalPadding = 8;
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");
95 public void TreeNodeStyle_Method_MergeWith () {
96 TreeNodeStyle tns = new TreeNodeStyle ();
97 TreeNodeStyle copy = new TreeNodeStyle ();
98 tns.BorderStyle = BorderStyle.Double;
100 tns.ChildNodesPadding = 4;
102 tns.HorizontalPadding = 6;
103 tns.ImageUrl = "ImageUrl";
105 tns.VerticalPadding = 8;
107 copy.ImageUrl = "NewImageUrl";
108 copy.NodeSpacing = 10;
109 copy.VerticalPadding = 11;
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");
128 public void TreeNodeStyle_Method_Reset () {
129 TreeNodeStyle tns = new TreeNodeStyle ();
130 tns.BorderStyle = BorderStyle.Double;
132 tns.ChildNodesPadding = 4;
134 tns.HorizontalPadding = 6;
135 tns.ImageUrl = "ImageUrl";
137 tns.VerticalPadding = 8;
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");
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");
160 public void TreeNodeStyle_ViewState () {
162 TreeNodeStyle orig = new TreeNodeStyle ();
163 ((IStateManager) orig).TrackViewState ();
164 TreeNodeStyle copy = new TreeNodeStyle ();
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");
174 object state = ((IStateManager) orig).SaveViewState ();
175 ((IStateManager) copy).LoadViewState (state);
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");