1 //
2 // System.Web.UI.WebControls.TreeViewTest.cs
3 //	- Unit tests for System.Web.UI.Webcontrols.TreeView
4 //
5 //
6 // Authors:
7 //	Chris Toshok (toshok@ximian.com)
8 //  Hagit Yidov (hagity@mainsoft.com
9 //
10 // (C) 2005 Novell, Inc (http://www.novell.com)
11 //
12 // Permission is hereby granted, free of charge, to any person obtaining
13 // a copy of this software and associated documentation files (the
14 // "Software"), to deal in the Software without restriction, including
15 // without limitation the rights to use, copy, modify, merge, publish,
16 // distribute, sublicense, and/or sell copies of the Software, and to
17 // permit persons to whom the Software is furnished to do so, subject to
18 // the following conditions:
19 //
20 // The above copyright notice and this permission notice shall be
21 // included in all copies or substantial portions of the Software.
22 //
23 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
27 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
28 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
29 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30 //
31 //
32 
33 using System;
34 using System.IO;
35 using System.Globalization;
36 using System.Web;
37 using System.Web.UI;
38 using System.Web.UI.WebControls;
39 using MonoTests.stand_alone.WebHarness;
40 using MonoTests.SystemWeb.Framework;
41 using System.Xml;
42 using System.Collections.Specialized;
43 using System.Threading;
44 
45 using NUnit.Framework;
46 
47 namespace MonoTests.System.Web.UI.WebControls {
48 	public class TreeViewPoker : TreeView {
49 	}
50 	class PokerTreeView : TreeView {
51 		// View state Stuff
PokerTreeView()52 		public PokerTreeView () {
53 			TrackViewState ();
54 		}
SaveState()55 		public object SaveState () {
56 			return SaveViewState ();
57 		}
LoadState(object o)58 		public void LoadState (object o) {
59 			LoadViewState (o);
60 		}
61 		public StateBag StateBag {
62 			get { return base.ViewState; }
63 		}
64 
65 		public HtmlTextWriterTag TagKeyFromBase {
66 			get { return base.TagKey; }
67 		}
68 
69 		// Protected Methods
DataBindFromBase(bool raiseOnDataBinding)70 		public void DataBindFromBase (bool raiseOnDataBinding) {
71 			base.DataBind (raiseOnDataBinding);
72 		}
AddAttributesToRenderBase(HtmlTextWriter writer)73 		public void AddAttributesToRenderBase (HtmlTextWriter writer) {
74 			base.AddAttributesToRender (writer);
75 		}
CreateControlCollectionBase()76 		public ControlCollection CreateControlCollectionBase () {
77 			return (base.CreateControlCollection ());
78 		}
CreateNodeBase()79 		public TreeNode CreateNodeBase () {
80 			TreeNode tn = base.CreateNode ();
81 			tn.Text = "New Tree Node";
82 			return (tn);
83 		}
RaiseCallbackEventBase(string eventArgument)84 		public void RaiseCallbackEventBase (string eventArgument) {
85 			base.RaiseCallbackEvent (eventArgument);
86 		}
GetCallbackResultBase()87 		public string GetCallbackResultBase () {
88 			return (base.GetCallbackResult ());
89 		}
SetNodeDataBoundBase(TreeNode node, bool dataBound)90 		public void SetNodeDataBoundBase (TreeNode node, bool dataBound) {
91 			base.SetNodeDataBound (node, dataBound);
92 		}
SetNodeDataItemBase(TreeNode node, object dataItem)93 		public void SetNodeDataItemBase (TreeNode node, object dataItem) {
94 			base.SetNodeDataItem (node, dataItem);
95 		}
SetNodeDataPathBase(TreeNode node, string dataPath)96 		public void SetNodeDataPathBase (TreeNode node, string dataPath) {
97 			base.SetNodeDataPath (node, dataPath);
98 		}
PerformDataBindingBase()99 		public void PerformDataBindingBase () {
100 			base.PerformDataBinding ();
101 		}
102 
103 		// Events
OnInitBase(EventArgs e)104 		public void OnInitBase (EventArgs e) { base.OnInit (e); }
OnPreRenderBase(EventArgs e)105 		public void OnPreRenderBase (EventArgs e) { base.OnPreRender (e); }
OnSelectedNodeChangedBase(EventArgs e)106 		public void OnSelectedNodeChangedBase (EventArgs e) { base.OnSelectedNodeChanged (e); }
OnTreeNodeCheckChangedBase(TreeNodeEventArgs e)107 		public void OnTreeNodeCheckChangedBase (TreeNodeEventArgs e) { base.OnTreeNodeCheckChanged (e); }
OnTreeNodeCollapsedBase(TreeNodeEventArgs e)108 		public void OnTreeNodeCollapsedBase (TreeNodeEventArgs e) { base.OnTreeNodeCollapsed (e); }
OnTreeNodeDataBoundBase(TreeNodeEventArgs e)109 		public void OnTreeNodeDataBoundBase (TreeNodeEventArgs e) { base.OnTreeNodeDataBound (e); }
OnTreeNodeExpandedBase(TreeNodeEventArgs e)110 		public void OnTreeNodeExpandedBase (TreeNodeEventArgs e) { base.OnTreeNodeExpanded (e); }
OnTreeNodePopulateBase(TreeNodeEventArgs e)111 		public void OnTreeNodePopulateBase (TreeNodeEventArgs e) { base.OnTreeNodePopulate (e); }
OnBubbleEventBase(Object o, EventArgs e)112 		public void OnBubbleEventBase (Object o, EventArgs e) { base.OnBubbleEvent (o, e); }
113 	}
114 
115 	[TestFixture]
116 	public class TreeViewTest {
117 
118 		[TestFixtureSetUp]
SetUp()119 		public void SetUp ()
120 		{
121 			WebTest.CopyResource (GetType (), "NoEventValidation.aspx", "NoEventValidation.aspx");
122 		}
123 
124 		[Test]
Defaults()125 		public void Defaults () {
126 			TreeViewPoker p = new TreeViewPoker ();
127 
128 			Assert.AreEqual ("Collapse {0}", p.CollapseImageToolTip, "A1");
129 			Assert.IsTrue (p.AutoGenerateDataBindings, "A2");
130 			Assert.AreEqual ("", p.CollapseImageUrl, "A3");
131 			Assert.IsNotNull (p.DataBindings, "A4");
132 			Assert.AreEqual (0, p.DataBindings.Count, "A4.1");
133 			Assert.IsTrue (p.EnableClientScript, "A5");
134 			Assert.AreEqual (-1, p.ExpandDepth, "A6");
135 			Assert.AreEqual ("Expand {0}", p.ExpandImageToolTip, "A7");
136 			Assert.AreEqual ("", p.ExpandImageUrl, "A8");
137 			Assert.IsNotNull (p.HoverNodeStyle, "A9");
138 			Assert.AreEqual (TreeViewImageSet.Custom, p.ImageSet, "A10");
139 			Assert.IsNotNull (p.LeafNodeStyle, "A11");
140 			Assert.IsNotNull (p.LevelStyles, "A12");
141 			Assert.AreEqual (0, p.LevelStyles.Count, "A12.1");
142 			Assert.AreEqual ("", p.LineImagesFolder, "A13");
143 			Assert.AreEqual (-1, p.MaxDataBindDepth, "A14");
144 			Assert.AreEqual (20, p.NodeIndent, "A15");
145 			Assert.IsNotNull (p.Nodes, "A16");
146 			Assert.AreEqual (0, p.Nodes.Count, "A16.1");
147 			Assert.IsNotNull (p.NodeStyle, "A17");
148 			Assert.IsFalse (p.NodeWrap, "A18");
149 			Assert.AreEqual ("", p.NoExpandImageUrl, "A19");
150 			Assert.IsNotNull (p.ParentNodeStyle, "A20");
151 			Assert.AreEqual ('/', p.PathSeparator, "A21");
152 			Assert.IsTrue (p.PopulateNodesFromClient, "A22");
153 			Assert.IsNotNull (p.RootNodeStyle, "A23");
154 			Assert.IsNotNull (p.SelectedNodeStyle, "A24");
155 			Assert.AreEqual (TreeNodeTypes.None, p.ShowCheckBoxes, "A25");
156 			Assert.IsTrue (p.ShowExpandCollapse, "A26");
157 			Assert.AreEqual ("Skip Navigation Links.", p.SkipLinkText, "A27");
158 			Assert.IsNull (p.SelectedNode, "A28");
159 			Assert.AreEqual ("", p.SelectedValue, "A29");
160 			Assert.AreEqual ("", p.Target, "A30");
161 			Assert.IsTrue (p.Visible, "A31");
162 		}
163 
164 		[Test]
TreeView_DefaultProperties()165 		public void TreeView_DefaultProperties () {
166 			PokerTreeView tv = new PokerTreeView ();
167 			Assert.AreEqual (0, tv.StateBag.Count, "ViewState.Count");
168 			// Public Properties
169 			Assert.AreEqual (true, tv.AutoGenerateDataBindings, "AutoGenerateDataBindings");
170 			Assert.AreEqual (0, tv.CheckedNodes.Count, "CheckedNodes");
171 			Assert.AreEqual ("Collapse {0}", tv.CollapseImageToolTip, "CollapseImageToolTip");
172 			Assert.AreEqual (string.Empty, tv.CollapseImageUrl, "CollapseImageUrl");
173 			Assert.AreEqual (0, tv.DataBindings.Count, "DataBindings");
174 			Assert.AreEqual (true, tv.EnableClientScript, "EnableClientScript");
175 			Assert.AreEqual (-1, tv.ExpandDepth, "ExpandDepth");
176 			Assert.AreEqual ("Expand {0}", tv.ExpandImageToolTip, "ExpandImageToolTip");
177 			Assert.AreEqual (string.Empty, tv.ExpandImageUrl, "ExpandImageUrl");
178 			Assert.AreEqual (TreeViewImageSet.Custom, tv.ImageSet, "ImageSet");
179 			Assert.AreEqual (0, tv.LevelStyles.Count, "LevelStyles");
180 			Assert.AreEqual (string.Empty, tv.LineImagesFolder, "LineImagesFolder");
181 			Assert.AreEqual (-1, tv.MaxDataBindDepth, "MaxDataBindDepth");
182 			Assert.AreEqual (20, tv.NodeIndent, "NodeIndent");
183 			Assert.AreEqual (0, tv.Nodes.Count, "Nodes");
184 			Assert.AreEqual (false, tv.NodeWrap, "NodeWrap");
185 			Assert.AreEqual (string.Empty, tv.NoExpandImageUrl, "NoExpandImageUrl");
186 			Assert.AreEqual (true, tv.PopulateNodesFromClient, "PopulateNodesFromClient");
187 			Assert.AreEqual (null, tv.SelectedNode, "SelectedNode");
188 			Assert.AreEqual (string.Empty, tv.SelectedValue, "SelectedValue");
189 			Assert.AreEqual (TreeNodeTypes.None, tv.ShowCheckBoxes, "ShowCheckBoxes");
190 			Assert.AreEqual (true, tv.ShowExpandCollapse, "ShowExpandCollapse");
191 			Assert.AreEqual (false, tv.ShowLines, "ShowLines");
192 			Assert.AreEqual ("Skip Navigation Links.", tv.SkipLinkText, "SkipLinkText");
193 			Assert.AreEqual (string.Empty, tv.Target, "Target");
194 			Assert.AreEqual (true, tv.Visible, "Visible");
195 			// Protected Properties
196 			Assert.AreEqual (HtmlTextWriterTag.Div, tv.TagKeyFromBase, "TagKey");
197 		}
198 
199 		[Test]
Treeview_AssignToDefaultProperties()200 		public void Treeview_AssignToDefaultProperties () {
201 			PokerTreeView tv = new PokerTreeView ();
202 			Assert.AreEqual (0, tv.StateBag.Count, "ViewState.Count");
203 
204 			tv.AutoGenerateDataBindings = true;
205 			Assert.AreEqual (true, tv.AutoGenerateDataBindings, "AutoGenerateDataBindings");
206 			Assert.AreEqual (1, tv.StateBag.Count, "ViewState.Count-1");
207 
208 			//tv.CheckedNodes.Add (new TreeNode ());
209 			//Assert.AreEqual (1, tv.CheckedNodes.Count, "CheckedNodes");
210 			//Assert.AreEqual (1, tv.StateBag.Count, "ViewState.Count-2");
211 
212 			tv.CollapseImageToolTip = "Collapse {0}";
213 			Assert.AreEqual ("Collapse {0}", tv.CollapseImageToolTip, "CollapseImageToolTip");
214 			Assert.AreEqual (2, tv.StateBag.Count, "ViewState.Count-3");
215 
216 			tv.CollapseImageUrl = string.Empty;
217 			Assert.AreEqual (string.Empty, tv.CollapseImageUrl, "CollapseImageUrl");
218 			Assert.AreEqual (3, tv.StateBag.Count, "ViewState.Count-4");
219 
220 			tv.DataBindings.Add (new TreeNodeBinding ());
221 			Assert.AreEqual (1, tv.DataBindings.Count, "DataBindings");
222 			Assert.AreEqual (3, tv.StateBag.Count, "ViewState.Count-5");
223 
224 			tv.EnableClientScript = true;
225 			Assert.AreEqual (true, tv.EnableClientScript, "EnableClientScript");
226 			Assert.AreEqual (4, tv.StateBag.Count, "ViewState.Count-6");
227 
228 			tv.ExpandDepth = -1;
229 			Assert.AreEqual (-1, tv.ExpandDepth, "ExpandDepth");
230 			Assert.AreEqual (5, tv.StateBag.Count, "ViewState.Count-7");
231 
232 			tv.ExpandImageToolTip = "Expand {0}";
233 			Assert.AreEqual ("Expand {0}", tv.ExpandImageToolTip, "ExpandImageToolTip");
234 			Assert.AreEqual (6, tv.StateBag.Count, "ViewState.Count-8");
235 
236 			tv.ExpandImageUrl = string.Empty;
237 			Assert.AreEqual (string.Empty, tv.ExpandImageUrl, "ExpandImageUrl");
238 			Assert.AreEqual (7, tv.StateBag.Count, "ViewState.Count-9");
239 
240 			tv.ImageSet = TreeViewImageSet.Custom;
241 			Assert.AreEqual (TreeViewImageSet.Custom, tv.ImageSet, "ImageSet");
242 			Assert.AreEqual (8, tv.StateBag.Count, "ViewState.Count-10");
243 
244 			tv.LevelStyles.Add (new TreeNodeStyle ());
245 			Assert.AreEqual (1, tv.LevelStyles.Count, "LevelStyles");
246 			Assert.AreEqual (8, tv.StateBag.Count, "ViewState.Count-11");
247 
248 			tv.LineImagesFolder = string.Empty;
249 			Assert.AreEqual (string.Empty, tv.LineImagesFolder, "LineImagesFolder");
250 			Assert.AreEqual (9, tv.StateBag.Count, "ViewState.Count-12");
251 
252 			tv.MaxDataBindDepth = -1;
253 			Assert.AreEqual (-1, tv.MaxDataBindDepth, "MaxDataBindDepth");
254 			Assert.AreEqual (10, tv.StateBag.Count, "ViewState.Count-13");
255 
256 			tv.NodeIndent = 20;
257 			Assert.AreEqual (20, tv.NodeIndent, "NodeIndent");
258 			Assert.AreEqual (11, tv.StateBag.Count, "ViewState.Count-14");
259 
260 			tv.Nodes.Add (new TreeNode ());
261 			Assert.AreEqual (1, tv.Nodes.Count, "Nodes");
262 			Assert.AreEqual (11, tv.StateBag.Count, "ViewState.Count-15");
263 
264 			tv.NodeWrap = false;
265 			Assert.AreEqual (false, tv.NodeWrap, "NodeWrap");
266 			Assert.AreEqual (12, tv.StateBag.Count, "ViewState.Count-16");
267 
268 			tv.NoExpandImageUrl = string.Empty;
269 			Assert.AreEqual (string.Empty, tv.NoExpandImageUrl, "NoExpandImageUrl");
270 			Assert.AreEqual (13, tv.StateBag.Count, "ViewState.Count-17");
271 
272 			tv.PopulateNodesFromClient = true;
273 			Assert.AreEqual (true, tv.PopulateNodesFromClient, "PopulateNodesFromClient");
274 			Assert.AreEqual (14, tv.StateBag.Count, "ViewState.Count-18");
275 
276 			tv.ShowCheckBoxes = TreeNodeTypes.None;
277 			Assert.AreEqual (TreeNodeTypes.None, tv.ShowCheckBoxes, "ShowCheckBoxes");
278 			Assert.AreEqual (15, tv.StateBag.Count, "ViewState.Count-19");
279 
280 			tv.ShowExpandCollapse = true;
281 			Assert.AreEqual (true, tv.ShowExpandCollapse, "ShowExpandCollapse");
282 			Assert.AreEqual (16, tv.StateBag.Count, "ViewState.Count-20");
283 
284 			tv.ShowLines = false;
285 			Assert.AreEqual (false, tv.ShowLines, "ShowLines");
286 			Assert.AreEqual (17, tv.StateBag.Count, "ViewState.Count-21");
287 
288 			tv.SkipLinkText = "Skip Navigation Links.";
289 			Assert.AreEqual ("Skip Navigation Links.", tv.SkipLinkText, "SkipLinkText");
290 			Assert.AreEqual (18, tv.StateBag.Count, "ViewState.Count-22");
291 
292 			tv.Target = string.Empty;
293 			Assert.AreEqual (string.Empty, tv.Target, "Target");
294 			Assert.AreEqual (19, tv.StateBag.Count, "ViewState.Count-23");
295 
296 			tv.Visible = true;
297 			Assert.AreEqual (true, tv.Visible, "Visible");
298 			Assert.AreEqual (19, tv.StateBag.Count, "ViewState.Count-24");
299 		}
300 
301 		[Test]
Treeview_ViewState()302 		public void Treeview_ViewState () {
303 			PokerTreeView tv = new PokerTreeView ();
304 			tv.AutoGenerateDataBindings = true;
305 			Assert.AreEqual (true, tv.AutoGenerateDataBindings, "AutoGenerateDataBindings-beforecopy");
306 			TreeNode node = new TreeNode ();
307 			node.Checked = true;
308 			tv.Nodes.Add (node);
309 			tv.Nodes.Add (new TreeNode ());
310 			Assert.AreEqual (2, tv.Nodes.Count, "Nodes-beforecopy");
311 			Assert.AreEqual (1, tv.CheckedNodes.Count, "CheckedNodes-beforecopy");
312 			tv.CollapseImageToolTip = "Collapse {0}";
313 			Assert.AreEqual ("Collapse {0}", tv.CollapseImageToolTip, "CollapseImageToolTip-beforecopy");
314 			tv.CollapseImageUrl = string.Empty;
315 			Assert.AreEqual (string.Empty, tv.CollapseImageUrl, "CollapseImageUrl-beforecopy");
316 			tv.DataBindings.Add (new TreeNodeBinding ());
317 			Assert.AreEqual (1, tv.DataBindings.Count, "DataBindings-beforecopy");
318 			tv.EnableClientScript = true;
319 			Assert.AreEqual (true, tv.EnableClientScript, "EnableClientScript-beforecopy");
320 			tv.ExpandDepth = -1;
321 			Assert.AreEqual (-1, tv.ExpandDepth, "ExpandDepth-beforecopy");
322 			tv.ExpandImageToolTip = "Expand {0}";
323 			Assert.AreEqual ("Expand {0}", tv.ExpandImageToolTip, "ExpandImageToolTip-beforecopy");
324 			tv.ExpandImageUrl = string.Empty;
325 			Assert.AreEqual (string.Empty, tv.ExpandImageUrl, "ExpandImageUrl-beforecopy");
326 			tv.ImageSet = TreeViewImageSet.Custom;
327 			Assert.AreEqual (TreeViewImageSet.Custom, tv.ImageSet, "ImageSet-beforecopy");
328 			tv.LevelStyles.Add (new TreeNodeStyle ());
329 			Assert.AreEqual (1, tv.LevelStyles.Count, "LevelStyles-beforecopy");
330 			tv.LineImagesFolder = string.Empty;
331 			Assert.AreEqual (string.Empty, tv.LineImagesFolder, "LineImagesFolder-beforecopy");
332 			tv.MaxDataBindDepth = -1;
333 			Assert.AreEqual (-1, tv.MaxDataBindDepth, "MaxDataBindDepth-beforecopy");
334 			tv.NodeIndent = 20;
335 			Assert.AreEqual (20, tv.NodeIndent, "NodeIndent-beforecopy");
336 			tv.NodeWrap = false;
337 			Assert.AreEqual (false, tv.NodeWrap, "NodeWrap-beforecopy");
338 			tv.NoExpandImageUrl = string.Empty;
339 			Assert.AreEqual (string.Empty, tv.NoExpandImageUrl, "NoExpandImageUrl-beforecopy");
340 			tv.PopulateNodesFromClient = true;
341 			Assert.AreEqual (true, tv.PopulateNodesFromClient, "PopulateNodesFromClient-beforecopy");
342 			tv.ShowCheckBoxes = TreeNodeTypes.None;
343 			Assert.AreEqual (TreeNodeTypes.None, tv.ShowCheckBoxes, "ShowCheckBoxes-beforecopy");
344 			tv.ShowExpandCollapse = true;
345 			Assert.AreEqual (true, tv.ShowExpandCollapse, "ShowExpandCollapse-beforecopy");
346 			tv.ShowLines = false;
347 			Assert.AreEqual (false, tv.ShowLines, "ShowLines-beforecopy");
348 			tv.SkipLinkText = "Skip Navigation Links.";
349 			Assert.AreEqual ("Skip Navigation Links.", tv.SkipLinkText, "SkipLinkText-beforecopy");
350 			tv.Target = string.Empty;
351 			Assert.AreEqual (string.Empty, tv.Target, "Target-beforecopy");
352 			tv.Visible = true;
353 			Assert.AreEqual (true, tv.Visible, "Visible-beforecopy");
354 			object state = tv.SaveState ();
355 			PokerTreeView copy = new PokerTreeView ();
356 			copy.LoadState (state);
357 			Assert.AreEqual (true, copy.AutoGenerateDataBindings, "AutoGenerateDataBindings-aftercopy");
358 			Assert.AreEqual ("Collapse {0}", copy.CollapseImageToolTip, "CollapseImageToolTip-aftercopy");
359 			Assert.AreEqual (string.Empty, copy.CollapseImageUrl, "CollapseImageUrl-aftercopy");
360 			Assert.AreEqual (true, copy.EnableClientScript, "EnableClientScript-aftercopy");
361 			Assert.AreEqual (-1, copy.ExpandDepth, "ExpandDepth-aftercopy");
362 			Assert.AreEqual ("Expand {0}", copy.ExpandImageToolTip, "ExpandImageToolTip-aftercopy");
363 			Assert.AreEqual (string.Empty, copy.ExpandImageUrl, "ExpandImageUrl-aftercopy");
364 			Assert.AreEqual (TreeViewImageSet.Custom, copy.ImageSet, "ImageSet-aftercopy");
365 			Assert.AreEqual (1, copy.LevelStyles.Count, "LevelStyles-aftercopy");
366 			Assert.AreEqual (string.Empty, copy.LineImagesFolder, "LineImagesFolder-aftercopy");
367 			Assert.AreEqual (-1, copy.MaxDataBindDepth, "MaxDataBindDepth-aftercopy");
368 			Assert.AreEqual (20, copy.NodeIndent, "NodeIndent-aftercopy");
369 			Assert.AreEqual (2, copy.Nodes.Count, "Nodes-aftercopy");
370 			Assert.AreEqual (false, copy.NodeWrap, "NodeWrap-aftercopy");
371 			Assert.AreEqual (string.Empty, copy.NoExpandImageUrl, "NoExpandImageUrl-aftercopy");
372 			Assert.AreEqual (true, copy.PopulateNodesFromClient, "PopulateNodesFromClient-aftercopy");
373 			Assert.AreEqual (TreeNodeTypes.None, copy.ShowCheckBoxes, "ShowCheckBoxes-aftercopy");
374 			Assert.AreEqual (true, copy.ShowExpandCollapse, "ShowExpandCollapse-aftercopy");
375 			Assert.AreEqual (false, copy.ShowLines, "ShowLines-aftercopy");
376 			Assert.AreEqual ("Skip Navigation Links.", copy.SkipLinkText, "SkipLinkText-aftercopy");
377 			Assert.AreEqual (string.Empty, copy.Target, "Target-aftercopy");
378 			Assert.AreEqual (true, copy.Visible, "Visible-aftercopy");
379 		}
380 
381 		[Test]
TreeView_ViewStateNodes()382 		public void TreeView_ViewStateNodes () {
383 			PokerTreeView tv = new PokerTreeView ();
384 			TreeNode R = new TreeNode ("root", "value-root");
385 			TreeNode N1 = new TreeNode ("node1", "value-node1");
386 			TreeNode N2 = new TreeNode ("node2", "value-node2");
387 			R.ChildNodes.Add (N1);
388 			R.ChildNodes.Add (N2);
389 			tv.Nodes.Add (R);
390 			PokerTreeView copy = new PokerTreeView ();
391 			object state = tv.SaveState ();
392 			copy.LoadState (state);
393 			Assert.AreEqual (1, tv.Nodes.Count, "ViewStateNodes-1");
394 			Assert.AreEqual (2, tv.Nodes[0].ChildNodes.Count, "ViewStateNodes-1");
395 			Assert.AreEqual (0, tv.Nodes[0].ChildNodes[0].ChildNodes.Count, "ViewStateNodes-2");
396 			Assert.AreEqual ("node1", tv.Nodes[0].ChildNodes[0].Text, "ViewStateNodes-3");
397 			Assert.AreEqual ("value-node1", tv.Nodes[0].ChildNodes[0].Value, "ViewStateNodes-4");
398 			Assert.AreEqual (false, tv.Nodes[0].ChildNodes[0].DataBound, "ViewStateNodes-5");
399 			Assert.AreEqual ("", tv.Nodes[0].ChildNodes[0].DataPath, "ViewStateNodes-6");
400 		}
401 
402 		private static string xmlDataBind = "<?xml version=\"1.0\" encoding=\"utf-8\" ?><Book Title=\"Book Title\"><Chapter Heading=\"Chapter 1\"><Section Heading=\"Section 1\"></Section><Section Heading=\"Section 2\"></Section></Chapter><Chapter Heading=\"Chapter 2\"><Section Heading=\"Section 1\"></Section></Chapter></Book>";
403 		private static string xmlDataBindSmall = "<?xml version=\"1.0\" encoding=\"utf-8\" ?><Book Title=\"Book Title\"></Book>";
404 
405 		[Test]
TreeView_ViewStateDataBoundNodes()406 		public void TreeView_ViewStateDataBoundNodes () {
407 			PokerTreeView b = new PokerTreeView ();
408 			SetDataBindings (b);
409 			b.DataSource = CreateXmlDataSource ();
410 			b.DataBind ();
411 			PokerTreeView copy = new PokerTreeView ();
412 			object state = b.SaveState ();
413 			copy.LoadState (state);
414 			CheckTreeNodes (copy);
415 		}
416 
CheckTreeNodes(TreeView m)417 		private static void CheckTreeNodes (TreeView m) {
418 			Assert.AreEqual (1, m.Nodes.Count, "CheckTreeNodes#1");
419 			Assert.AreEqual (10, m.Nodes[0].ChildNodes.Count, "CheckTreeNodes#2");
420 			Assert.AreEqual (0, m.Nodes[0].ChildNodes[0].ChildNodes.Count, "CheckTreeNodes#3");
421 			Assert.AreEqual (true, m.Nodes[0].ChildNodes[0].DataBound, "CheckTreeNodes#4");
422 			Assert.AreEqual ("/*[position()=1]/*[position()=1]", m.Nodes[0].ChildNodes[0].DataPath, "CheckTreeNodes#5");
423 
424 			Assert.AreEqual ("img#root", m.Nodes[0].ImageUrl, "CheckTreeNodes_ImageUrl#1");
425 			Assert.AreEqual ("img#1", m.Nodes[0].ChildNodes[0].ImageUrl, "CheckTreeNodes_ImageUrl#2");
426 			Assert.AreEqual ("img#2", m.Nodes[0].ChildNodes[1].ImageUrl, "CheckTreeNodes_ImageUrl#3");
427 			Assert.AreEqual ("img#default", m.Nodes[0].ChildNodes[2].ImageUrl, "CheckTreeNodes_ImageUrl#4");
428 			Assert.AreEqual ("", m.Nodes[0].ChildNodes[2].ChildNodes[0].ImageUrl, "CheckTreeNodes_ImageUrl#5");
429 
430 			Assert.AreEqual ("url#root", m.Nodes[0].NavigateUrl, "CheckTreeNodes_NavigateUrl#1");
431 			Assert.AreEqual ("url#1", m.Nodes[0].ChildNodes[0].NavigateUrl, "CheckTreeNodes_NavigateUrl#2");
432 			Assert.AreEqual ("url#2", m.Nodes[0].ChildNodes[1].NavigateUrl, "CheckTreeNodes_NavigateUrl#3");
433 			Assert.AreEqual ("url#default", m.Nodes[0].ChildNodes[2].NavigateUrl, "CheckTreeNodes_NavigateUrl#4");
434 			Assert.AreEqual ("", m.Nodes[0].ChildNodes[2].ChildNodes[0].NavigateUrl, "CheckTreeNodes_NavigateUrl#5");
435 
436 			Assert.AreEqual ("target#root", m.Nodes[0].Target, "CheckTreeNodes_Target#1");
437 			Assert.AreEqual ("target#1", m.Nodes[0].ChildNodes[0].Target, "CheckTreeNodes_Target#2");
438 			Assert.AreEqual ("target#2", m.Nodes[0].ChildNodes[1].Target, "CheckTreeNodes_Target#3");
439 			Assert.AreEqual ("target#default", m.Nodes[0].ChildNodes[2].Target, "CheckTreeNodes_Target#4");
440 			Assert.AreEqual ("", m.Nodes[0].ChildNodes[2].ChildNodes[0].Target, "CheckTreeNodes_Target#5");
441 
442 			Assert.AreEqual ("text#root", m.Nodes[0].Text, "CheckTreeNodes_Text#1");
443 			Assert.AreEqual ("text#1", m.Nodes[0].ChildNodes[0].Text, "CheckTreeNodes_Text#2");
444 			Assert.AreEqual ("text#2", m.Nodes[0].ChildNodes[1].Text, "CheckTreeNodes_Text#3");
445 			Assert.AreEqual ("text#", m.Nodes[0].ChildNodes[2].Text, "CheckTreeNodes_Text#4");
446 			Assert.AreEqual ("subnode", m.Nodes[0].ChildNodes[2].ChildNodes[0].Text, "CheckTreeNodes_Text#5");
447 
448 			Assert.AreEqual ("tooltip#root", m.Nodes[0].ToolTip, "CheckTreeNodes_ToolTip#1");
449 			Assert.AreEqual ("tooltip#1", m.Nodes[0].ChildNodes[0].ToolTip, "CheckTreeNodes_ToolTip#2");
450 			Assert.AreEqual ("tooltip#2", m.Nodes[0].ChildNodes[1].ToolTip, "CheckTreeNodes_ToolTip#3");
451 			Assert.AreEqual ("tooltip#default", m.Nodes[0].ChildNodes[2].ToolTip, "CheckTreeNodes_ToolTip#4");
452 			Assert.AreEqual ("", m.Nodes[0].ChildNodes[2].ChildNodes[0].ToolTip, "CheckTreeNodes_ToolTip#5");
453 
454 			Assert.AreEqual ("imagetooltip#root", m.Nodes[0].ImageToolTip, "CheckTreeNodes_ImageToolTip#1");
455 			Assert.AreEqual ("imagetooltip#1", m.Nodes[0].ChildNodes[0].ImageToolTip, "CheckTreeNodes_ImageToolTip#2");
456 			Assert.AreEqual ("imagetooltip#2", m.Nodes[0].ChildNodes[1].ImageToolTip, "CheckTreeNodes_ImageToolTip#3");
457 			Assert.AreEqual ("imagetooltip#default", m.Nodes[0].ChildNodes[2].ImageToolTip, "CheckTreeNodes_ImageToolTip#4");
458 			Assert.AreEqual ("", m.Nodes[0].ChildNodes[2].ChildNodes[0].ImageToolTip, "CheckTreeNodes_ImageToolTip#5");
459 
460 			Assert.AreEqual ("value#root", m.Nodes[0].Value, "CheckTreeNodes_Value#1");
461 			Assert.AreEqual ("value#1", m.Nodes[0].ChildNodes[0].Value, "CheckTreeNodes_Value#2");
462 			Assert.AreEqual ("value#2", m.Nodes[0].ChildNodes[1].Value, "CheckTreeNodes_Value#3");
463 			Assert.AreEqual ("value#default", m.Nodes[0].ChildNodes[2].Value, "CheckTreeNodes_Value#4");
464 			Assert.AreEqual ("subnode", m.Nodes[0].ChildNodes[2].ChildNodes[0].Value, "CheckTreeNodes_Value#5");
465 
466 			Assert.AreEqual ("text#extra1", m.Nodes[0].ChildNodes[3].Text, "CheckTreeNodes_Extra1#1");
467 			Assert.AreEqual ("text#extra1", m.Nodes[0].ChildNodes[3].Value, "CheckTreeNodes_Extra1#2");
468 
469 			Assert.AreEqual ("value#extra2", m.Nodes[0].ChildNodes[4].Text, "CheckTreeNodes_Extra2#1");
470 			Assert.AreEqual ("value#extra2", m.Nodes[0].ChildNodes[4].Value, "CheckTreeNodes_Extra2#2");
471 
472 			Assert.AreEqual ("text#extra3", m.Nodes[0].ChildNodes[5].Text, "CheckTreeNodes_Extra3#1");
473 			Assert.AreEqual ("text#extra3", m.Nodes[0].ChildNodes[5].Value, "CheckTreeNodes_Extra3#2");
474 			Assert.AreEqual ("value#extra3", m.Nodes[0].ChildNodes[6].Text, "CheckTreeNodes_Extra3#3");
475 			Assert.AreEqual ("value#extra3", m.Nodes[0].ChildNodes[6].Value, "CheckTreeNodes_Extra3#4");
476 			Assert.AreEqual ("", m.Nodes[0].ChildNodes[7].Text, "CheckTreeNodes_Extra3#5");
477 			Assert.AreEqual ("", m.Nodes[0].ChildNodes[7].Value, "CheckTreeNodes_Extra3#6");
478 
479 			Assert.AreEqual ("text#extra4", m.Nodes[0].ChildNodes[8].Text, "CheckTreeNodes_Extra4#1");
480 			Assert.AreEqual ("text#default", m.Nodes[0].ChildNodes[8].Value, "CheckTreeNodes_Extra4#2");
481 
482 			Assert.AreEqual ("value#default", m.Nodes[0].ChildNodes[9].Text, "CheckTreeNodes_Extra5#1");
483 			Assert.AreEqual ("value#extra5", m.Nodes[0].ChildNodes[9].Value, "CheckTreeNodes_Extra5#2");
484 
485 			m.Nodes [0].ChildNodes [5].Text = "TTT";
486 			Assert.AreEqual ("TTT", m.Nodes [0].ChildNodes [5].Value, "");
487 
488 			m.Nodes [0].ChildNodes [6].Value = "VVV";
489 			Assert.AreEqual ("VVV", m.Nodes [0].ChildNodes [6].Text, "");
490 		}
491 
SetDataBindings(TreeView tv)492 		void SetDataBindings (TreeView tv) {
493 			TreeNodeBinding b = new TreeNodeBinding ();
494 			b.DataMember = "node";
495 			b.ImageUrlField = "img";
496 			b.ImageUrl = "img#default";
497 			b.NavigateUrlField = "url";
498 			b.NavigateUrl = "url#default";
499 			b.TargetField = "target";
500 			b.Target = "target#default";
501 			b.FormatString = "text#{0}";
502 			b.TextField = "text";
503 			b.Text = "text#default";
504 			b.ToolTipField = "tooltip";
505 			b.ToolTip = "tooltip#default";
506 			b.ImageToolTipField = "imagetooltip";
507 			b.ImageToolTip = "imagetooltip#default";
508 			b.ValueField = "value";
509 			b.Value = "value#default";
510 			tv.DataBindings.Add (b);
511 
512 			b = new TreeNodeBinding ();
513 			b.DataMember = "root";
514 			b.ImageUrl = "img#root";
515 			b.NavigateUrl = "url#root";
516 			b.Target = "target#root";
517 			b.Text = "text#root";
518 			b.ToolTip = "tooltip#root";
519 			b.ImageToolTip = "imagetooltip#root";
520 			b.Value = "value#root";
521 			tv.DataBindings.Add (b);
522 
523 			b = new TreeNodeBinding ();
524 			b.DataMember = "extra1";
525 			b.Text = "text#extra1";
526 			tv.DataBindings.Add (b);
527 
528 			b = new TreeNodeBinding ();
529 			b.DataMember = "extra2";
530 			b.Value = "value#extra2";
531 			tv.DataBindings.Add (b);
532 
533 			b = new TreeNodeBinding ();
534 			b.DataMember = "extra3";
535 			b.TextField = "text";
536 			b.ValueField = "value";
537 			tv.DataBindings.Add (b);
538 
539 			b = new TreeNodeBinding ();
540 			b.DataMember = "extra4";
541 			b.TextField = "text";
542 			b.Text = "text#default";
543 			b.ValueField = "value";
544 			tv.DataBindings.Add (b);
545 
546 			b = new TreeNodeBinding ();
547 			b.DataMember = "extra5";
548 			b.TextField = "text";
549 			b.Value = "value#default";
550 			b.ValueField = "value";
551 			tv.DataBindings.Add (b);
552 		}
553 
CreateXmlDataSource()554 		XmlDataSource CreateXmlDataSource () {
555 			XmlDataSource xmlDs = new XmlDataSource ();
556 			xmlDs.EnableCaching = false;
557 			xmlDs.ID = "XmlDataSource";
558 			xmlDs.Data = "<root>" +
559 				"<node url=\"url#1\" img=\"img#1\" selectable=\"true\" popoutimg=\"popoutimg#1\" separatorimg=\"separatorimg#1\" target=\"target#1\" text=\"1\" tooltip=\"tooltip#1\" imagetooltip=\"imagetooltip#1\" value=\"value#1\" />" +
560 				"<node url=\"url#2\" img=\"img#2\" selectable=\"false\" popoutimg=\"popoutimg#2\" separatorimg=\"separatorimg#2\" target=\"target#2\" text=\"2\" tooltip=\"tooltip#2\" imagetooltip=\"imagetooltip#2\" value=\"value#2\" />" +
561 				"<node url=\"\" img=\"\" selectable=\"\" popoutimg=\"\" separatorimg=\"\" target=\"\" text=\"\" tooltip=\"\" imagetooltip=\"\" value=\"\">" +
562 				"<subnode url=\"url#unreachable\" img=\"img#unreachable\" selectable=\"false\" popoutimg=\"popoutimg#unreachable\" separatorimg=\"separatorimg#unreachable\" target=\"target#unreachable\" text=\"text#unreachable\" tooltip=\"tooltip#unreachable\" imagetooltip=\"imagetooltip#unreachable\" value=\"value#unreachable\" />" +
563 				"<subnode /></node>" +
564 				"<extra1 /><extra2 />" +
565 				"<extra3 text=\"text#extra3\" value=\"\" />" +
566 				"<extra3 text=\"\" value=\"value#extra3\" />" +
567 				"<extra3 text=\"\" value=\"\" />" +
568 				"<extra4 text=\"text#extra4\" value=\"\" />" +
569 				"<extra5 text=\"\" value=\"value#extra5\" />" +
570 				"</root>";
571 			return xmlDs;
572 		}
573 
574 		[Test]
575 		[ExpectedException (typeof (ArgumentOutOfRangeException))]
TreeView_Exp_ImageSet()576 		public void TreeView_Exp_ImageSet () {
577 			// The specified image set is not one of the TreeViewImageSet values.
578 			PokerTreeView tv = new PokerTreeView ();
579 			tv.ImageSet = (TreeViewImageSet) 16;
580 		}
581 
582 		[Test]
583 		[ExpectedException (typeof (ArgumentOutOfRangeException))]
TreeView_Exp_ShowCheckBoxes()584 		public void TreeView_Exp_ShowCheckBoxes () {
585 			// The bitwise combination value is outside the range of the TreeNodeTypes enumeration.
586 			PokerTreeView tv = new PokerTreeView ();
587 			tv.ShowCheckBoxes = (TreeNodeTypes) 8;
588 		}
589 
590 		[Test]
591 		[ExpectedException (typeof (ArgumentOutOfRangeException))]
TreeView_Exp_Nodes()592 		public void TreeView_Exp_Nodes () {
593 			// Trying to access nonexisting node.
594 			PokerTreeView tv = new PokerTreeView ();
595 			int depth = tv.Nodes[1].Depth;
596 		}
597 
598 		[Test]
TreeView_Method_DataBindDataSource()599 		public void TreeView_Method_DataBindDataSource () {
600 			PokerTreeView tv = new PokerTreeView ();
601 			XmlDataSource xmlds = new XmlDataSource ();
602 			xmlds.EnableCaching = false;
603 			xmlds.Data = xmlDataBind;
604 			tv.DataSource = xmlds;
605 			_TreeNodeDataBoundCount = 0;
606 			tv.TreeNodeDataBound += new TreeNodeEventHandler (TreeView_TreeNodeDataBound);
607 			Assert.AreEqual (0, tv.Nodes.Count, "BeforeDataBind1");
608 			tv.DataBind ();
609 			Assert.AreEqual (1, tv.Nodes.Count, "AfterDataBind1-a");
610 			Assert.AreEqual ("Book", tv.Nodes[0].Text, "AfterDataBind1-b");
611 			Assert.AreEqual (2, tv.Nodes[0].ChildNodes.Count, "AfterDataBind1-c");
612 			Assert.AreEqual (2, tv.Nodes [0].ChildNodes [0].ChildNodes.Count, "AfterDataBind1-d");
613 			Assert.AreEqual (6, _TreeNodeDataBoundCount, "AfterDataBind1-TreeNodeDataBoundCount");
614 		}
615 
616 		[Test]
TreeView_MaxDataBindDepth()617 		public void TreeView_MaxDataBindDepth () {
618 			TreeView tv = new TreeView ();
619 			XmlDataSource xmlds = new XmlDataSource ();
620 			xmlds.EnableCaching = false;
621 			xmlds.Data = xmlDataBind;
622 			tv.DataSource = xmlds;
623 			tv.MaxDataBindDepth = 1;
624 			_TreeNodeDataBoundCount = 0;
625 			tv.TreeNodeDataBound += new TreeNodeEventHandler (TreeView_TreeNodeDataBound);
626 			Assert.AreEqual (0, tv.Nodes.Count, "BeforeDataBind1");
627 			tv.DataBind ();
628 			Assert.AreEqual (1, tv.Nodes.Count, "AfterDataBind1-a");
629 			Assert.AreEqual ("Book", tv.Nodes [0].Text, "AfterDataBind1-b");
630 			Assert.AreEqual (2, tv.Nodes [0].ChildNodes.Count, "AfterDataBind1-c");
631 			Assert.AreEqual (0, tv.Nodes [0].ChildNodes [0].ChildNodes.Count, "AfterDataBind1-d");
632 			Assert.AreEqual (3, _TreeNodeDataBoundCount, "AfterDataBind1-TreeNodeDataBoundCount");
633 		}
634 
635 		int _TreeNodeDataBoundCount;
TreeView_TreeNodeDataBound(object sender, TreeNodeEventArgs e)636 		private void TreeView_TreeNodeDataBound (object sender, TreeNodeEventArgs e) {
637 			_TreeNodeDataBoundCount++;
638 		}
639 
640 		[Test]
TreeView_Method_DataBindStatic()641 		public void TreeView_Method_DataBindStatic () {
642 			PokerTreeView tv = new PokerTreeView ();
643 			TreeNode R = new TreeNode ("root", "value-root");
644 			TreeNode N1 = new TreeNode ("node1", "value-node1");
645 			TreeNode N2 = new TreeNode ("node2", "value-node2");
646 			R.ChildNodes.Add (N1);
647 			R.ChildNodes.Add (N2);
648 			tv.Nodes.Add (R);
649 			tv.DataBind ();
650 			Assert.AreEqual (1, tv.Nodes.Count, "DataBindStatic-1");
651 			Assert.AreEqual (2, tv.Nodes[0].ChildNodes.Count, "DataBindStatic-1");
652 			Assert.AreEqual (0, tv.Nodes[0].ChildNodes[0].ChildNodes.Count, "DataBindStatic-2");
653 			Assert.AreEqual ("node1", tv.Nodes[0].ChildNodes[0].Text, "DataBindStatic-3");
654 			Assert.AreEqual ("value-node1", tv.Nodes[0].ChildNodes[0].Value, "DataBindStatic-4");
655 			Assert.AreEqual (false, tv.Nodes[0].ChildNodes[0].DataBound, "DataBindStatic-5");
656 			Assert.AreEqual ("", tv.Nodes[0].ChildNodes[0].DataPath, "DataBindStatic-6");
657 		}
658 
659 		[Test]
TreeView_Method_DataBind()660 		public void TreeView_Method_DataBind () {
661 			PokerTreeView tv = new PokerTreeView ();
662 			SetDataBindings (tv);
663 			tv.DataSource = CreateXmlDataSource ();
664 			tv.DataBind ();
665 			CheckTreeNodes (tv);
666 		}
667 
668 		[Test]
TreeView_Method_FindNode()669 		public void TreeView_Method_FindNode () {
670 			PokerTreeView tv = new PokerTreeView ();
671 			XmlDataSource xmlds = new XmlDataSource ();
672 			xmlds.EnableCaching = false;
673 			xmlds.Data = xmlDataBind;
674 			tv.DataSource = xmlds;
675 			tv.DataBind ();
676 			TreeNode tn = new TreeNode ();
677 			Assert.AreEqual (0, tn.ChildNodes.Count, "BeforeFindNode");
678 			tn = tv.FindNode ("Book" + tv.PathSeparator + "Chapter");
679 			Assert.AreEqual ("Chapter", tn.Text, "AfterFindNode1");
680 			Assert.AreEqual (2, tn.ChildNodes.Count, "AfterFindNode2");
681 			Assert.AreEqual ("Section", tn.ChildNodes[0].Text, "AfterFindNode3");
682 		}
683 
684 		[Test]
685 		[Category ("NunitWeb")]
TreeView_Render_Defaults()686 		public void TreeView_Render_Defaults () {
687 			WebTest t = new WebTest (PageInvoker.CreateOnLoad (pageLoadRenderDefaults));
688 			#region HTML
689 			string strTarget = "<a href=\"#treeview1_SkipLink\"><img alt=\"Skip Navigation Links.\" src=\"/NunitWeb/WebResource.axd?d=8VpphgAbakKUC_J8R6hR0Q2&amp;t=634067491135766272\" width=\"0\" height=\"0\" style=\"border-width:0px;\" /></a><div id=\"treeview1\">\r\n\t<table cellpadding=\"0\" cellspacing=\"0\" style=\"border-width:0;\">\r\n\t\t<tr>\r\n\t\t\t<td><a href=\"javascript:__doPostBack(&#39;treeview1&#39;,&#39;tBook&#39;)\"><img src=\"/NunitWeb/WebResource.axd?d=Me-CdxEHiTTT3lXTDd0I2qLe7WfoYyDfWfVSkV5Suzs1&amp;t=634067491135766272\" alt=\"Collapse Book\" style=\"border-width:0;\" /></a></td><td style=\"white-space:nowrap;\"><a class=\"treeview1_0\" href=\"javascript:__doPostBack(&#39;treeview1&#39;,&#39;sBook&#39;)\" id=\"treeview1t0\">Book</a></td>\r\n\t\t</tr>\r\n\t</table><table cellpadding=\"0\" cellspacing=\"0\" style=\"border-width:0;\">\r\n\t\t<tr>\r\n\t\t\t<td><div style=\"width:20px;height:1px\"></div></td><td><a href=\"javascript:__doPostBack(&#39;treeview1&#39;,&#39;tBook\\\\Chapter&#39;)\"><img src=\"/NunitWeb/WebResource.axd?d=Me-CdxEHiTTT3lXTDd0I2qLe7WfoYyDfWfVSkV5Suzs1&amp;t=634067491135766272\" alt=\"Collapse Chapter\" style=\"border-width:0;\" /></a></td><td style=\"white-space:nowrap;\"><a class=\"treeview1_0\" href=\"javascript:__doPostBack(&#39;treeview1&#39;,&#39;sBook\\\\Chapter&#39;)\" id=\"treeview1t1\">Chapter</a></td>\r\n\t\t</tr>\r\n\t</table><table cellpadding=\"0\" cellspacing=\"0\" style=\"border-width:0;\">\r\n\t\t<tr>\r\n\t\t\t<td><div style=\"width:20px;height:1px\"></div></td><td><div style=\"width:20px;height:1px\"></div></td><td><img src=\"/NunitWeb/WebResource.axd?d=Me-CdxEHiTTT3lXTDd0I2ilpe6vhhhJjssENmbNkrSY1&amp;t=634067491135766272\" alt=\"\" /></td><td style=\"white-space:nowrap;\"><a class=\"treeview1_0\" href=\"javascript:__doPostBack(&#39;treeview1&#39;,&#39;sBook\\\\Chapter\\\\Section&#39;)\" id=\"treeview1t2\">Section</a></td>\r\n\t\t</tr>\r\n\t</table><table cellpadding=\"0\" cellspacing=\"0\" style=\"border-width:0;\">\r\n\t\t<tr>\r\n\t\t\t<td><div style=\"width:20px;height:1px\"></div></td><td><div style=\"width:20px;height:1px\"></div></td><td><img src=\"/NunitWeb/WebResource.axd?d=Me-CdxEHiTTT3lXTDd0I2ilpe6vhhhJjssENmbNkrSY1&amp;t=634067491135766272\" alt=\"\" /></td><td style=\"white-space:nowrap;\"><a class=\"treeview1_0\" href=\"javascript:__doPostBack(&#39;treeview1&#39;,&#39;sBook\\\\Chapter\\\\Section&#39;)\" id=\"treeview1t3\">Section</a></td>\r\n\t\t</tr>\r\n\t</table><table cellpadding=\"0\" cellspacing=\"0\" style=\"border-width:0;\">\r\n\t\t<tr>\r\n\t\t\t<td><div style=\"width:20px;height:1px\"></div></td><td><a href=\"javascript:__doPostBack(&#39;treeview1&#39;,&#39;tBook\\\\Chapter&#39;)\"><img src=\"/NunitWeb/WebResource.axd?d=Me-CdxEHiTTT3lXTDd0I2qLe7WfoYyDfWfVSkV5Suzs1&amp;t=634067491135766272\" alt=\"Collapse Chapter\" style=\"border-width:0;\" /></a></td><td style=\"white-space:nowrap;\"><a class=\"treeview1_0\" href=\"javascript:__doPostBack(&#39;treeview1&#39;,&#39;sBook\\\\Chapter&#39;)\" id=\"treeview1t4\">Chapter</a></td>\r\n\t\t</tr>\r\n\t</table><table cellpadding=\"0\" cellspacing=\"0\" style=\"border-width:0;\">\r\n\t\t<tr>\r\n\t\t\t<td><div style=\"width:20px;height:1px\"></div></td><td><div style=\"width:20px;height:1px\"></div></td><td><img src=\"/NunitWeb/WebResource.axd?d=Me-CdxEHiTTT3lXTDd0I2ilpe6vhhhJjssENmbNkrSY1&amp;t=634067491135766272\" alt=\"\" /></td><td style=\"white-space:nowrap;\"><a class=\"treeview1_0\" href=\"javascript:__doPostBack(&#39;treeview1&#39;,&#39;sBook\\\\Chapter\\\\Section&#39;)\" id=\"treeview1t5\">Section</a></td>\r\n\t\t</tr>\r\n\t</table>\r\n</div><a id=\"treeview1_SkipLink\"></a>";
690 			#endregion
691 			string str = HtmlDiff.GetControlFromPageHtml (t.Run ());
692 			HtmlDiff.AssertAreEqual (strTarget, str, "RenderDefaults");
693 		}
pageLoadRenderDefaults(Page page)694 		public static void pageLoadRenderDefaults (Page page) {
695 			TreeView tv = new TreeView ();
696 			tv.EnableClientScript = false;
697 			tv.ID = "treeview1";
698 			XmlDataSource xmlds = new XmlDataSource ();
699 			xmlds.EnableCaching = false;
700 			xmlds.Data = xmlDataBind;
701 			tv.DataSource = xmlds;
702 			tv.DataBind ();
703 			LiteralControl lcb = new LiteralControl (HtmlDiff.BEGIN_TAG);
704 			LiteralControl lce = new LiteralControl (HtmlDiff.END_TAG);
705 			page.Form.Controls.Add (lcb);
706 			page.Form.Controls.Add (tv);
707 			page.Form.Controls.Add (lce);
708 		}
709 
710 		[Test (Description="Bug #580692")]
711 		[Category ("NunitWeb")]
TreeView_Render_LevelStyle_CssClass()712 		public void TreeView_Render_LevelStyle_CssClass ()
713 		{
714 			WebTest t = new WebTest (PageInvoker.CreateOnLoad (pageLoadRenderLevelStyleCssClass));
715 #region HTML
716 			string strTarget = "<a href=\"#treeview1_SkipLink\"><img alt=\"Skip Navigation Links.\" src=\"/NunitWeb/WebResource.axd?d=8VpphgAbakKUC_J8R6hR0Q2&amp;t=634067491135766272\" width=\"0\" height=\"0\" style=\"border-width:0px;\" /></a><div id=\"treeview1\">\r\n\t<table cellpadding=\"0\" cellspacing=\"0\" style=\"border-width:0;\">\r\n\t\t<tr>\r\n\t\t\t<td><a href=\"javascript:__doPostBack(&#39;treeview1&#39;,&#39;tBook&#39;)\"><img src=\"/NunitWeb/WebResource.axd?d=Me-CdxEHiTTT3lXTDd0I2qLe7WfoYyDfWfVSkV5Suzs1&amp;t=634067491135766272\" alt=\"Collapse Book\" style=\"border-width:0;\" /></a></td><td class=\"TestCssClass1 treeview1_2\" style=\"white-space:nowrap;\"><a class=\"treeview1_0 TestCssClass1 treeview1_1\" href=\"javascript:__doPostBack(&#39;treeview1&#39;,&#39;sBook&#39;)\" id=\"treeview1t0\" style=\"border-style:none;font-size:1em;\">Book</a></td>\r\n\t\t</tr>\r\n\t</table><table cellpadding=\"0\" cellspacing=\"0\" style=\"border-width:0;\">\r\n\t\t<tr>\r\n\t\t\t<td><div style=\"width:20px;height:1px\"></div></td><td><a href=\"javascript:__doPostBack(&#39;treeview1&#39;,&#39;tBook\\\\Chapter&#39;)\"><img src=\"/NunitWeb/WebResource.axd?d=Me-CdxEHiTTT3lXTDd0I2qLe7WfoYyDfWfVSkV5Suzs1&amp;t=634067491135766272\" alt=\"Collapse Chapter\" style=\"border-width:0;\" /></a></td><td class=\"TestCssClass2 treeview1_4\" style=\"white-space:nowrap;\"><a class=\"treeview1_0 TestCssClass2 treeview1_3\" href=\"javascript:__doPostBack(&#39;treeview1&#39;,&#39;sBook\\\\Chapter&#39;)\" id=\"treeview1t1\" style=\"border-style:none;font-size:1em;\">Chapter</a></td>\r\n\t\t</tr>\r\n\t</table><table cellpadding=\"0\" cellspacing=\"0\" style=\"border-width:0;\">\r\n\t\t<tr>\r\n\t\t\t<td><div style=\"width:20px;height:1px\"></div></td><td><div style=\"width:20px;height:1px\"></div></td><td><img src=\"/NunitWeb/WebResource.axd?d=Me-CdxEHiTTT3lXTDd0I2ilpe6vhhhJjssENmbNkrSY1&amp;t=634067491135766272\" alt=\"\" /></td><td style=\"white-space:nowrap;\"><a class=\"treeview1_0\" href=\"javascript:__doPostBack(&#39;treeview1&#39;,&#39;sBook\\\\Chapter\\\\Section&#39;)\" id=\"treeview1t2\">Section</a></td>\r\n\t\t</tr>\r\n\t</table><table cellpadding=\"0\" cellspacing=\"0\" style=\"border-width:0;\">\r\n\t\t<tr>\r\n\t\t\t<td><div style=\"width:20px;height:1px\"></div></td><td><div style=\"width:20px;height:1px\"></div></td><td><img src=\"/NunitWeb/WebResource.axd?d=Me-CdxEHiTTT3lXTDd0I2ilpe6vhhhJjssENmbNkrSY1&amp;t=634067491135766272\" alt=\"\" /></td><td style=\"white-space:nowrap;\"><a class=\"treeview1_0\" href=\"javascript:__doPostBack(&#39;treeview1&#39;,&#39;sBook\\\\Chapter\\\\Section&#39;)\" id=\"treeview1t3\">Section</a></td>\r\n\t\t</tr>\r\n\t</table><table cellpadding=\"0\" cellspacing=\"0\" style=\"border-width:0;\">\r\n\t\t<tr>\r\n\t\t\t<td><div style=\"width:20px;height:1px\"></div></td><td><a href=\"javascript:__doPostBack(&#39;treeview1&#39;,&#39;tBook\\\\Chapter&#39;)\"><img src=\"/NunitWeb/WebResource.axd?d=Me-CdxEHiTTT3lXTDd0I2qLe7WfoYyDfWfVSkV5Suzs1&amp;t=634067491135766272\" alt=\"Collapse Chapter\" style=\"border-width:0;\" /></a></td><td class=\"TestCssClass2 treeview1_4\" style=\"white-space:nowrap;\"><a class=\"treeview1_0 TestCssClass2 treeview1_3\" href=\"javascript:__doPostBack(&#39;treeview1&#39;,&#39;sBook\\\\Chapter&#39;)\" id=\"treeview1t4\" style=\"border-style:none;font-size:1em;\">Chapter</a></td>\r\n\t\t</tr>\r\n\t</table><table cellpadding=\"0\" cellspacing=\"0\" style=\"border-width:0;\">\r\n\t\t<tr>\r\n\t\t\t<td><div style=\"width:20px;height:1px\"></div></td><td><div style=\"width:20px;height:1px\"></div></td><td><img src=\"/NunitWeb/WebResource.axd?d=Me-CdxEHiTTT3lXTDd0I2ilpe6vhhhJjssENmbNkrSY1&amp;t=634067491135766272\" alt=\"\" /></td><td style=\"white-space:nowrap;\"><a class=\"treeview1_0\" href=\"javascript:__doPostBack(&#39;treeview1&#39;,&#39;sBook\\\\Chapter\\\\Section&#39;)\" id=\"treeview1t5\">Section</a></td>\r\n\t\t</tr>\r\n\t</table>\r\n</div><a id=\"treeview1_SkipLink\"></a>";
717 #endregion
718 			string str = HtmlDiff.GetControlFromPageHtml (t.Run ());
719 			HtmlDiff.AssertAreEqual (strTarget, str, "Render_LevelStyle_CssClass");
720 		}
721 
pageLoadRenderLevelStyleCssClass(Page page)722 		public static void pageLoadRenderLevelStyleCssClass (Page page) {
723 			TreeView tv = new TreeView ();
724 			tv.EnableClientScript = false;
725 			tv.ID = "treeview1";
726 
727 			TreeNodeStyle tns = new TreeNodeStyle ();
728 			tns.CssClass = "TestCssClass1";
729 			tv.LevelStyles.Add (tns);
730 
731 			tns = new TreeNodeStyle ();
732 			tns.CssClass = "TestCssClass2";
733 			tv.LevelStyles.Add (tns);
734 
735 			XmlDataSource xmlds = new XmlDataSource ();
736 			xmlds.EnableCaching = false;
737 			xmlds.Data = xmlDataBind;
738 			tv.DataSource = xmlds;
739 			tv.DataBind ();
740 			LiteralControl lcb = new LiteralControl (HtmlDiff.BEGIN_TAG);
741 			LiteralControl lce = new LiteralControl (HtmlDiff.END_TAG);
742 			page.Form.Controls.Add (lcb);
743 			page.Form.Controls.Add (tv);
744 			page.Form.Controls.Add (lce);
745 		}
746 
747 		[Test]
748 		[Category ("NunitWeb")]
TreeView_Method_RenderTags()749 		public void TreeView_Method_RenderTags () {
750 			new WebTest (PageInvoker.CreateOnLoad (pageLoadRenderTags)).Run ();
751 		}
pageLoadRenderTags(Page page)752 		public static void pageLoadRenderTags (Page page) {
753 			TreeView tv = new TreeView ();
754 			tv.ID = "treeview1";
755 			page.Form.Controls.Add (tv);
756 			StringWriter sw = new StringWriter ();
757 			HtmlTextWriter tw = new HtmlTextWriter (sw);
758 			tv.RenderBeginTag (tw);
759 			tv.RenderEndTag (tw);
760 			string str = sw.ToString ();
761 			string strTarget = "<a href=\"#treeview1_SkipLink\"><img alt=\"Skip Navigation Links.\" src=\"/NunitWeb/WebResource.axd?d=8VpphgAbakKUC_J8R6hR0Q2&amp;t=634067491135766272\" width=\"0\" height=\"0\" style=\"border-width:0px;\" /></a><div id=\"treeview1\">\r\n\r\n</div><a id=\"treeview1_SkipLink\"></a>";
762 			HtmlDiff.AssertAreEqual (strTarget, str, "RenderTags");
763 		}
764 
765 		[Test]
766 		[Category ("NunitWeb")]
TreeView_Method_ExpandAll()767 		public void TreeView_Method_ExpandAll () {
768 			WebTest t = new WebTest (PageInvoker.CreateOnLoad (pageLoadExpandAll));
769 			#region HTML
770 			string strTarget = "<a href=\"#treeview1_SkipLink\"><img alt=\"Skip Navigation Links.\" src=\"/NunitWeb/WebResource.axd?d=8VpphgAbakKUC_J8R6hR0Q2&amp;t=634067491135766272\" width=\"0\" height=\"0\" style=\"border-width:0px;\" /></a><div id=\"treeview1\">\r\n\t<table cellpadding=\"0\" cellspacing=\"0\" style=\"border-width:0;\">\r\n\t\t<tr>\r\n\t\t\t<td><a href=\"javascript:__doPostBack(&#39;treeview1&#39;,&#39;tBook&#39;)\"><img src=\"/NunitWeb/WebResource.axd?d=Me-CdxEHiTTT3lXTDd0I2qLe7WfoYyDfWfVSkV5Suzs1&amp;t=634067491135766272\" alt=\"Collapse Book\" style=\"border-width:0;\" /></a></td><td style=\"white-space:nowrap;\"><a class=\"treeview1_0\" href=\"javascript:__doPostBack(&#39;treeview1&#39;,&#39;sBook&#39;)\" id=\"treeview1t0\">Book</a></td>\r\n\t\t</tr>\r\n\t</table><table cellpadding=\"0\" cellspacing=\"0\" style=\"border-width:0;\">\r\n\t\t<tr>\r\n\t\t\t<td><div style=\"width:20px;height:1px\"></div></td><td><a href=\"javascript:__doPostBack(&#39;treeview1&#39;,&#39;tBook\\\\Chapter&#39;)\"><img src=\"/NunitWeb/WebResource.axd?d=Me-CdxEHiTTT3lXTDd0I2qLe7WfoYyDfWfVSkV5Suzs1&amp;t=634067491135766272\" alt=\"Collapse Chapter\" style=\"border-width:0;\" /></a></td><td style=\"white-space:nowrap;\"><a class=\"treeview1_0\" href=\"javascript:__doPostBack(&#39;treeview1&#39;,&#39;sBook\\\\Chapter&#39;)\" id=\"treeview1t1\">Chapter</a></td>\r\n\t\t</tr>\r\n\t</table><table cellpadding=\"0\" cellspacing=\"0\" style=\"border-width:0;\">\r\n\t\t<tr>\r\n\t\t\t<td><div style=\"width:20px;height:1px\"></div></td><td><div style=\"width:20px;height:1px\"></div></td><td><img src=\"/NunitWeb/WebResource.axd?d=Me-CdxEHiTTT3lXTDd0I2ilpe6vhhhJjssENmbNkrSY1&amp;t=634067491135766272\" alt=\"\" /></td><td style=\"white-space:nowrap;\"><a class=\"treeview1_0\" href=\"javascript:__doPostBack(&#39;treeview1&#39;,&#39;sBook\\\\Chapter\\\\Section&#39;)\" id=\"treeview1t2\">Section</a></td>\r\n\t\t</tr>\r\n\t</table><table cellpadding=\"0\" cellspacing=\"0\" style=\"border-width:0;\">\r\n\t\t<tr>\r\n\t\t\t<td><div style=\"width:20px;height:1px\"></div></td><td><div style=\"width:20px;height:1px\"></div></td><td><img src=\"/NunitWeb/WebResource.axd?d=Me-CdxEHiTTT3lXTDd0I2ilpe6vhhhJjssENmbNkrSY1&amp;t=634067491135766272\" alt=\"\" /></td><td style=\"white-space:nowrap;\"><a class=\"treeview1_0\" href=\"javascript:__doPostBack(&#39;treeview1&#39;,&#39;sBook\\\\Chapter\\\\Section&#39;)\" id=\"treeview1t3\">Section</a></td>\r\n\t\t</tr>\r\n\t</table><table cellpadding=\"0\" cellspacing=\"0\" style=\"border-width:0;\">\r\n\t\t<tr>\r\n\t\t\t<td><div style=\"width:20px;height:1px\"></div></td><td><a href=\"javascript:__doPostBack(&#39;treeview1&#39;,&#39;tBook\\\\Chapter&#39;)\"><img src=\"/NunitWeb/WebResource.axd?d=Me-CdxEHiTTT3lXTDd0I2qLe7WfoYyDfWfVSkV5Suzs1&amp;t=634067491135766272\" alt=\"Collapse Chapter\" style=\"border-width:0;\" /></a></td><td style=\"white-space:nowrap;\"><a class=\"treeview1_0\" href=\"javascript:__doPostBack(&#39;treeview1&#39;,&#39;sBook\\\\Chapter&#39;)\" id=\"treeview1t4\">Chapter</a></td>\r\n\t\t</tr>\r\n\t</table><table cellpadding=\"0\" cellspacing=\"0\" style=\"border-width:0;\">\r\n\t\t<tr>\r\n\t\t\t<td><div style=\"width:20px;height:1px\"></div></td><td><div style=\"width:20px;height:1px\"></div></td><td><img src=\"/NunitWeb/WebResource.axd?d=Me-CdxEHiTTT3lXTDd0I2ilpe6vhhhJjssENmbNkrSY1&amp;t=634067491135766272\" alt=\"\" /></td><td style=\"white-space:nowrap;\"><a class=\"treeview1_0\" href=\"javascript:__doPostBack(&#39;treeview1&#39;,&#39;sBook\\\\Chapter\\\\Section&#39;)\" id=\"treeview1t5\">Section</a></td>\r\n\t\t</tr>\r\n\t</table>\r\n</div><a id=\"treeview1_SkipLink\"></a>";
771 			#endregion
772 			string str = HtmlDiff.GetControlFromPageHtml (t.Run ());
773 			HtmlDiff.AssertAreEqual (strTarget, str, "ExpandAll");
774 		}
pageLoadExpandAll(Page page)775 		public static void pageLoadExpandAll (Page page) {
776 			TreeView tv = new TreeView ();
777 			tv.EnableClientScript = false;
778 			tv.ID = "treeview1";
779 			XmlDataSource xmlds = new XmlDataSource ();
780 			xmlds.EnableCaching = false;
781 			xmlds.Data = xmlDataBind;
782 			tv.DataSource = xmlds;
783 			tv.DataBind ();
784 			tv.ExpandAll ();
785 			LiteralControl lcb = new LiteralControl (HtmlDiff.BEGIN_TAG);
786 			LiteralControl lce = new LiteralControl (HtmlDiff.END_TAG);
787 			page.Form.Controls.Add (lcb);
788 			page.Form.Controls.Add (tv);
789 			page.Form.Controls.Add (lce);
790 		}
791 
792 		[Test]
793 		[Category ("NunitWeb")]
TreeView_Method_NodeExpand()794 		public void TreeView_Method_NodeExpand () {
795 			WebTest t = new WebTest (PageInvoker.CreateOnLoad (pageLoadNodeExpand));
796 			#region HTML
797 			string strTarget = "<a href=\"#treeview1_SkipLink\"><img alt=\"Skip Navigation Links.\" src=\"/NunitWeb/WebResource.axd?d=8VpphgAbakKUC_J8R6hR0Q2&amp;t=634067491135766272\" width=\"0\" height=\"0\" style=\"border-width:0px;\" /></a><div id=\"treeview1\">\r\n\t<table cellpadding=\"0\" cellspacing=\"0\" style=\"border-width:0;\">\r\n\t\t<tr>\r\n\t\t\t<td><a href=\"javascript:__doPostBack(&#39;treeview1&#39;,&#39;tBook&#39;)\"><img src=\"/NunitWeb/WebResource.axd?d=Me-CdxEHiTTT3lXTDd0I2qLe7WfoYyDfWfVSkV5Suzs1&amp;t=634067491135766272\" alt=\"Collapse Book\" style=\"border-width:0;\" /></a></td><td style=\"white-space:nowrap;\"><a class=\"treeview1_0\" href=\"javascript:__doPostBack(&#39;treeview1&#39;,&#39;sBook&#39;)\" id=\"treeview1t0\">Book</a></td>\r\n\t\t</tr>\r\n\t</table><table cellpadding=\"0\" cellspacing=\"0\" style=\"border-width:0;\">\r\n\t\t<tr>\r\n\t\t\t<td><div style=\"width:20px;height:1px\"></div></td><td><a href=\"javascript:__doPostBack(&#39;treeview1&#39;,&#39;tBook\\\\Chapter&#39;)\"><img src=\"/NunitWeb/WebResource.axd?d=Me-CdxEHiTTT3lXTDd0I2qsyBHMcxXXKbUwruYE_9Mo1&amp;t=634067491135766272\" alt=\"Expand Chapter\" style=\"border-width:0;\" /></a></td><td style=\"white-space:nowrap;\"><a class=\"treeview1_0\" href=\"javascript:__doPostBack(&#39;treeview1&#39;,&#39;sBook\\\\Chapter&#39;)\" id=\"treeview1t1\">Chapter</a></td>\r\n\t\t</tr>\r\n\t</table><table cellpadding=\"0\" cellspacing=\"0\" style=\"border-width:0;\">\r\n\t\t<tr>\r\n\t\t\t<td><div style=\"width:20px;height:1px\"></div></td><td><a href=\"javascript:__doPostBack(&#39;treeview1&#39;,&#39;tBook\\\\Chapter&#39;)\"><img src=\"/NunitWeb/WebResource.axd?d=Me-CdxEHiTTT3lXTDd0I2qsyBHMcxXXKbUwruYE_9Mo1&amp;t=634067491135766272\" alt=\"Expand Chapter\" style=\"border-width:0;\" /></a></td><td style=\"white-space:nowrap;\"><a class=\"treeview1_0\" href=\"javascript:__doPostBack(&#39;treeview1&#39;,&#39;sBook\\\\Chapter&#39;)\" id=\"treeview1t4\">Chapter</a></td>\r\n\t\t</tr>\r\n\t</table>\r\n</div><a id=\"treeview1_SkipLink\"></a>";
798 			#endregion
799 			string str = HtmlDiff.GetControlFromPageHtml (t.Run ());
800 			HtmlDiff.AssertAreEqual (strTarget, str, "NodeExpand");
801 		}
pageLoadNodeExpand(Page page)802 		public static void pageLoadNodeExpand (Page page) {
803 			TreeView tv = new TreeView ();
804 			tv.EnableClientScript = false;
805 			tv.ID = "treeview1";
806 			XmlDataSource xmlds = new XmlDataSource ();
807 			xmlds.EnableCaching = false;
808 			xmlds.Data = xmlDataBind;
809 			tv.DataSource = xmlds;
810 			tv.DataBind ();
811 			tv.CollapseAll ();
812 			tv.Nodes[0].Expand ();
813 			LiteralControl lcb = new LiteralControl (HtmlDiff.BEGIN_TAG);
814 			LiteralControl lce = new LiteralControl (HtmlDiff.END_TAG);
815 			page.Form.Controls.Add (lcb);
816 			page.Form.Controls.Add (tv);
817 			page.Form.Controls.Add (lce);
818 		}
819 
820 		[Test]
821 		[Category ("NunitWeb")]
TreeView_Method_NodeExpandAll()822 		public void TreeView_Method_NodeExpandAll () {
823 			WebTest t = new WebTest (PageInvoker.CreateOnLoad (pageLoadNodeExpandAll));
824 			#region HTML
825 			string strTarget = "<a href=\"#treeview1_SkipLink\"><img alt=\"Skip Navigation Links.\" src=\"/NunitWeb/WebResource.axd?d=8VpphgAbakKUC_J8R6hR0Q2&amp;t=634067491135766272\" width=\"0\" height=\"0\" style=\"border-width:0px;\" /></a><div id=\"treeview1\">\r\n\t<table cellpadding=\"0\" cellspacing=\"0\" style=\"border-width:0;\">\r\n\t\t<tr>\r\n\t\t\t<td><a href=\"javascript:__doPostBack(&#39;treeview1&#39;,&#39;tBook&#39;)\"><img src=\"/NunitWeb/WebResource.axd?d=Me-CdxEHiTTT3lXTDd0I2qsyBHMcxXXKbUwruYE_9Mo1&amp;t=634067491135766272\" alt=\"Expand Book\" style=\"border-width:0;\" /></a></td><td style=\"white-space:nowrap;\"><a class=\"treeview1_0\" href=\"javascript:__doPostBack(&#39;treeview1&#39;,&#39;sBook&#39;)\" id=\"treeview1t0\">Book</a></td>\r\n\t\t</tr>\r\n\t</table>\r\n</div><a id=\"treeview1_SkipLink\"></a>";
826 			#endregion
827 			string str = HtmlDiff.GetControlFromPageHtml (t.Run ());
828 			HtmlDiff.AssertAreEqual (strTarget, str, "NodeExpandAll");
829 		}
pageLoadNodeExpandAll(Page page)830 		public static void pageLoadNodeExpandAll (Page page) {
831 			TreeView tv = new TreeView ();
832 			tv.EnableClientScript = false;
833 			tv.ID = "treeview1";
834 			XmlDataSource xmlds = new XmlDataSource ();
835 			xmlds.EnableCaching = false;
836 			xmlds.Data = xmlDataBind;
837 			tv.DataSource = xmlds;
838 			tv.DataBind ();
839 			tv.CollapseAll ();
840 			tv.Nodes[0].ChildNodes[0].ExpandAll ();
841 			LiteralControl lcb = new LiteralControl (HtmlDiff.BEGIN_TAG);
842 			LiteralControl lce = new LiteralControl (HtmlDiff.END_TAG);
843 			page.Form.Controls.Add (lcb);
844 			page.Form.Controls.Add (tv);
845 			page.Form.Controls.Add (lce);
846 		}
847 
848 		[Test]
849 		[Category ("NunitWeb")]
TreeView_Method_CollapseAll()850 		public void TreeView_Method_CollapseAll () {
851 			WebTest t = new WebTest (PageInvoker.CreateOnLoad (pageLoadCollapseAll));
852 			#region HTML
853 			string strTarget = "<a href=\"#treeview1_SkipLink\"><img alt=\"Skip Navigation Links.\" src=\"/NunitWeb/WebResource.axd?d=8VpphgAbakKUC_J8R6hR0Q2&amp;t=634067491135766272\" width=\"0\" height=\"0\" style=\"border-width:0px;\" /></a><div id=\"treeview1\">\r\n\t<table cellpadding=\"0\" cellspacing=\"0\" style=\"border-width:0;\">\r\n\t\t<tr>\r\n\t\t\t<td><a href=\"javascript:__doPostBack(&#39;treeview1&#39;,&#39;tBook&#39;)\"><img src=\"/NunitWeb/WebResource.axd?d=Me-CdxEHiTTT3lXTDd0I2qsyBHMcxXXKbUwruYE_9Mo1&amp;t=634067491135766272\" alt=\"Expand Book\" style=\"border-width:0;\" /></a></td><td style=\"white-space:nowrap;\"><a class=\"treeview1_0\" href=\"javascript:__doPostBack(&#39;treeview1&#39;,&#39;sBook&#39;)\" id=\"treeview1t0\">Book</a></td>\r\n\t\t</tr>\r\n\t</table>\r\n</div><a id=\"treeview1_SkipLink\"></a>";
854 			#endregion
855 			string str = HtmlDiff.GetControlFromPageHtml (t.Run ());
856 			HtmlDiff.AssertAreEqual (strTarget, str, "CollapseAll");
857 		}
pageLoadCollapseAll(Page page)858 		public static void pageLoadCollapseAll (Page page) {
859 			TreeView tv = new TreeView ();
860 			tv.EnableClientScript = false;
861 			tv.ID = "treeview1";
862 			XmlDataSource xmlds = new XmlDataSource ();
863 			xmlds.EnableCaching = false;
864 			xmlds.Data = xmlDataBind;
865 			tv.DataSource = xmlds;
866 			tv.DataBind ();
867 			tv.CollapseAll ();
868 			LiteralControl lcb = new LiteralControl (HtmlDiff.BEGIN_TAG);
869 			LiteralControl lce = new LiteralControl (HtmlDiff.END_TAG);
870 			page.Form.Controls.Add (lcb);
871 			page.Form.Controls.Add (tv);
872 			page.Form.Controls.Add (lce);
873 		}
874 
875 		[Test]
876 		[Category ("NunitWeb")]
TreeView_Method_NodeCollapse()877 		public void TreeView_Method_NodeCollapse () {
878 			WebTest t = new WebTest (PageInvoker.CreateOnLoad (pageLoadNodeCollapse));
879 			#region HTML
880 			string strTarget = "<a href=\"#treeview1_SkipLink\"><img alt=\"Skip Navigation Links.\" src=\"/NunitWeb/WebResource.axd?d=8VpphgAbakKUC_J8R6hR0Q2&amp;t=634067491135766272\" width=\"0\" height=\"0\" style=\"border-width:0px;\" /></a><div id=\"treeview1\">\r\n\t<table cellpadding=\"0\" cellspacing=\"0\" style=\"border-width:0;\">\r\n\t\t<tr>\r\n\t\t\t<td><a href=\"javascript:__doPostBack(&#39;treeview1&#39;,&#39;tBook&#39;)\"><img src=\"/NunitWeb/WebResource.axd?d=Me-CdxEHiTTT3lXTDd0I2qsyBHMcxXXKbUwruYE_9Mo1&amp;t=634067491135766272\" alt=\"Expand Book\" style=\"border-width:0;\" /></a></td><td style=\"white-space:nowrap;\"><a class=\"treeview1_0\" href=\"javascript:__doPostBack(&#39;treeview1&#39;,&#39;sBook&#39;)\" id=\"treeview1t0\">Book</a></td>\r\n\t\t</tr>\r\n\t</table>\r\n</div><a id=\"treeview1_SkipLink\"></a>";
881 			#endregion
882 			string str = HtmlDiff.GetControlFromPageHtml (t.Run ());
883 			HtmlDiff.AssertAreEqual (strTarget, str, "NodeCollapse");
884 		}
pageLoadNodeCollapse(Page page)885 		public static void pageLoadNodeCollapse (Page page) {
886 			TreeView tv = new TreeView ();
887 			tv.EnableClientScript = false;
888 			tv.ID = "treeview1";
889 			XmlDataSource xmlds = new XmlDataSource ();
890 			xmlds.EnableCaching = false;
891 			xmlds.Data = xmlDataBind;
892 			tv.DataSource = xmlds;
893 			tv.DataBind ();
894 			tv.Nodes[0].Collapse ();
895 			LiteralControl lcb = new LiteralControl (HtmlDiff.BEGIN_TAG);
896 			LiteralControl lce = new LiteralControl (HtmlDiff.END_TAG);
897 			page.Form.Controls.Add (lcb);
898 			page.Form.Controls.Add (tv);
899 			page.Form.Controls.Add (lce);
900 		}
901 
902 		[Test]
903 		[Category ("NunitWeb")]
TreeView_Method_NodeCollapseAll()904 		public void TreeView_Method_NodeCollapseAll () {
905 			WebTest t = new WebTest (PageInvoker.CreateOnLoad (pageLoadNodeCollapseAll));
906 			#region HTML
907 			string strTarget = "<a href=\"#treeview1_SkipLink\"><img alt=\"Skip Navigation Links.\" src=\"/NunitWeb/WebResource.axd?d=8VpphgAbakKUC_J8R6hR0Q2&amp;t=634067491135766272\" width=\"0\" height=\"0\" style=\"border-width:0px;\" /></a><div id=\"treeview1\">\r\n\t<table cellpadding=\"0\" cellspacing=\"0\" style=\"border-width:0;\">\r\n\t\t<tr>\r\n\t\t\t<td><a href=\"javascript:__doPostBack(&#39;treeview1&#39;,&#39;tBook&#39;)\"><img src=\"/NunitWeb/WebResource.axd?d=Me-CdxEHiTTT3lXTDd0I2qLe7WfoYyDfWfVSkV5Suzs1&amp;t=634067491135766272\" alt=\"Collapse Book\" style=\"border-width:0;\" /></a></td><td style=\"white-space:nowrap;\"><a class=\"treeview1_0\" href=\"javascript:__doPostBack(&#39;treeview1&#39;,&#39;sBook&#39;)\" id=\"treeview1t0\">Book</a></td>\r\n\t\t</tr>\r\n\t</table><table cellpadding=\"0\" cellspacing=\"0\" style=\"border-width:0;\">\r\n\t\t<tr>\r\n\t\t\t<td><div style=\"width:20px;height:1px\"></div></td><td><a href=\"javascript:__doPostBack(&#39;treeview1&#39;,&#39;tBook\\\\Chapter&#39;)\"><img src=\"/NunitWeb/WebResource.axd?d=Me-CdxEHiTTT3lXTDd0I2qsyBHMcxXXKbUwruYE_9Mo1&amp;t=634067491135766272\" alt=\"Expand Chapter\" style=\"border-width:0;\" /></a></td><td style=\"white-space:nowrap;\"><a class=\"treeview1_0\" href=\"javascript:__doPostBack(&#39;treeview1&#39;,&#39;sBook\\\\Chapter&#39;)\" id=\"treeview1t1\">Chapter</a></td>\r\n\t\t</tr>\r\n\t</table><table cellpadding=\"0\" cellspacing=\"0\" style=\"border-width:0;\">\r\n\t\t<tr>\r\n\t\t\t<td><div style=\"width:20px;height:1px\"></div></td><td><a href=\"javascript:__doPostBack(&#39;treeview1&#39;,&#39;tBook\\\\Chapter&#39;)\"><img src=\"/NunitWeb/WebResource.axd?d=Me-CdxEHiTTT3lXTDd0I2qLe7WfoYyDfWfVSkV5Suzs1&amp;t=634067491135766272\" alt=\"Collapse Chapter\" style=\"border-width:0;\" /></a></td><td style=\"white-space:nowrap;\"><a class=\"treeview1_0\" href=\"javascript:__doPostBack(&#39;treeview1&#39;,&#39;sBook\\\\Chapter&#39;)\" id=\"treeview1t4\">Chapter</a></td>\r\n\t\t</tr>\r\n\t</table><table cellpadding=\"0\" cellspacing=\"0\" style=\"border-width:0;\">\r\n\t\t<tr>\r\n\t\t\t<td><div style=\"width:20px;height:1px\"></div></td><td><div style=\"width:20px;height:1px\"></div></td><td><img src=\"/NunitWeb/WebResource.axd?d=Me-CdxEHiTTT3lXTDd0I2ilpe6vhhhJjssENmbNkrSY1&amp;t=634067491135766272\" alt=\"\" /></td><td style=\"white-space:nowrap;\"><a class=\"treeview1_0\" href=\"javascript:__doPostBack(&#39;treeview1&#39;,&#39;sBook\\\\Chapter\\\\Section&#39;)\" id=\"treeview1t5\">Section</a></td>\r\n\t\t</tr>\r\n\t</table>\r\n</div><a id=\"treeview1_SkipLink\"></a>";
908 			#endregion
909 			string str = HtmlDiff.GetControlFromPageHtml (t.Run ());
910 			HtmlDiff.AssertAreEqual (strTarget, str, "NodeCollapseAll");
911 		}
pageLoadNodeCollapseAll(Page page)912 		public static void pageLoadNodeCollapseAll (Page page) {
913 			TreeView tv = new TreeView ();
914 			tv.EnableClientScript = false;
915 			tv.ID = "treeview1";
916 			XmlDataSource xmlds = new XmlDataSource ();
917 			xmlds.EnableCaching = false;
918 			xmlds.Data = xmlDataBind;
919 			tv.DataSource = xmlds;
920 			tv.DataBind ();
921 			tv.Nodes[0].ChildNodes[0].CollapseAll ();
922 			LiteralControl lcb = new LiteralControl (HtmlDiff.BEGIN_TAG);
923 			LiteralControl lce = new LiteralControl (HtmlDiff.END_TAG);
924 			page.Form.Controls.Add (lcb);
925 			page.Form.Controls.Add (tv);
926 			page.Form.Controls.Add (lce);
927 		}
928 
929 		[Test]
930 		[Category ("NunitWeb")]
TreeView_Method_NodeToggleExpandState1()931 		public void TreeView_Method_NodeToggleExpandState1 () {
932 			WebTest t = new WebTest (PageInvoker.CreateOnLoad (pageLoadNodeToggleExpandState1));
933 			#region HTML
934 			string strTarget = "<a href=\"#treeview1_SkipLink\"><img alt=\"Skip Navigation Links.\" src=\"/NunitWeb/WebResource.axd?d=8VpphgAbakKUC_J8R6hR0Q2&amp;t=634067491135766272\" width=\"0\" height=\"0\" style=\"border-width:0px;\" /></a><div id=\"treeview1\">\r\n\t<table cellpadding=\"0\" cellspacing=\"0\" style=\"border-width:0;\">\r\n\t\t<tr>\r\n\t\t\t<td><a href=\"javascript:__doPostBack(&#39;treeview1&#39;,&#39;tBook&#39;)\"><img src=\"/NunitWeb/WebResource.axd?d=Me-CdxEHiTTT3lXTDd0I2qLe7WfoYyDfWfVSkV5Suzs1&amp;t=634067491135766272\" alt=\"Collapse Book\" style=\"border-width:0;\" /></a></td><td style=\"white-space:nowrap;\"><a class=\"treeview1_0\" href=\"javascript:__doPostBack(&#39;treeview1&#39;,&#39;sBook&#39;)\" id=\"treeview1t0\">Book</a></td>\r\n\t\t</tr>\r\n\t</table><table cellpadding=\"0\" cellspacing=\"0\" style=\"border-width:0;\">\r\n\t\t<tr>\r\n\t\t\t<td><div style=\"width:20px;height:1px\"></div></td><td><a href=\"javascript:__doPostBack(&#39;treeview1&#39;,&#39;tBook\\\\Chapter&#39;)\"><img src=\"/NunitWeb/WebResource.axd?d=Me-CdxEHiTTT3lXTDd0I2qLe7WfoYyDfWfVSkV5Suzs1&amp;t=634067491135766272\" alt=\"Collapse Chapter\" style=\"border-width:0;\" /></a></td><td style=\"white-space:nowrap;\"><a class=\"treeview1_0\" href=\"javascript:__doPostBack(&#39;treeview1&#39;,&#39;sBook\\\\Chapter&#39;)\" id=\"treeview1t1\">Chapter</a></td>\r\n\t\t</tr>\r\n\t</table><table cellpadding=\"0\" cellspacing=\"0\" style=\"border-width:0;\">\r\n\t\t<tr>\r\n\t\t\t<td><div style=\"width:20px;height:1px\"></div></td><td><div style=\"width:20px;height:1px\"></div></td><td><img src=\"/NunitWeb/WebResource.axd?d=Me-CdxEHiTTT3lXTDd0I2ilpe6vhhhJjssENmbNkrSY1&amp;t=634067491135766272\" alt=\"\" /></td><td style=\"white-space:nowrap;\"><a class=\"treeview1_0\" href=\"javascript:__doPostBack(&#39;treeview1&#39;,&#39;sBook\\\\Chapter\\\\Section&#39;)\" id=\"treeview1t2\">Section</a></td>\r\n\t\t</tr>\r\n\t</table><table cellpadding=\"0\" cellspacing=\"0\" style=\"border-width:0;\">\r\n\t\t<tr>\r\n\t\t\t<td><div style=\"width:20px;height:1px\"></div></td><td><div style=\"width:20px;height:1px\"></div></td><td><img src=\"/NunitWeb/WebResource.axd?d=Me-CdxEHiTTT3lXTDd0I2ilpe6vhhhJjssENmbNkrSY1&amp;t=634067491135766272\" alt=\"\" /></td><td style=\"white-space:nowrap;\"><a class=\"treeview1_0\" href=\"javascript:__doPostBack(&#39;treeview1&#39;,&#39;sBook\\\\Chapter\\\\Section&#39;)\" id=\"treeview1t3\">Section</a></td>\r\n\t\t</tr>\r\n\t</table><table cellpadding=\"0\" cellspacing=\"0\" style=\"border-width:0;\">\r\n\t\t<tr>\r\n\t\t\t<td><div style=\"width:20px;height:1px\"></div></td><td><a href=\"javascript:__doPostBack(&#39;treeview1&#39;,&#39;tBook\\\\Chapter&#39;)\"><img src=\"/NunitWeb/WebResource.axd?d=Me-CdxEHiTTT3lXTDd0I2qsyBHMcxXXKbUwruYE_9Mo1&amp;t=634067491135766272\" alt=\"Expand Chapter\" style=\"border-width:0;\" /></a></td><td style=\"white-space:nowrap;\"><a class=\"treeview1_0\" href=\"javascript:__doPostBack(&#39;treeview1&#39;,&#39;sBook\\\\Chapter&#39;)\" id=\"treeview1t4\">Chapter</a></td>\r\n\t\t</tr>\r\n\t</table>\r\n</div><a id=\"treeview1_SkipLink\"></a>";
935 			#endregion
936 			string str = HtmlDiff.GetControlFromPageHtml (t.Run ());
937 			HtmlDiff.AssertAreEqual (strTarget, str, "NodeToggleExpandState1");
938 		}
pageLoadNodeToggleExpandState1(Page page)939 		public static void pageLoadNodeToggleExpandState1 (Page page) {
940 			TreeView tv = new TreeView ();
941 			tv.EnableClientScript = false;
942 			tv.ID = "treeview1";
943 			XmlDataSource xmlds = new XmlDataSource ();
944 			xmlds.EnableCaching = false;
945 			xmlds.Data = xmlDataBind;
946 			tv.DataSource = xmlds;
947 			tv.DataBind ();
948 			tv.ExpandAll ();
949 			tv.Nodes[0].ChildNodes[1].ToggleExpandState ();
950 			LiteralControl lcb = new LiteralControl (HtmlDiff.BEGIN_TAG);
951 			LiteralControl lce = new LiteralControl (HtmlDiff.END_TAG);
952 			page.Form.Controls.Add (lcb);
953 			page.Form.Controls.Add (tv);
954 			page.Form.Controls.Add (lce);
955 		}
956 		[Test]
957 		[Category ("NunitWeb")]
TreeView_Method_NodeToggleExpandState2()958 		public void TreeView_Method_NodeToggleExpandState2 () {
959 			WebTest t = new WebTest (PageInvoker.CreateOnLoad (pageLoadNodeToggleExpandState2));
960 			#region HTML
961 			string strTarget = "<a href=\"#treeview1_SkipLink\"><img alt=\"Skip Navigation Links.\" src=\"/NunitWeb/WebResource.axd?d=8VpphgAbakKUC_J8R6hR0Q2&amp;t=634067491135766272\" width=\"0\" height=\"0\" style=\"border-width:0px;\" /></a><div id=\"treeview1\">\r\n\t<table cellpadding=\"0\" cellspacing=\"0\" style=\"border-width:0;\">\r\n\t\t<tr>\r\n\t\t\t<td><a href=\"javascript:__doPostBack(&#39;treeview1&#39;,&#39;tBook&#39;)\"><img src=\"/NunitWeb/WebResource.axd?d=Me-CdxEHiTTT3lXTDd0I2qsyBHMcxXXKbUwruYE_9Mo1&amp;t=634067491135766272\" alt=\"Expand Book\" style=\"border-width:0;\" /></a></td><td style=\"white-space:nowrap;\"><a class=\"treeview1_0\" href=\"javascript:__doPostBack(&#39;treeview1&#39;,&#39;sBook&#39;)\" id=\"treeview1t0\">Book</a></td>\r\n\t\t</tr>\r\n\t</table>\r\n</div><a id=\"treeview1_SkipLink\"></a>";
962 			#endregion
963 			string str = HtmlDiff.GetControlFromPageHtml (t.Run ());
964 			HtmlDiff.AssertAreEqual (strTarget, str, "NodeToggleExpandState2");
965 		}
pageLoadNodeToggleExpandState2(Page page)966 		public static void pageLoadNodeToggleExpandState2 (Page page) {
967 			TreeView tv = new TreeView ();
968 			tv.EnableClientScript = false;
969 			tv.ID = "treeview1";
970 			XmlDataSource xmlds = new XmlDataSource ();
971 			xmlds.EnableCaching = false;
972 			xmlds.Data = xmlDataBind;
973 			tv.DataSource = xmlds;
974 			tv.DataBind ();
975 			tv.CollapseAll ();
976 			tv.Nodes [0].ChildNodes [0].ToggleExpandState ();
977 			LiteralControl lcb = new LiteralControl (HtmlDiff.BEGIN_TAG);
978 			LiteralControl lce = new LiteralControl (HtmlDiff.END_TAG);
979 			page.Form.Controls.Add (lcb);
980 			page.Form.Controls.Add (tv);
981 			page.Form.Controls.Add (lce);
982 		}
983 
984 		[Test]
985 		[Category ("NunitWeb")]
TreeView_PopulateNode()986 		public void TreeView_PopulateNode () {
987 			PageDelegates delegates = new PageDelegates ();
988 			delegates.Load = new PageDelegate (TreeView_PopulateNode_Load);
989 			delegates.PreRender = new PageDelegate (TreeView_PopulateNode_PreRender);
990 			delegates.PreRenderComplete = new PageDelegate (TreeView_PopulateNode_PreRenderComplete);
991 			PageInvoker invoker = new PageInvoker (delegates);
992 			WebTest test = new WebTest (invoker);
993 			test.Run ();
994 		}
995 
TreeView_PopulateNode_Load(Page page)996 		public static void TreeView_PopulateNode_Load (Page page) {
997 			TreeView tv = new TreeView ();
998 			tv.ID = "TreeView";
999 			tv.TreeNodePopulate += new TreeNodeEventHandler (tv_TreeNodePopulate);
1000 			tv.ExpandDepth = 3;
1001 			TreeNode rootNode = new TreeNode ("root");
1002 			rootNode.PopulateOnDemand = true;
1003 			tv.Nodes.Add (rootNode);
1004 			page.Form.Controls.Add (tv);
1005 
1006 			// root node still not populated
1007 			Assert.AreEqual (null, rootNode.Expanded, "TreeView_PopulateNode_Load#1");
1008 			Assert.AreEqual (0, rootNode.ChildNodes.Count, "TreeView_PopulateNode_Load#2");
1009 
1010 			// root node was populated after set Expanded=true
1011 			rootNode.Expanded = true;
1012 			Assert.AreEqual (1, rootNode.ChildNodes.Count, "TreeView_PopulateNode_Load#3");
1013 
1014 			// node1 was populated because was added with Expanded=true whan root was populated
1015 			Assert.AreEqual (true, rootNode.ChildNodes [0].Expanded, "TreeView_PopulateNode_Load#4");
1016 			Assert.AreEqual (1, rootNode.ChildNodes [0].ChildNodes.Count, "TreeView_PopulateNode_Load#5");
1017 
1018 			// node2 not populated because Expanded not set
1019 			Assert.AreEqual (null, rootNode.ChildNodes [0].ChildNodes [0].Expanded, "TreeView_PopulateNode_Load#6");
1020 			Assert.AreEqual (0, rootNode.ChildNodes [0].ChildNodes [0].ChildNodes.Count, "TreeView_PopulateNode_Load#7");
1021 		}
1022 
TreeView_PopulateNode_PreRender(Page page)1023 		public static void TreeView_PopulateNode_PreRender (Page page) {
1024 			TreeView tv = (TreeView) page.Form.FindControl ("TreeView");
1025 			TreeNode rootNode = tv.Nodes [0];
1026 
1027 			// state of nodes remain the same
1028 			// root
1029 			Assert.AreEqual (true, rootNode.Expanded, "TreeView_PopulateNode_PreRender#1");
1030 			Assert.AreEqual (1, rootNode.ChildNodes.Count, "TreeView_PopulateNode_PreRender#3");
1031 			// node1
1032 			Assert.AreEqual (true, rootNode.ChildNodes [0].Expanded, "TreeView_PopulateNode_PreRender#4");
1033 			Assert.AreEqual (1, rootNode.ChildNodes [0].ChildNodes.Count, "TreeView_PopulateNode_PreRender#5");
1034 			// node2
1035 			Assert.AreEqual (null, rootNode.ChildNodes [0].ChildNodes [0].Expanded, "TreeView_PopulateNode_PreRender#6");
1036 			Assert.AreEqual (0, rootNode.ChildNodes [0].ChildNodes [0].ChildNodes.Count, "TreeView_PopulateNode_PreRender#7");
1037 		}
1038 
TreeView_PopulateNode_PreRenderComplete(Page page)1039 		public static void TreeView_PopulateNode_PreRenderComplete (Page page) {
1040 			TreeView tv = (TreeView) page.Form.FindControl ("TreeView");
1041 			TreeNode rootNode = tv.Nodes [0];
1042 
1043 			// All nodes were expanded and populated up to ExpandDepth
1044 			// root
1045 			Assert.AreEqual (true, rootNode.Expanded, "TreeView_PopulateNode_PreRenderComplete#1");
1046 			Assert.AreEqual (1, rootNode.ChildNodes.Count, "TreeView_PopulateNode_PreRenderComplete#3");
1047 			// node1
1048 			Assert.AreEqual (true, rootNode.ChildNodes [0].Expanded, "TreeView_PopulateNode_PreRenderComplete#4");
1049 			Assert.AreEqual (1, rootNode.ChildNodes [0].ChildNodes.Count, "TreeView_PopulateNode_PreRenderComplete#5");
1050 			// node2
1051 			Assert.AreEqual (true, rootNode.ChildNodes [0].ChildNodes [0].Expanded, "TreeView_PopulateNode_PreRenderComplete#6");
1052 			Assert.AreEqual (1, rootNode.ChildNodes [0].ChildNodes [0].ChildNodes.Count, "TreeView_PopulateNode_PreRenderComplete#7");
1053 			// node3
1054 			Assert.AreEqual (null, rootNode.ChildNodes [0].ChildNodes [0].ChildNodes [0].Expanded, "TreeView_PopulateNode_PreRenderComplete#6");
1055 			Assert.AreEqual (0, rootNode.ChildNodes [0].ChildNodes [0].ChildNodes [0].ChildNodes.Count, "TreeView_PopulateNode_PreRenderComplete#7");
1056 		}
1057 
tv_TreeNodePopulate(object sender, TreeNodeEventArgs e)1058 		static void tv_TreeNodePopulate (object sender, TreeNodeEventArgs e) {
1059 			TreeNode node = new TreeNode ("node" + (e.Node.Depth + 1));
1060 			node.PopulateOnDemand = true;
1061 			if (e.Node.Depth < 1)
1062 				node.Expanded = true;
1063 			e.Node.ChildNodes.Add (node);
1064 		}
1065 
1066 		[Test]
1067 		[Category ("NunitWeb")]
TreeView_ExpandDepth()1068 		public void TreeView_ExpandDepth () {
1069 			PageDelegates delegates = new PageDelegates ();
1070 			delegates.Init = pageInitExpandDepth;
1071 			delegates.Load = pageLoadExpandDepth;
1072 			PageInvoker invoker = new PageInvoker (delegates);
1073 			WebTest t = new WebTest (invoker);
1074 			#region HTML
1075 			string strTarget = "<a href=\"#treeview1_SkipLink\"><img alt=\"Skip Navigation Links.\" src=\"/NunitWeb/WebResource.axd?d=8VpphgAbakKUC_J8R6hR0Q2&amp;t=634067491135766272\" width=\"0\" height=\"0\" style=\"border-width:0px;\" /></a><div id=\"treeview1\">\r\n\t<table cellpadding=\"0\" cellspacing=\"0\" style=\"border-width:0;\">\r\n\t\t<tr>\r\n\t\t\t<td><a href=\"javascript:__doPostBack(&#39;treeview1&#39;,&#39;tBook&#39;)\"><img src=\"/NunitWeb/WebResource.axd?d=Me-CdxEHiTTT3lXTDd0I2qLe7WfoYyDfWfVSkV5Suzs1&amp;t=634067491135766272\" alt=\"Collapse Book\" style=\"border-width:0;\" /></a></td><td style=\"white-space:nowrap;\"><a class=\"treeview1_0\" href=\"javascript:__doPostBack(&#39;treeview1&#39;,&#39;sBook&#39;)\" id=\"treeview1t0\">Book</a></td>\r\n\t\t</tr>\r\n\t</table><table cellpadding=\"0\" cellspacing=\"0\" style=\"border-width:0;\">\r\n\t\t<tr>\r\n\t\t\t<td><div style=\"width:20px;height:1px\"></div></td><td><a href=\"javascript:__doPostBack(&#39;treeview1&#39;,&#39;tBook\\\\Chapter&#39;)\"><img src=\"/NunitWeb/WebResource.axd?d=Me-CdxEHiTTT3lXTDd0I2qsyBHMcxXXKbUwruYE_9Mo1&amp;t=634067491135766272\" alt=\"Expand Chapter\" style=\"border-width:0;\" /></a></td><td style=\"white-space:nowrap;\"><a class=\"treeview1_0\" href=\"javascript:__doPostBack(&#39;treeview1&#39;,&#39;sBook\\\\Chapter&#39;)\" id=\"treeview1t1\">Chapter</a></td>\r\n\t\t</tr>\r\n\t</table><table cellpadding=\"0\" cellspacing=\"0\" style=\"border-width:0;\">\r\n\t\t<tr>\r\n\t\t\t<td><div style=\"width:20px;height:1px\"></div></td><td><a href=\"javascript:__doPostBack(&#39;treeview1&#39;,&#39;tBook\\\\Chapter&#39;)\"><img src=\"/NunitWeb/WebResource.axd?d=Me-CdxEHiTTT3lXTDd0I2qsyBHMcxXXKbUwruYE_9Mo1&amp;t=634067491135766272\" alt=\"Expand Chapter\" style=\"border-width:0;\" /></a></td><td style=\"white-space:nowrap;\"><a class=\"treeview1_0\" href=\"javascript:__doPostBack(&#39;treeview1&#39;,&#39;sBook\\\\Chapter&#39;)\" id=\"treeview1t4\">Chapter</a></td>\r\n\t\t</tr>\r\n\t</table>\r\n</div><a id=\"treeview1_SkipLink\"></a>";
1076 			#endregion
1077 			string str = HtmlDiff.GetControlFromPageHtml (t.Run ());
1078 			HtmlDiff.AssertAreEqual (strTarget, str, "NodeToggleExpandState2");
1079 		}
pageInitExpandDepth(Page page)1080 		public static void pageInitExpandDepth (Page page) {
1081 			TreeView tv = new TreeView ();
1082 			tv.EnableClientScript = false;
1083 			tv.ID = "treeview1";
1084 			tv.ExpandDepth = 1;
1085 			LiteralControl lcb = new LiteralControl (HtmlDiff.BEGIN_TAG);
1086 			LiteralControl lce = new LiteralControl (HtmlDiff.END_TAG);
1087 			page.Form.Controls.Add (lcb);
1088 			page.Form.Controls.Add (tv);
1089 			page.Form.Controls.Add (lce);
1090 		}
pageLoadExpandDepth(Page page)1091 		public static void pageLoadExpandDepth (Page page) {
1092 			TreeView tv = (TreeView)page.Form.FindControl("treeview1");
1093 			XmlDataSource xmlds = new XmlDataSource ();
1094 			xmlds.EnableCaching = false;
1095 			xmlds.Data = xmlDataBind;
1096 			tv.DataSource = xmlds;
1097 			tv.DataBind ();
1098 		}
1099 
1100 		[Test]
TreeView_Method_CreateControlCollection()1101 		public void TreeView_Method_CreateControlCollection () {
1102 			PokerTreeView tv = new PokerTreeView ();
1103 			ControlCollection cc = tv.CreateControlCollectionBase ();
1104 			Assert.AreEqual (0, cc.Count, "AfterCreateControlCollection");
1105 		}
1106 		[Test]
TreeView_Method_CreateNode()1107 		public void TreeView_Method_CreateNode () {
1108 			PokerTreeView tv = new PokerTreeView ();
1109 			TreeNode tn = tv.CreateNodeBase ();
1110 			Assert.AreEqual ("New Tree Node", tn.Text, "AfterCreateNode");
1111 		}
1112 
1113 		[Test]
TreeView_Method_PerformDataBinding()1114 		public void TreeView_Method_PerformDataBinding () {
1115 			PokerTreeView tv = new PokerTreeView ();
1116 			XmlDataSource xmlds = new XmlDataSource ();
1117 			xmlds.EnableCaching = false;
1118 			xmlds.Data = xmlDataBind;
1119 			tv.DataSource = xmlds;
1120 			Assert.AreEqual (0, tv.Nodes.Count, "BeforePerformDataBinding");
1121 			tv.PerformDataBindingBase ();
1122 			Assert.AreEqual (1, tv.Nodes.Count, "AfterPerformDataBinding-a");
1123 			Assert.AreEqual ("Book", tv.Nodes[0].Text, "AfterPerformDataBinding-b");
1124 			Assert.AreEqual (2, tv.Nodes[0].ChildNodes.Count, "AfterPerformDataBinding-c");
1125 		}
1126 
1127 		// Render Bindings
1128 		[Test]
1129 		[Category ("NunitWeb")]
TreeView_Render_Bindings()1130 		public void TreeView_Render_Bindings () {
1131 			WebTest t = new WebTest (PageInvoker.CreateOnLoad (pageLoadBindings));
1132 			#region HTML
1133 			string strTarget = "<a href=\"#treeview1_SkipLink\"><img alt=\"Skip Navigation Links.\" src=\"/NunitWeb/WebResource.axd?d=8VpphgAbakKUC_J8R6hR0Q2&amp;t=634067491135766272\" width=\"0\" height=\"0\" style=\"border-width:0px;\" /></a><div id=\"treeview1\">\r\n\t<table cellpadding=\"0\" cellspacing=\"0\" style=\"border-width:0;\">\r\n\t\t<tr>\r\n\t\t\t<td><a href=\"javascript:__doPostBack(&#39;treeview1&#39;,&#39;tBook Title&#39;)\"><img src=\"/NunitWeb/WebResource.axd?d=9M_pBQelEbwLdXyZk6p9TZbZQJ7rAlJ-YkXM8P7PpIM1&amp;t=634067491135766272\" alt=\"Collapse Book Title\" style=\"border-width:0;\" /></a></td><td style=\"white-space:nowrap;\"><a class=\"treeview1_0\" href=\"javascript:__doPostBack(&#39;treeview1&#39;,&#39;sBook Title&#39;)\" id=\"treeview1t0\">Book Title</a></td>\r\n\t\t</tr>\r\n\t</table><table cellpadding=\"0\" cellspacing=\"0\" style=\"border-width:0;\">\r\n\t\t<tr>\r\n\t\t\t<td><div style=\"width:20px;height:1px\"></div></td><td><img src=\"/NunitWeb/WebResource.axd?d=9M_pBQelEbwLdXyZk6p9TaTo2-lEuHkqGL9mwa70sVQ1&amp;t=634067491135766272\" alt=\"\" /></td><td style=\"white-space:nowrap;\"><a class=\"treeview1_0\" href=\"javascript:__doPostBack(&#39;treeview1&#39;,&#39;sBook Title\\\\Chapter 1&#39;)\" id=\"treeview1t1\">Chapter 1</a></td>\r\n\t\t</tr>\r\n\t</table><table cellpadding=\"0\" cellspacing=\"0\" style=\"border-width:0;\">\r\n\t\t<tr>\r\n\t\t\t<td><div style=\"width:20px;height:1px\"></div></td><td><img src=\"/NunitWeb/WebResource.axd?d=9M_pBQelEbwLdXyZk6p9TaTo2-lEuHkqGL9mwa70sVQ1&amp;t=634067491135766272\" alt=\"\" /></td><td style=\"white-space:nowrap;\"><a class=\"treeview1_0\" href=\"javascript:__doPostBack(&#39;treeview1&#39;,&#39;sBook Title\\\\Chapter 2&#39;)\" id=\"treeview1t2\">Chapter 2</a></td>\r\n\t\t</tr>\r\n\t</table>\r\n</div><a id=\"treeview1_SkipLink\"></a>";
1134 			#endregion
1135 			string str = HtmlDiff.GetControlFromPageHtml (t.Run ());
1136 			HtmlDiff.AssertAreEqual (strTarget, str, "RenderBindings");
1137 		}
pageLoadBindings(Page page)1138 		public static void pageLoadBindings (Page page) {
1139 			TreeView tv = new TreeView ();
1140 			tv.EnableClientScript = false;
1141 			tv.ID = "treeview1";
1142 			tv.ImageSet = TreeViewImageSet.Arrows;
1143 			tv.AutoGenerateDataBindings = false;
1144 			tv.MaxDataBindDepth = 1;
1145 			tv.DataBindings.Add (new TreeNodeBinding ());
1146 			tv.DataBindings[0].DataMember = "Book";
1147 			tv.DataBindings[0].TextField = "Title";
1148 			tv.DataBindings.Add (new TreeNodeBinding ());
1149 			tv.DataBindings[1].DataMember = "Chapter";
1150 			tv.DataBindings[1].TextField = "Heading";
1151 			tv.DataBindings.Add (new TreeNodeBinding ());
1152 			tv.DataBindings[2].DataMember = "Section";
1153 			tv.DataBindings[2].TextField = "Heading";
1154 			XmlDataSource xmlds = new XmlDataSource ();
1155 			xmlds.EnableCaching = false;
1156 			xmlds.Data = xmlDataBind;
1157 			tv.DataSource = xmlds;
1158 			tv.DataBind ();
1159 			LiteralControl lcb = new LiteralControl (HtmlDiff.BEGIN_TAG);
1160 			LiteralControl lce = new LiteralControl (HtmlDiff.END_TAG);
1161 			page.Form.Controls.Add (lcb);
1162 			page.Form.Controls.Add (tv);
1163 			page.Form.Controls.Add (lce);
1164 		}
1165 
1166 		// Render Navigate
1167 		[Test]
1168 		[Category ("NunitWeb")]
TreeView_Render_Navigate()1169 		public void TreeView_Render_Navigate () {
1170 			WebTest t = new WebTest (PageInvoker.CreateOnLoad (pageLoadNavigate));
1171 			#region HTML
1172 			string strTarget = "<a href=\"#treeview1_SkipLink\"><img alt=\"Skip Navigation Links.\" src=\"/NunitWeb/WebResource.axd?d=8VpphgAbakKUC_J8R6hR0Q2&amp;t=634067491135766272\" width=\"0\" height=\"0\" style=\"border-width:0px;\" /></a><div id=\"treeview1\">\r\n\t<table cellpadding=\"0\" cellspacing=\"0\" style=\"border-width:0;\">\r\n\t\t<tr>\r\n\t\t\t<td><a href=\"javascript:__doPostBack(&#39;treeview1&#39;,&#39;tmyNode0&#39;)\"><img src=\"/NunitWeb/WebResource.axd?d=Me-CdxEHiTTT3lXTDd0I2qLe7WfoYyDfWfVSkV5Suzs1&amp;t=634067491135766272\" alt=\"Collapse myNode0\" style=\"border-width:0;\" /></a></td><td style=\"white-space:nowrap;\"><a class=\"treeview1_0\" href=\"myUrl0\" target=\"myTarget\" id=\"treeview1t0\">myNode0</a></td>\r\n\t\t</tr>\r\n\t</table><table cellpadding=\"0\" cellspacing=\"0\" style=\"border-width:0;\">\r\n\t\t<tr>\r\n\t\t\t<td><div style=\"width:20px;height:1px\"></div></td><td><img src=\"/NunitWeb/WebResource.axd?d=Me-CdxEHiTTT3lXTDd0I2ilpe6vhhhJjssENmbNkrSY1&amp;t=634067491135766272\" alt=\"\" /></td><td style=\"white-space:nowrap;\"><a class=\"treeview1_0\" href=\"myUrl00\" target=\"myTarget\" id=\"treeview1t1\">myNode00</a></td>\r\n\t\t</tr>\r\n\t</table><table cellpadding=\"0\" cellspacing=\"0\" style=\"border-width:0;\">\r\n\t\t<tr>\r\n\t\t\t<td><img src=\"/NunitWeb/WebResource.axd?d=Me-CdxEHiTTT3lXTDd0I2ilpe6vhhhJjssENmbNkrSY1&amp;t=634067491135766272\" alt=\"\" /></td><td style=\"white-space:nowrap;\"><a class=\"treeview1_0\" href=\"myUrl1\" target=\"myTarget\" id=\"treeview1t2\">myNode1</a></td>\r\n\t\t</tr>\r\n\t</table>\r\n</div><a id=\"treeview1_SkipLink\"></a>";
1173 			#endregion
1174 			string str = HtmlDiff.GetControlFromPageHtml (t.Run ());
1175 			HtmlDiff.AssertAreEqual (strTarget, str, "RenderNavigate");
1176 		}
pageLoadNavigate(Page page)1177 		public static void pageLoadNavigate (Page page) {
1178 			TreeView tv = new TreeView ();
1179 			tv.EnableClientScript = false;
1180 			tv.ID = "treeview1";
1181 			tv.Target = "myTarget";
1182 			tv.Nodes.Add (new TreeNode ());
1183 			tv.Nodes[0].NavigateUrl = "myUrl0";
1184 			tv.Nodes[0].Text = "myNode0";
1185 			tv.Nodes[0].ChildNodes.Add (new TreeNode ());
1186 			tv.Nodes[0].ChildNodes[0].NavigateUrl = "myUrl00";
1187 			tv.Nodes[0].ChildNodes[0].Text = "myNode00";
1188 			tv.Nodes.Add (new TreeNode ());
1189 			tv.Nodes[1].NavigateUrl = "myUrl1";
1190 			tv.Nodes[1].Text = "myNode1";
1191 			LiteralControl lcb = new LiteralControl (HtmlDiff.BEGIN_TAG);
1192 			LiteralControl lce = new LiteralControl (HtmlDiff.END_TAG);
1193 			page.Form.Controls.Add (lcb);
1194 			page.Form.Controls.Add (tv);
1195 			page.Form.Controls.Add (lce);
1196 		}
1197 
1198 		// Render Checkboxes
1199 		[Test]
1200 		[Category ("NunitWeb")]
TreeView_Render_Checkboxes()1201 		public void TreeView_Render_Checkboxes () {
1202 			WebTest t = new WebTest (PageInvoker.CreateOnLoad (pageLoadCheckboxes));
1203 			#region HTML
1204 			string strTarget = "<a href=\"#treeview1_SkipLink\"><img alt=\"Skip Navigation Links.\" src=\"/NunitWeb/WebResource.axd?d=8VpphgAbakKUC_J8R6hR0Q2&amp;t=634067491135766272\" width=\"0\" height=\"0\" style=\"border-width:0px;\" /></a><div id=\"treeview1\">\r\n\t<table cellpadding=\"0\" cellspacing=\"0\" style=\"border-width:0;\">\r\n\t\t<tr>\r\n\t\t\t<td><a href=\"javascript:__doPostBack(&#39;treeview1&#39;,&#39;tBook&#39;)\"><img src=\"/NunitWeb/WebResource.axd?d=Me-CdxEHiTTT3lXTDd0I2qLe7WfoYyDfWfVSkV5Suzs1&amp;t=634067491135766272\" alt=\"Collapse Book\" style=\"border-width:0;\" /></a></td><td style=\"white-space:nowrap;\"><input type=\"checkbox\" name=\"treeview1n0CheckBox\" id=\"treeview1n0CheckBox\" /><a class=\"treeview1_0\" href=\"javascript:__doPostBack(&#39;treeview1&#39;,&#39;sBook&#39;)\" id=\"treeview1t0\">Book</a></td>\r\n\t\t</tr>\r\n\t</table><table cellpadding=\"0\" cellspacing=\"0\" style=\"border-width:0;\">\r\n\t\t<tr>\r\n\t\t\t<td><div style=\"width:20px;height:1px\"></div></td><td><a href=\"javascript:__doPostBack(&#39;treeview1&#39;,&#39;tBook\\\\Chapter&#39;)\"><img src=\"/NunitWeb/WebResource.axd?d=Me-CdxEHiTTT3lXTDd0I2qLe7WfoYyDfWfVSkV5Suzs1&amp;t=634067491135766272\" alt=\"Collapse Chapter\" style=\"border-width:0;\" /></a></td><td style=\"white-space:nowrap;\"><input type=\"checkbox\" name=\"treeview1n1CheckBox\" id=\"treeview1n1CheckBox\" /><a class=\"treeview1_0\" href=\"javascript:__doPostBack(&#39;treeview1&#39;,&#39;sBook\\\\Chapter&#39;)\" id=\"treeview1t1\">Chapter</a></td>\r\n\t\t</tr>\r\n\t</table><table cellpadding=\"0\" cellspacing=\"0\" style=\"border-width:0;\">\r\n\t\t<tr>\r\n\t\t\t<td><div style=\"width:20px;height:1px\"></div></td><td><div style=\"width:20px;height:1px\"></div></td><td><img src=\"/NunitWeb/WebResource.axd?d=Me-CdxEHiTTT3lXTDd0I2ilpe6vhhhJjssENmbNkrSY1&amp;t=634067491135766272\" alt=\"\" /></td><td style=\"white-space:nowrap;\"><input type=\"checkbox\" name=\"treeview1n2CheckBox\" id=\"treeview1n2CheckBox\" /><a class=\"treeview1_0\" href=\"javascript:__doPostBack(&#39;treeview1&#39;,&#39;sBook\\\\Chapter\\\\Section&#39;)\" id=\"treeview1t2\">Section</a></td>\r\n\t\t</tr>\r\n\t</table><table cellpadding=\"0\" cellspacing=\"0\" style=\"border-width:0;\">\r\n\t\t<tr>\r\n\t\t\t<td><div style=\"width:20px;height:1px\"></div></td><td><div style=\"width:20px;height:1px\"></div></td><td><img src=\"/NunitWeb/WebResource.axd?d=Me-CdxEHiTTT3lXTDd0I2ilpe6vhhhJjssENmbNkrSY1&amp;t=634067491135766272\" alt=\"\" /></td><td style=\"white-space:nowrap;\"><input type=\"checkbox\" name=\"treeview1n3CheckBox\" id=\"treeview1n3CheckBox\" /><a class=\"treeview1_0\" href=\"javascript:__doPostBack(&#39;treeview1&#39;,&#39;sBook\\\\Chapter\\\\Section&#39;)\" id=\"treeview1t3\">Section</a></td>\r\n\t\t</tr>\r\n\t</table><table cellpadding=\"0\" cellspacing=\"0\" style=\"border-width:0;\">\r\n\t\t<tr>\r\n\t\t\t<td><div style=\"width:20px;height:1px\"></div></td><td><a href=\"javascript:__doPostBack(&#39;treeview1&#39;,&#39;tBook\\\\Chapter&#39;)\"><img src=\"/NunitWeb/WebResource.axd?d=Me-CdxEHiTTT3lXTDd0I2qLe7WfoYyDfWfVSkV5Suzs1&amp;t=634067491135766272\" alt=\"Collapse Chapter\" style=\"border-width:0;\" /></a></td><td style=\"white-space:nowrap;\"><input type=\"checkbox\" name=\"treeview1n4CheckBox\" id=\"treeview1n4CheckBox\" /><a class=\"treeview1_0\" href=\"javascript:__doPostBack(&#39;treeview1&#39;,&#39;sBook\\\\Chapter&#39;)\" id=\"treeview1t4\">Chapter</a></td>\r\n\t\t</tr>\r\n\t</table><table cellpadding=\"0\" cellspacing=\"0\" style=\"border-width:0;\">\r\n\t\t<tr>\r\n\t\t\t<td><div style=\"width:20px;height:1px\"></div></td><td><div style=\"width:20px;height:1px\"></div></td><td><img src=\"/NunitWeb/WebResource.axd?d=Me-CdxEHiTTT3lXTDd0I2ilpe6vhhhJjssENmbNkrSY1&amp;t=634067491135766272\" alt=\"\" /></td><td style=\"white-space:nowrap;\"><input type=\"checkbox\" name=\"treeview1n5CheckBox\" id=\"treeview1n5CheckBox\" /><a class=\"treeview1_0\" href=\"javascript:__doPostBack(&#39;treeview1&#39;,&#39;sBook\\\\Chapter\\\\Section&#39;)\" id=\"treeview1t5\">Section</a></td>\r\n\t\t</tr>\r\n\t</table>\r\n</div><a id=\"treeview1_SkipLink\"></a>";
1205 			#endregion
1206 			string str = HtmlDiff.GetControlFromPageHtml (t.Run ());
1207 			HtmlDiff.AssertAreEqual (strTarget, str, "RenderCheckboxes");
1208 		}
pageLoadCheckboxes(Page page)1209 		public static void pageLoadCheckboxes (Page page) {
1210 			TreeView tv = new TreeView ();
1211 			tv.EnableClientScript = false;
1212 			tv.ID = "treeview1";
1213 			tv.ShowCheckBoxes = TreeNodeTypes.All;
1214 			XmlDataSource xmlds = new XmlDataSource ();
1215 			xmlds.EnableCaching = false;
1216 			xmlds.Data = xmlDataBind;
1217 			tv.DataSource = xmlds;
1218 			tv.DataBind ();
1219 			LiteralControl lcb = new LiteralControl (HtmlDiff.BEGIN_TAG);
1220 			LiteralControl lce = new LiteralControl (HtmlDiff.END_TAG);
1221 			page.Form.Controls.Add (lcb);
1222 			page.Form.Controls.Add (tv);
1223 			page.Form.Controls.Add (lce);
1224 		}
1225 
1226 		// Render Values
1227 		[Test]
1228 		[Category ("NunitWeb")]
TreeView_Render_Values()1229 		public void TreeView_Render_Values () {
1230 			WebTest t = new WebTest (PageInvoker.CreateOnLoad (pageLoadValues));
1231 			#region HTML
1232 			string strTarget = "<a href=\"#treeview1_SkipLink\"><img alt=\"mySkipLinkText\" src=\"/NunitWeb/WebResource.axd?d=8VpphgAbakKUC_J8R6hR0Q2&amp;t=634067491135766272\" width=\"0\" height=\"0\" style=\"border-width:0px;\" /></a><div id=\"treeview1\">\r\n\t<table cellpadding=\"0\" cellspacing=\"0\" style=\"border-width:0;\">\r\n\t\t<tr>\r\n\t\t\t<td><a href=\"javascript:__doPostBack(&#39;treeview1&#39;,&#39;tBook&#39;)\"><img src=\"/NunitWeb/WebResource.axd?d=9M_pBQelEbwLdXyZk6p9TZbZQJ7rAlJ-YkXM8P7PpIM1&amp;t=634067491135766272\" alt=\"Collapse Book\" style=\"border-width:0;\" /></a></td><td style=\"white-space:nowrap;\"><a class=\"treeview1_0\" href=\"javascript:__doPostBack(&#39;treeview1&#39;,&#39;sBook&#39;)\" id=\"treeview1t0\">Book</a></td>\r\n\t\t</tr>\r\n\t</table><table cellpadding=\"0\" cellspacing=\"0\" style=\"border-width:0;\">\r\n\t\t<tr>\r\n\t\t\t<td><div style=\"width:30px;height:1px\"></div></td><td><a href=\"javascript:__doPostBack(&#39;treeview1&#39;,&#39;tBook\\\\Chapter&#39;)\"><img src=\"/NunitWeb/WebResource.axd?d=9M_pBQelEbwLdXyZk6p9TZbZQJ7rAlJ-YkXM8P7PpIM1&amp;t=634067491135766272\" alt=\"Collapse Chapter\" style=\"border-width:0;\" /></a></td><td style=\"white-space:nowrap;\"><a class=\"treeview1_0\" href=\"javascript:__doPostBack(&#39;treeview1&#39;,&#39;sBook\\\\Chapter&#39;)\" id=\"treeview1t1\">Chapter</a></td>\r\n\t\t</tr>\r\n\t</table><table cellpadding=\"0\" cellspacing=\"0\" style=\"border-width:0;\">\r\n\t\t<tr>\r\n\t\t\t<td><div style=\"width:30px;height:1px\"></div></td><td><div style=\"width:30px;height:1px\"></div></td><td><img src=\"/NunitWeb/WebResource.axd?d=9M_pBQelEbwLdXyZk6p9TaTo2-lEuHkqGL9mwa70sVQ1&amp;t=634067491135766272\" alt=\"\" /></td><td style=\"white-space:nowrap;\"><a class=\"treeview1_0\" href=\"javascript:__doPostBack(&#39;treeview1&#39;,&#39;sBook\\\\Chapter\\\\Section&#39;)\" id=\"treeview1t2\">Section</a></td>\r\n\t\t</tr>\r\n\t</table><table cellpadding=\"0\" cellspacing=\"0\" style=\"border-width:0;\">\r\n\t\t<tr>\r\n\t\t\t<td><div style=\"width:30px;height:1px\"></div></td><td><div style=\"width:30px;height:1px\"></div></td><td><img src=\"/NunitWeb/WebResource.axd?d=9M_pBQelEbwLdXyZk6p9TaTo2-lEuHkqGL9mwa70sVQ1&amp;t=634067491135766272\" alt=\"\" /></td><td style=\"white-space:nowrap;\"><a class=\"treeview1_0\" href=\"javascript:__doPostBack(&#39;treeview1&#39;,&#39;sBook\\\\Chapter\\\\Section&#39;)\" id=\"treeview1t3\">Section</a></td>\r\n\t\t</tr>\r\n\t</table><table cellpadding=\"0\" cellspacing=\"0\" style=\"border-width:0;\">\r\n\t\t<tr>\r\n\t\t\t<td><div style=\"width:30px;height:1px\"></div></td><td><a href=\"javascript:__doPostBack(&#39;treeview1&#39;,&#39;tBook\\\\Chapter&#39;)\"><img src=\"/NunitWeb/WebResource.axd?d=9M_pBQelEbwLdXyZk6p9TZbZQJ7rAlJ-YkXM8P7PpIM1&amp;t=634067491135766272\" alt=\"Collapse Chapter\" style=\"border-width:0;\" /></a></td><td style=\"white-space:nowrap;\"><a class=\"treeview1_0\" href=\"javascript:__doPostBack(&#39;treeview1&#39;,&#39;sBook\\\\Chapter&#39;)\" id=\"treeview1t4\">Chapter</a></td>\r\n\t\t</tr>\r\n\t</table><table cellpadding=\"0\" cellspacing=\"0\" style=\"border-width:0;\">\r\n\t\t<tr>\r\n\t\t\t<td><div style=\"width:30px;height:1px\"></div></td><td><div style=\"width:30px;height:1px\"></div></td><td><img src=\"/NunitWeb/WebResource.axd?d=9M_pBQelEbwLdXyZk6p9TaTo2-lEuHkqGL9mwa70sVQ1&amp;t=634067491135766272\" alt=\"\" /></td><td style=\"white-space:nowrap;\"><a class=\"treeview1_0\" href=\"javascript:__doPostBack(&#39;treeview1&#39;,&#39;sBook\\\\Chapter\\\\Section&#39;)\" id=\"treeview1t5\">Section</a></td>\r\n\t\t</tr>\r\n\t</table>\r\n</div><a id=\"treeview1_SkipLink\"></a>";
1233 			#endregion
1234 			string str = HtmlDiff.GetControlFromPageHtml (t.Run ());
1235 			HtmlDiff.AssertAreEqual (strTarget, str, "RenderValues");
1236 		}
pageLoadValues(Page page)1237 		public static void pageLoadValues (Page page) {
1238 			TreeView tv = new TreeView ();
1239 			tv.EnableClientScript = false;
1240 			tv.ID = "treeview1";
1241 			tv.ImageSet = TreeViewImageSet.Arrows;
1242 			tv.SkipLinkText = "mySkipLinkText";
1243 			tv.NodeIndent = 30;
1244 			tv.ExpandDepth = 3;
1245 			XmlDataSource xmlds = new XmlDataSource ();
1246 			xmlds.EnableCaching = false;
1247 			xmlds.Data = xmlDataBind;
1248 			tv.DataSource = xmlds;
1249 			tv.DataBind ();
1250 			LiteralControl lcb = new LiteralControl (HtmlDiff.BEGIN_TAG);
1251 			LiteralControl lce = new LiteralControl (HtmlDiff.END_TAG);
1252 			page.Form.Controls.Add (lcb);
1253 			page.Form.Controls.Add (tv);
1254 			page.Form.Controls.Add (lce);
1255 		}
1256 
1257 		// Render Images
1258 		[Test]
1259 		[Category ("NunitWeb")]
TreeView_Render_ImagesOn()1260 		public void TreeView_Render_ImagesOn () {
1261 			WebTest t = new WebTest (PageInvoker.CreateOnLoad (pageLoadImagesOn));
1262 			#region HTML
1263 			string strTarget = "<a href=\"#treeview1_SkipLink\"><img alt=\"Skip Navigation Links.\" src=\"/NunitWeb/WebResource.axd?d=8VpphgAbakKUC_J8R6hR0Q2&amp;t=634067491135766272\" width=\"0\" height=\"0\" style=\"border-width:0px;\" /></a><div id=\"treeview1\">\r\n\t<table cellpadding=\"0\" cellspacing=\"0\" style=\"border-width:0;\">\r\n\t\t<tr>\r\n\t\t\t<td><a href=\"javascript:__doPostBack(&#39;treeview1&#39;,&#39;tBook&#39;)\"><img src=\"Test666/dashminus.gif\" alt=\"Test111\" style=\"border-width:0;\" /></a></td><td style=\"white-space:nowrap;\"><a class=\"treeview1_0\" href=\"javascript:__doPostBack(&#39;treeview1&#39;,&#39;sBook&#39;)\" id=\"treeview1t0\">Book</a></td>\r\n\t\t</tr>\r\n\t</table><table cellpadding=\"0\" cellspacing=\"0\" style=\"border-width:0;\">\r\n\t\t<tr>\r\n\t\t\t<td><div style=\"width:20px;height:1px\"></div></td><td><a href=\"javascript:__doPostBack(&#39;treeview1&#39;,&#39;tBook\\\\Chapter&#39;)\"><img src=\"Test666/tminus.gif\" alt=\"Test111\" style=\"border-width:0;\" /></a></td><td style=\"white-space:nowrap;\"><a class=\"treeview1_0\" href=\"javascript:__doPostBack(&#39;treeview1&#39;,&#39;sBook\\\\Chapter&#39;)\" id=\"treeview1t1\">Chapter</a></td>\r\n\t\t</tr>\r\n\t</table><table cellpadding=\"0\" cellspacing=\"0\" style=\"border-width:0;\">\r\n\t\t<tr>\r\n\t\t\t<td><div style=\"width:20px;height:1px\"></div></td><td><div style=\"width:20px;height:1px\"><img src=\"Test666/i.gif\" alt=\"\" /></div></td><td><img src=\"Test666/t.gif\" alt=\"\" /></td><td style=\"white-space:nowrap;\"><a class=\"treeview1_0\" href=\"javascript:__doPostBack(&#39;treeview1&#39;,&#39;sBook\\\\Chapter\\\\Section&#39;)\" id=\"treeview1t2\">Section</a></td>\r\n\t\t</tr>\r\n\t</table><table cellpadding=\"0\" cellspacing=\"0\" style=\"border-width:0;\">\r\n\t\t<tr>\r\n\t\t\t<td><div style=\"width:20px;height:1px\"></div></td><td><div style=\"width:20px;height:1px\"><img src=\"Test666/i.gif\" alt=\"\" /></div></td><td><img src=\"Test666/l.gif\" alt=\"\" /></td><td style=\"white-space:nowrap;\"><a class=\"treeview1_0\" href=\"javascript:__doPostBack(&#39;treeview1&#39;,&#39;sBook\\\\Chapter\\\\Section&#39;)\" id=\"treeview1t3\">Section</a></td>\r\n\t\t</tr>\r\n\t</table><table cellpadding=\"0\" cellspacing=\"0\" style=\"border-width:0;\">\r\n\t\t<tr>\r\n\t\t\t<td><div style=\"width:20px;height:1px\"></div></td><td><a href=\"javascript:__doPostBack(&#39;treeview1&#39;,&#39;tBook\\\\Chapter&#39;)\"><img src=\"Test666/lminus.gif\" alt=\"Test111\" style=\"border-width:0;\" /></a></td><td style=\"white-space:nowrap;\"><a class=\"treeview1_0\" href=\"javascript:__doPostBack(&#39;treeview1&#39;,&#39;sBook\\\\Chapter&#39;)\" id=\"treeview1t4\">Chapter</a></td>\r\n\t\t</tr>\r\n\t</table><table cellpadding=\"0\" cellspacing=\"0\" style=\"border-width:0;\">\r\n\t\t<tr>\r\n\t\t\t<td><div style=\"width:20px;height:1px\"></div></td><td><div style=\"width:20px;height:1px\"></div></td><td><img src=\"Test666/l.gif\" alt=\"\" /></td><td style=\"white-space:nowrap;\"><a class=\"treeview1_0\" href=\"javascript:__doPostBack(&#39;treeview1&#39;,&#39;sBook\\\\Chapter\\\\Section&#39;)\" id=\"treeview1t5\">Section</a></td>\r\n\t\t</tr>\r\n\t</table>\r\n</div><a id=\"treeview1_SkipLink\"></a>";
1264 			#endregion
1265 			string str = HtmlDiff.GetControlFromPageHtml (t.Run ());
1266 			HtmlDiff.AssertAreEqual (strTarget, str, "RenderImagesOn");
1267 		}
1268 		[Test]
1269 		[Category ("NunitWeb")]
TreeView_Render_ImagesOff()1270 		public void TreeView_Render_ImagesOff () {
1271 			WebTest t = new WebTest (PageInvoker.CreateOnLoad (pageLoadImagesOff));
1272 			#region HTML
1273 			string strTarget = "<a href=\"#treeview1_SkipLink\"><img alt=\"Skip Navigation Links.\" src=\"/NunitWeb/WebResource.axd?d=8VpphgAbakKUC_J8R6hR0Q2&amp;t=634067491135766272\" width=\"0\" height=\"0\" style=\"border-width:0px;\" /></a><div id=\"treeview1\">\r\n\t<table cellpadding=\"0\" cellspacing=\"0\" style=\"border-width:0;\">\r\n\t\t<tr>\r\n\t\t\t<td style=\"white-space:nowrap;\"><a class=\"treeview1_0\" href=\"javascript:__doPostBack(&#39;treeview1&#39;,&#39;sBook&#39;)\" id=\"treeview1n0\">Book</a></td>\r\n\t\t</tr>\r\n\t</table><table cellpadding=\"0\" cellspacing=\"0\" style=\"border-width:0;\">\r\n\t\t<tr>\r\n\t\t\t<td><div style=\"width:20px;height:1px\"></div></td><td style=\"white-space:nowrap;\"><a class=\"treeview1_0\" href=\"javascript:__doPostBack(&#39;treeview1&#39;,&#39;sBook\\\\Chapter&#39;)\" id=\"treeview1n1\">Chapter</a></td>\r\n\t\t</tr>\r\n\t</table><table cellpadding=\"0\" cellspacing=\"0\" style=\"border-width:0;\">\r\n\t\t<tr>\r\n\t\t\t<td><div style=\"width:20px;height:1px\"></div></td><td><div style=\"width:20px;height:1px\"></div></td><td style=\"white-space:nowrap;\"><a class=\"treeview1_0\" href=\"javascript:__doPostBack(&#39;treeview1&#39;,&#39;sBook\\\\Chapter\\\\Section&#39;)\" id=\"treeview1n2\">Section</a></td>\r\n\t\t</tr>\r\n\t</table><table cellpadding=\"0\" cellspacing=\"0\" style=\"border-width:0;\">\r\n\t\t<tr>\r\n\t\t\t<td><div style=\"width:20px;height:1px\"></div></td><td><div style=\"width:20px;height:1px\"></div></td><td style=\"white-space:nowrap;\"><a class=\"treeview1_0\" href=\"javascript:__doPostBack(&#39;treeview1&#39;,&#39;sBook\\\\Chapter\\\\Section&#39;)\" id=\"treeview1n3\">Section</a></td>\r\n\t\t</tr>\r\n\t</table><table cellpadding=\"0\" cellspacing=\"0\" style=\"border-width:0;\">\r\n\t\t<tr>\r\n\t\t\t<td><div style=\"width:20px;height:1px\"></div></td><td style=\"white-space:nowrap;\"><a class=\"treeview1_0\" href=\"javascript:__doPostBack(&#39;treeview1&#39;,&#39;sBook\\\\Chapter&#39;)\" id=\"treeview1n4\">Chapter</a></td>\r\n\t\t</tr>\r\n\t</table><table cellpadding=\"0\" cellspacing=\"0\" style=\"border-width:0;\">\r\n\t\t<tr>\r\n\t\t\t<td><div style=\"width:20px;height:1px\"></div></td><td><div style=\"width:20px;height:1px\"></div></td><td style=\"white-space:nowrap;\"><a class=\"treeview1_0\" href=\"javascript:__doPostBack(&#39;treeview1&#39;,&#39;sBook\\\\Chapter\\\\Section&#39;)\" id=\"treeview1n5\">Section</a></td>\r\n\t\t</tr>\r\n\t</table>\r\n</div><a id=\"treeview1_SkipLink\"></a>";
1274 			#endregion
1275 			string str = HtmlDiff.GetControlFromPageHtml (t.Run ());
1276 			HtmlDiff.AssertAreEqual (strTarget, str, "RenderImagesOff");
1277 		}
pageLoadImagesOn(Page page)1278 		public static void pageLoadImagesOn (Page page) {
1279 			TreeView tv = new TreeView ();
1280 			tv.EnableClientScript = false;
1281 			tv.ID = "treeview1";
1282 			tv.CollapseImageToolTip = "Test111";
1283 			tv.ExpandImageToolTip = "Test222";
1284 			tv.CollapseImageUrl = "Test333";
1285 			tv.ExpandImageUrl = "Test444";
1286 			tv.NoExpandImageUrl = "Test555";
1287 			tv.LineImagesFolder = "Test666";
1288 			tv.ShowLines = true;
1289 			tv.ShowExpandCollapse = true;
1290 			tv.ImageSet = TreeViewImageSet.Custom;
1291 			XmlDataSource xmlds = new XmlDataSource ();
1292 			xmlds.EnableCaching = false;
1293 			xmlds.Data = xmlDataBind;
1294 			tv.DataSource = xmlds;
1295 			tv.DataBind ();
1296 			LiteralControl lcb = new LiteralControl (HtmlDiff.BEGIN_TAG);
1297 			LiteralControl lce = new LiteralControl (HtmlDiff.END_TAG);
1298 			page.Form.Controls.Add (lcb);
1299 			page.Form.Controls.Add (tv);
1300 			page.Form.Controls.Add (lce);
1301 		}
pageLoadImagesOff(Page page)1302 		public static void pageLoadImagesOff (Page page) {
1303 			TreeView tv = new TreeView ();
1304 			tv.EnableClientScript = false;
1305 			tv.ID = "treeview1";
1306 			tv.ShowLines = false;
1307 			tv.ShowExpandCollapse = false;
1308 			XmlDataSource xmlds = new XmlDataSource ();
1309 			xmlds.EnableCaching = false;
1310 			xmlds.Data = xmlDataBind;
1311 			tv.DataSource = xmlds;
1312 			tv.DataBind ();
1313 			LiteralControl lcb = new LiteralControl (HtmlDiff.BEGIN_TAG);
1314 			LiteralControl lce = new LiteralControl (HtmlDiff.END_TAG);
1315 			page.Form.Controls.Add (lcb);
1316 			page.Form.Controls.Add (tv);
1317 			page.Form.Controls.Add (lce);
1318 		}
1319 
1320 		//Render Wrap
1321 		[Test]
1322 		[Category ("NunitWeb")]
TreeView_Render_WrapOn()1323 		public void TreeView_Render_WrapOn () {
1324 			WebTest t = new WebTest (PageInvoker.CreateOnLoad (pageLoadWrapOn));
1325 			string strTarget = "<a href=\"#treeview1_SkipLink\"><img alt=\"Skip Navigation Links.\" src=\"/NunitWeb/WebResource.axd?d=8VpphgAbakKUC_J8R6hR0Q2&amp;t=634067491135766272\" width=\"0\" height=\"0\" style=\"border-width:0px;\" /></a><div id=\"treeview1\">\r\n\t<table cellpadding=\"0\" cellspacing=\"0\" style=\"border-width:0;\">\r\n\t\t<tr>\r\n\t\t\t<td><img src=\"/NunitWeb/WebResource.axd?d=Me-CdxEHiTTT3lXTDd0I2ilpe6vhhhJjssENmbNkrSY1&amp;t=634067491135766272\" alt=\"\" /></td><td><a class=\"treeview1_0\" href=\"javascript:__doPostBack(&#39;treeview1&#39;,&#39;sTreeNode1&#39;)\" onclick=\"TreeView_SelectNode(treeview1_Data, this,&#39;treeview1t0&#39;);\" id=\"treeview1t0\">TreeNode1</a></td>\r\n\t\t</tr>\r\n\t</table>\r\n</div><a id=\"treeview1_SkipLink\"></a>";
1326 			string str = HtmlDiff.GetControlFromPageHtml (t.Run ());
1327 			HtmlDiff.AssertAreEqual (strTarget, str, "RenderWrapOn");
1328 		}
1329 		[Test]
1330 		[Category ("NunitWeb")]
TreeView_Render_WrapOff()1331 		public void TreeView_Render_WrapOff () {
1332 			WebTest t = new WebTest (PageInvoker.CreateOnLoad (pageLoadWrapOff));
1333 			string strTarget = "<a href=\"#treeview1_SkipLink\"><img alt=\"Skip Navigation Links.\" src=\"/NunitWeb/WebResource.axd?d=8VpphgAbakKUC_J8R6hR0Q2&amp;t=634067491135766272\" width=\"0\" height=\"0\" style=\"border-width:0px;\" /></a><div id=\"treeview1\">\r\n\t<table cellpadding=\"0\" cellspacing=\"0\" style=\"border-width:0;\">\r\n\t\t<tr>\r\n\t\t\t<td><img src=\"/NunitWeb/WebResource.axd?d=Me-CdxEHiTTT3lXTDd0I2ilpe6vhhhJjssENmbNkrSY1&amp;t=634067491135766272\" alt=\"\" /></td><td style=\"white-space:nowrap;\"><a class=\"treeview1_0\" href=\"javascript:__doPostBack(&#39;treeview1&#39;,&#39;sTreeNode1&#39;)\" onclick=\"TreeView_SelectNode(treeview1_Data, this,&#39;treeview1t0&#39;);\" id=\"treeview1t0\">TreeNode1</a></td>\r\n\t\t</tr>\r\n\t</table>\r\n</div><a id=\"treeview1_SkipLink\"></a>";
1334 			string str = HtmlDiff.GetControlFromPageHtml (t.Run ());
1335 			HtmlDiff.AssertAreEqual (strTarget, str, "RenderWrapOff");
1336 		}
pageLoadWrapOn(Page page)1337 		public static void pageLoadWrapOn (Page page) {
1338 			TreeView tv = new TreeView ();
1339 			tv.ID = "treeview1";
1340 			tv.NodeWrap = true;
1341 			tv.Nodes.Add (new TreeNode ("TreeNode1"));
1342 			tv.DataBind ();
1343 			LiteralControl lcb = new LiteralControl (HtmlDiff.BEGIN_TAG);
1344 			LiteralControl lce = new LiteralControl (HtmlDiff.END_TAG);
1345 			page.Form.Controls.Add (lcb);
1346 			page.Form.Controls.Add (tv);
1347 			page.Form.Controls.Add (lce);
1348 		}
pageLoadWrapOff(Page page)1349 		public static void pageLoadWrapOff (Page page) {
1350 			TreeView tv = new TreeView ();
1351 			tv.ID = "treeview1";
1352 			tv.NodeWrap = false;
1353 			tv.Nodes.Add (new TreeNode ("TreeNode1"));
1354 			tv.DataBind ();
1355 			LiteralControl lcb = new LiteralControl (HtmlDiff.BEGIN_TAG);
1356 			LiteralControl lce = new LiteralControl (HtmlDiff.END_TAG);
1357 			page.Form.Controls.Add (lcb);
1358 			page.Form.Controls.Add (tv);
1359 			page.Form.Controls.Add (lce);
1360 		}
1361 
1362 		// Render Client
1363 		[Test]
1364 		[Category ("NunitWeb")]
TreeView_Render_Client()1365 		public void TreeView_Render_Client () {
1366 			WebTest t = new WebTest (PageInvoker.CreateOnLoad (pageLoadClient));
1367 			string strTarget = "<a href=\"#treeview1_SkipLink\"><img alt=\"Skip Navigation Links.\" src=\"/NunitWeb/WebResource.axd?d=8VpphgAbakKUC_J8R6hR0Q2&amp;t=634067491135766272\" width=\"0\" height=\"0\" style=\"border-width:0px;\" /></a><div id=\"treeview1\">\r\n\r\n</div><a id=\"treeview1_SkipLink\"></a>";
1368 			string str = HtmlDiff.GetControlFromPageHtml (t.Run ());
1369 			HtmlDiff.AssertAreEqual (strTarget, str, "RenderClient");
1370 		}
pageLoadClient(Page page)1371 		public static void pageLoadClient (Page page) {
1372 			TreeView tv = new TreeView ();
1373 			tv.ID = "treeview1";
1374 			tv.EnableClientScript = false;
1375 			tv.PopulateNodesFromClient = false;
1376 			LiteralControl lcb = new LiteralControl (HtmlDiff.BEGIN_TAG);
1377 			LiteralControl lce = new LiteralControl (HtmlDiff.END_TAG);
1378 			page.Form.Controls.Add (lcb);
1379 			page.Form.Controls.Add (tv);
1380 			page.Form.Controls.Add (lce);
1381 		}
1382 
1383 		//Render Invisible
1384 		[Test]
1385 		[Category ("NunitWeb")]
TreeView_Render_Invisible()1386 		public void TreeView_Render_Invisible () {
1387 			WebTest t = new WebTest (PageInvoker.CreateOnLoad (pageLoadInvisible));
1388 			string strTarget = "";
1389 			string str = HtmlDiff.GetControlFromPageHtml (t.Run ());
1390 			Assert.AreEqual (strTarget, str, "RenderInvisible");
1391 		}
pageLoadInvisible(Page page)1392 		public static void pageLoadInvisible (Page page) {
1393 			TreeView tv = new TreeView ();
1394 			tv.ID = "treeview1";
1395 			tv.Visible = false;
1396 			XmlDataSource xmlds = new XmlDataSource ();
1397 			xmlds.EnableCaching = false;
1398 			xmlds.Data = xmlDataBindSmall;
1399 			tv.DataSource = xmlds;
1400 			tv.DataBind ();
1401 			LiteralControl lcb = new LiteralControl (HtmlDiff.BEGIN_TAG);
1402 			LiteralControl lce = new LiteralControl (HtmlDiff.END_TAG);
1403 			page.Form.Controls.Add (lcb);
1404 			page.Form.Controls.Add (tv);
1405 			page.Form.Controls.Add (lce);
1406 		}
1407 
1408 		//Render Node Strings
1409 		[Test]
1410 		[Category ("NunitWeb")]
TreeView_Render_NodeStrings()1411 		public void TreeView_Render_NodeStrings () {
1412 			WebTest t = new WebTest (PageInvoker.CreateOnLoad (pageLoadNodeStrings));
1413 			#region HTML
1414 			string strTarget = "<a href=\"#treeview1_SkipLink\"><img alt=\"Skip Navigation Links.\" src=\"/NunitWeb/WebResource.axd?d=8VpphgAbakKUC_J8R6hR0Q2&amp;t=634067491135766272\" width=\"0\" height=\"0\" style=\"border-width:0px;\" /></a><div id=\"treeview1\">\r\n\t<table cellpadding=\"0\" cellspacing=\"0\" style=\"border-width:0;\">\r\n\t\t<tr>\r\n\t\t\t<td><a href=\"javascript:__doPostBack(&#39;treeview1&#39;,&#39;tBook&#39;)\"><img src=\"/NunitWeb/WebResource.axd?d=Me-CdxEHiTTT3lXTDd0I2qLe7WfoYyDfWfVSkV5Suzs1&amp;t=634067491135766272\" alt=\"Collapse Book\" style=\"border-width:0;\" /></a></td><td style=\"white-space:nowrap;\"><a class=\"treeview1_0\" href=\"javascript:__doPostBack(&#39;treeview1&#39;,&#39;sBook&#39;)\" title=\"string1\" id=\"treeview1t0\">Book</a></td>\r\n\t\t</tr>\r\n\t</table><table cellpadding=\"0\" cellspacing=\"0\" style=\"border-width:0;\">\r\n\t\t<tr>\r\n\t\t\t<td><div style=\"width:20px;height:1px\"></div></td><td><a href=\"javascript:__doPostBack(&#39;treeview1&#39;,&#39;tBook\\\\Chapter&#39;)\"><img src=\"/NunitWeb/WebResource.axd?d=Me-CdxEHiTTT3lXTDd0I2qLe7WfoYyDfWfVSkV5Suzs1&amp;t=634067491135766272\" alt=\"Collapse Chapter\" style=\"border-width:0;\" /></a></td><td><a href=\"string4\" id=\"treeview1t1i\" tabindex=\"-1\"><img src=\"string3\" alt=\"\" style=\"border-width:0;\" /></a></td><td style=\"white-space:nowrap;\"><a class=\"treeview1_0\" href=\"string4\" id=\"treeview1t1\">Chapter</a></td>\r\n\t\t</tr>\r\n\t</table><table cellpadding=\"0\" cellspacing=\"0\" style=\"border-width:0;\">\r\n\t\t<tr>\r\n\t\t\t<td><div style=\"width:20px;height:1px\"></div></td><td><div style=\"width:20px;height:1px\"></div></td><td><img src=\"/NunitWeb/WebResource.axd?d=Me-CdxEHiTTT3lXTDd0I2ilpe6vhhhJjssENmbNkrSY1&amp;t=634067491135766272\" alt=\"\" /></td><td style=\"white-space:nowrap;\"><a class=\"treeview1_0\" href=\"javascript:__doPostBack(&#39;treeview1&#39;,&#39;sBook\\\\Chapter\\\\Section&#39;)\" id=\"treeview1t2\">Section</a></td>\r\n\t\t</tr>\r\n\t</table><table cellpadding=\"0\" cellspacing=\"0\" style=\"border-width:0;\">\r\n\t\t<tr>\r\n\t\t\t<td><div style=\"width:20px;height:1px\"></div></td><td><div style=\"width:20px;height:1px\"></div></td><td><img src=\"/NunitWeb/WebResource.axd?d=Me-CdxEHiTTT3lXTDd0I2ilpe6vhhhJjssENmbNkrSY1&amp;t=634067491135766272\" alt=\"\" /></td><td style=\"white-space:nowrap;\"><a class=\"treeview1_0\" href=\"javascript:__doPostBack(&#39;treeview1&#39;,&#39;sBook\\\\Chapter\\\\string6&#39;)\" id=\"treeview1t3\">string6</a></td>\r\n\t\t</tr>\r\n\t</table><table cellpadding=\"0\" cellspacing=\"0\" style=\"border-width:0;\">\r\n\t\t<tr>\r\n\t\t\t<td><div style=\"width:20px;height:1px\"></div></td><td><a href=\"javascript:__doPostBack(&#39;treeview1&#39;,&#39;tBook\\\\string7&#39;)\"><img src=\"/NunitWeb/WebResource.axd?d=Me-CdxEHiTTT3lXTDd0I2qLe7WfoYyDfWfVSkV5Suzs1&amp;t=634067491135766272\" alt=\"Collapse Chapter\" style=\"border-width:0;\" /></a></td><td style=\"white-space:nowrap;\"><a class=\"treeview1_0\" href=\"javascript:__doPostBack(&#39;treeview1&#39;,&#39;sBook\\\\string7&#39;)\" id=\"treeview1t4\">Chapter</a></td>\r\n\t\t</tr>\r\n\t</table><table cellpadding=\"0\" cellspacing=\"0\" style=\"border-width:0;\">\r\n\t\t<tr>\r\n\t\t\t<td><div style=\"width:20px;height:1px\"></div></td><td><div style=\"width:20px;height:1px\"></div></td><td><img src=\"/NunitWeb/WebResource.axd?d=Me-CdxEHiTTT3lXTDd0I2ilpe6vhhhJjssENmbNkrSY1&amp;t=634067491135766272\" alt=\"\" /></td><td style=\"white-space:nowrap;\"><a class=\"treeview1_0\" href=\"javascript:__doPostBack(&#39;treeview1&#39;,&#39;sBook\\\\string7\\\\Section&#39;)\" id=\"treeview1t5\">Section</a></td>\r\n\t\t</tr>\r\n\t</table>\r\n</div><a id=\"treeview1_SkipLink\"></a>";
1415 			#endregion
1416 			string str = HtmlDiff.GetControlFromPageHtml (t.Run ());
1417 			HtmlDiff.AssertAreEqual (strTarget, str, "RenderNodeStrings");
1418 		}
pageLoadNodeStrings(Page page)1419 		public static void pageLoadNodeStrings (Page page) {
1420 			TreeView tv = new TreeView ();
1421 			tv.EnableClientScript = false;
1422 			tv.ID = "treeview1";
1423 			XmlDataSource xmlds = new XmlDataSource ();
1424 			xmlds.EnableCaching = false;
1425 			xmlds.Data = xmlDataBind;
1426 			tv.DataSource = xmlds;
1427 			tv.DataBind ();
1428 			tv.Nodes[0].ToolTip = "string1";
1429 			tv.Nodes[0].ImageToolTip = "string2";
1430 			tv.Nodes[0].ChildNodes[0].ImageUrl = "string3";
1431 			tv.Nodes[0].ChildNodes[0].NavigateUrl = "string4";
1432 			tv.Nodes[0].ChildNodes[0].ChildNodes[0].Target = "string5";
1433 			tv.Nodes[0].ChildNodes[0].ChildNodes[1].Text = "string6";
1434 			tv.Nodes[0].ChildNodes[1].Value = "string7";
1435 			LiteralControl lcb = new LiteralControl (HtmlDiff.BEGIN_TAG);
1436 			LiteralControl lce = new LiteralControl (HtmlDiff.END_TAG);
1437 			page.Form.Controls.Add (lcb);
1438 			page.Form.Controls.Add (tv);
1439 			page.Form.Controls.Add (lce);
1440 		}
1441 
1442 		//Render Node States
1443 		[Test]
1444 		[Category ("NunitWeb")]
TreeView_Render_NodeStates1()1445 		public void TreeView_Render_NodeStates1 () {
1446 			WebTest t = new WebTest (PageInvoker.CreateOnLoad (pageLoadNodeStates1));
1447 			#region HTML
1448 			string strTarget = "<a href=\"#treeview1_SkipLink\"><img alt=\"Skip Navigation Links.\" src=\"/NunitWeb/WebResource.axd?d=8VpphgAbakKUC_J8R6hR0Q2&amp;t=634067491135766272\" width=\"0\" height=\"0\" style=\"border-width:0px;\" /></a><div id=\"treeview1\">\r\n\t<table cellpadding=\"0\" cellspacing=\"0\" style=\"border-width:0;\">\r\n\t\t<tr>\r\n\t\t\t<td><a href=\"javascript:__doPostBack(&#39;treeview1&#39;,&#39;tBook&#39;)\"><img src=\"/NunitWeb/WebResource.axd?d=Me-CdxEHiTTT3lXTDd0I2qLe7WfoYyDfWfVSkV5Suzs1&amp;t=634067491135766272\" alt=\"Collapse Book\" style=\"border-width:0;\" /></a></td><td style=\"white-space:nowrap;\"><a class=\"treeview1_0\" href=\"javascript:__doPostBack(&#39;treeview1&#39;,&#39;sBook&#39;)\" id=\"treeview1t0\">Book</a></td>\r\n\t\t</tr>\r\n\t</table><table cellpadding=\"0\" cellspacing=\"0\" style=\"border-width:0;\">\r\n\t\t<tr>\r\n\t\t\t<td><div style=\"width:20px;height:1px\"></div></td><td><a href=\"javascript:__doPostBack(&#39;treeview1&#39;,&#39;tBook\\\\Chapter&#39;)\"><img src=\"/NunitWeb/WebResource.axd?d=Me-CdxEHiTTT3lXTDd0I2qLe7WfoYyDfWfVSkV5Suzs1&amp;t=634067491135766272\" alt=\"Collapse Chapter\" style=\"border-width:0;\" /></a></td><td style=\"white-space:nowrap;\"><a class=\"treeview1_0\" href=\"javascript:__doPostBack(&#39;treeview1&#39;,&#39;sBook\\\\Chapter&#39;)\" id=\"treeview1t1\">Chapter</a></td>\r\n\t\t</tr>\r\n\t</table><table cellpadding=\"0\" cellspacing=\"0\" style=\"border-width:0;\">\r\n\t\t<tr>\r\n\t\t\t<td><div style=\"width:20px;height:1px\"></div></td><td><div style=\"width:20px;height:1px\"></div></td><td><img src=\"/NunitWeb/WebResource.axd?d=Me-CdxEHiTTT3lXTDd0I2ilpe6vhhhJjssENmbNkrSY1&amp;t=634067491135766272\" alt=\"\" /></td><td style=\"white-space:nowrap;\"><a class=\"treeview1_0\" href=\"javascript:__doPostBack(&#39;treeview1&#39;,&#39;sBook\\\\Chapter\\\\Section&#39;)\" id=\"treeview1t2\">Section</a></td>\r\n\t\t</tr>\r\n\t</table><table cellpadding=\"0\" cellspacing=\"0\" style=\"border-width:0;\">\r\n\t\t<tr>\r\n\t\t\t<td><div style=\"width:20px;height:1px\"></div></td><td><div style=\"width:20px;height:1px\"></div></td><td><img src=\"/NunitWeb/WebResource.axd?d=Me-CdxEHiTTT3lXTDd0I2ilpe6vhhhJjssENmbNkrSY1&amp;t=634067491135766272\" alt=\"\" /></td><td style=\"white-space:nowrap;\"><input type=\"checkbox\" name=\"treeview1n3CheckBox\" id=\"treeview1n3CheckBox\" /><a class=\"treeview1_0\" href=\"javascript:__doPostBack(&#39;treeview1&#39;,&#39;sBook\\\\Chapter\\\\Section&#39;)\" id=\"treeview1t3\">Section</a></td>\r\n\t\t</tr>\r\n\t</table><table cellpadding=\"0\" cellspacing=\"0\" style=\"border-width:0;\">\r\n\t\t<tr>\r\n\t\t\t<td><div style=\"width:20px;height:1px\"></div></td><td><a href=\"javascript:__doPostBack(&#39;treeview1&#39;,&#39;tBook\\\\Chapter&#39;)\"><img src=\"/NunitWeb/WebResource.axd?d=Me-CdxEHiTTT3lXTDd0I2qLe7WfoYyDfWfVSkV5Suzs1&amp;t=634067491135766272\" alt=\"Collapse Chapter\" style=\"border-width:0;\" /></a></td><td style=\"white-space:nowrap;\"><a class=\"treeview1_0\" href=\"javascript:__doPostBack(&#39;treeview1&#39;,&#39;sBook\\\\Chapter&#39;)\" id=\"treeview1t4\">Chapter</a></td>\r\n\t\t</tr>\r\n\t</table><table cellpadding=\"0\" cellspacing=\"0\" style=\"border-width:0;\">\r\n\t\t<tr>\r\n\t\t\t<td><div style=\"width:20px;height:1px\"></div></td><td><div style=\"width:20px;height:1px\"></div></td><td><img src=\"/NunitWeb/WebResource.axd?d=Me-CdxEHiTTT3lXTDd0I2ilpe6vhhhJjssENmbNkrSY1&amp;t=634067491135766272\" alt=\"\" /></td><td style=\"white-space:nowrap;\"><a class=\"treeview1_0\" href=\"javascript:__doPostBack(&#39;treeview1&#39;,&#39;sBook\\\\Chapter\\\\Section&#39;)\" id=\"treeview1t5\">Section</a></td>\r\n\t\t</tr>\r\n\t</table>\r\n</div><a id=\"treeview1_SkipLink\"></a>";
1449 			#endregion
1450 			string str = HtmlDiff.GetControlFromPageHtml (t.Run ());
1451 			HtmlDiff.AssertAreEqual (strTarget, str, "RenderNodeStates1");
1452 		}
pageLoadNodeStates1(Page page)1453 		public static void pageLoadNodeStates1 (Page page) {
1454 			TreeView tv = new TreeView ();
1455 			tv.EnableClientScript = false;
1456 			tv.ID = "treeview1";
1457 			XmlDataSource xmlds = new XmlDataSource ();
1458 			xmlds.EnableCaching = false;
1459 			xmlds.Data = xmlDataBind;
1460 			tv.DataSource = xmlds;
1461 			tv.DataBind ();
1462 			tv.Nodes[0].Checked = true;
1463 			tv.Nodes[0].ChildNodes[0].Selected = false;
1464 			tv.Nodes[0].ChildNodes[0].Expanded = true;
1465 			tv.Nodes[0].ChildNodes[0].ChildNodes[0].PopulateOnDemand = false;
1466 			tv.Nodes[0].ChildNodes[0].ChildNodes[1].ShowCheckBox = true;
1467 			tv.Nodes[0].ChildNodes[1].SelectAction = TreeNodeSelectAction.SelectExpand;
1468 			LiteralControl lcb = new LiteralControl (HtmlDiff.BEGIN_TAG);
1469 			LiteralControl lce = new LiteralControl (HtmlDiff.END_TAG);
1470 			page.Form.Controls.Add (lcb);
1471 			page.Form.Controls.Add (tv);
1472 			page.Form.Controls.Add (lce);
1473 		}
1474 
1475 		[Test]
1476 		[Category ("NunitWeb")]
TreeView_Render_NodeStates2()1477 		public void TreeView_Render_NodeStates2 () {
1478 			WebTest t = new WebTest (PageInvoker.CreateOnLoad (pageLoadNodeStates2));
1479 			#region HTML
1480 			string strTarget = "<a href=\"#treeview1_SkipLink\"><img alt=\"Skip Navigation Links.\" src=\"/NunitWeb/WebResource.axd?d=8VpphgAbakKUC_J8R6hR0Q2&amp;t=634067491135766272\" width=\"0\" height=\"0\" style=\"border-width:0px;\" /></a><div id=\"treeview1\">\r\n\t<table cellpadding=\"0\" cellspacing=\"0\" style=\"border-width:0;\">\r\n\t\t<tr>\r\n\t\t\t<td><a href=\"javascript:__doPostBack(&#39;treeview1&#39;,&#39;tBook&#39;)\"><img src=\"/NunitWeb/WebResource.axd?d=Me-CdxEHiTTT3lXTDd0I2qLe7WfoYyDfWfVSkV5Suzs1&amp;t=634067491135766272\" alt=\"Collapse Book\" style=\"border-width:0;\" /></a></td><td style=\"white-space:nowrap;\"><a class=\"treeview1_0\" href=\"javascript:__doPostBack(&#39;treeview1&#39;,&#39;sBook&#39;)\" id=\"treeview1t0\">Book</a></td>\r\n\t\t</tr>\r\n\t</table><table cellpadding=\"0\" cellspacing=\"0\" style=\"border-width:0;\">\r\n\t\t<tr>\r\n\t\t\t<td><div style=\"width:20px;height:1px\"></div></td><td><a href=\"javascript:__doPostBack(&#39;treeview1&#39;,&#39;tBook\\\\Chapter&#39;)\"><img src=\"/NunitWeb/WebResource.axd?d=Me-CdxEHiTTT3lXTDd0I2qsyBHMcxXXKbUwruYE_9Mo1&amp;t=634067491135766272\" alt=\"Expand Chapter\" style=\"border-width:0;\" /></a></td><td style=\"white-space:nowrap;\"><a class=\"treeview1_0\" href=\"javascript:__doPostBack(&#39;treeview1&#39;,&#39;sBook\\\\Chapter&#39;)\" id=\"treeview1t1\">Chapter</a></td>\r\n\t\t</tr>\r\n\t</table><table cellpadding=\"0\" cellspacing=\"0\" style=\"border-width:0;\">\r\n\t\t<tr>\r\n\t\t\t<td><div style=\"width:20px;height:1px\"></div></td><td><a href=\"javascript:__doPostBack(&#39;treeview1&#39;,&#39;tBook\\\\Chapter&#39;)\"><img src=\"/NunitWeb/WebResource.axd?d=Me-CdxEHiTTT3lXTDd0I2qLe7WfoYyDfWfVSkV5Suzs1&amp;t=634067491135766272\" alt=\"Collapse Chapter\" style=\"border-width:0;\" /></a></td><td style=\"white-space:nowrap;\"><a class=\"treeview1_0\" href=\"javascript:__doPostBack(&#39;treeview1&#39;,&#39;sBook\\\\Chapter&#39;)\" id=\"treeview1t4\">Chapter</a></td>\r\n\t\t</tr>\r\n\t</table><table cellpadding=\"0\" cellspacing=\"0\" style=\"border-width:0;\">\r\n\t\t<tr>\r\n\t\t\t<td><div style=\"width:20px;height:1px\"></div></td><td><div style=\"width:20px;height:1px\"></div></td><td><img src=\"/NunitWeb/WebResource.axd?d=Me-CdxEHiTTT3lXTDd0I2ilpe6vhhhJjssENmbNkrSY1&amp;t=634067491135766272\" alt=\"\" /></td><td style=\"white-space:nowrap;\"><a class=\"treeview1_0\" href=\"javascript:__doPostBack(&#39;treeview1&#39;,&#39;sBook\\\\Chapter\\\\Section&#39;)\" id=\"treeview1t5\">Section</a></td>\r\n\t\t</tr>\r\n\t</table>\r\n</div><a id=\"treeview1_SkipLink\"></a>";
1481 			#endregion
1482 			string str = HtmlDiff.GetControlFromPageHtml (t.Run ());
1483 			HtmlDiff.AssertAreEqual (strTarget, str, "RenderNodeStates2");
1484 		}
pageLoadNodeStates2(Page page)1485 		public static void pageLoadNodeStates2 (Page page) {
1486 			TreeView tv = new TreeView ();
1487 			tv.EnableClientScript = false;
1488 			tv.ID = "treeview1";
1489 			XmlDataSource xmlds = new XmlDataSource ();
1490 			xmlds.EnableCaching = false;
1491 			xmlds.Data = xmlDataBind;
1492 			tv.DataSource = xmlds;
1493 			tv.DataBind ();
1494 			tv.Nodes[0].Checked = false;
1495 			tv.Nodes[0].ChildNodes[0].Selected = true;
1496 			tv.Nodes[0].ChildNodes[0].Expanded = false;
1497 			tv.Nodes[0].ChildNodes[0].ChildNodes[0].PopulateOnDemand = true;
1498 			tv.Nodes[0].ChildNodes[0].ChildNodes[1].ShowCheckBox = false;
1499 			tv.Nodes[0].ChildNodes[1].SelectAction = TreeNodeSelectAction.Expand;
1500 			LiteralControl lcb = new LiteralControl (HtmlDiff.BEGIN_TAG);
1501 			LiteralControl lce = new LiteralControl (HtmlDiff.END_TAG);
1502 			page.Form.Controls.Add (lcb);
1503 			page.Form.Controls.Add (tv);
1504 			page.Form.Controls.Add (lce);
1505 		}
1506 
1507 		[Test]
1508 		[Category ("NunitWeb")]
TreeView_PostBackFireEvents_1()1509 		public void TreeView_PostBackFireEvents_1 ()
1510 		{
1511 			WebTest t = new WebTest (PageInvoker.CreateOnLoad (PostBackFireEvents_1));
1512 			String html = t.Run ();
1513 			if (t.UserData == null)
1514 				Assert.Fail ("Event not fired fail");
1515 			Assert.AreEqual ("TreeNodeDataBound", t.UserData.ToString (), "PostBackFireEvents_1");
1516 		}
1517 
1518 		#region PostBackFireEvents_1
PostBackFireEvents_1(Page p)1519 		public static void PostBackFireEvents_1 (Page p)
1520 		{
1521 			TreeView tv = new TreeView ();
1522 			tv.TreeNodeDataBound += new TreeNodeEventHandler (tv_TreeNodeDataBound);
1523 			tv.EnableClientScript = false;
1524 			tv.ID = "treeview1";
1525 			XmlDataSource xmlds = new XmlDataSource ();
1526 			xmlds.EnableCaching = false;
1527 			xmlds.Data = xmlDataBind;
1528 			tv.DataSource = xmlds;
1529 			tv.DataBind ();
1530 			tv.Nodes[0].Checked = true;
1531 			tv.Nodes[0].ChildNodes[0].Selected = false;
1532 			tv.Nodes[0].ChildNodes[0].Expanded = true;
1533 			tv.Nodes[0].ChildNodes[0].ChildNodes[0].PopulateOnDemand = false;
1534 			tv.Nodes[0].ChildNodes[0].ChildNodes[1].ShowCheckBox = true;
1535 			tv.Nodes[0].ChildNodes[1].SelectAction = TreeNodeSelectAction.SelectExpand;
1536 			p.Form.Controls.Add (tv);
1537 		}
1538 
tv_TreeNodeDataBound(object sender, TreeNodeEventArgs e)1539 		public static void tv_TreeNodeDataBound (object sender, TreeNodeEventArgs e)
1540 		{
1541 			WebTest.CurrentTest.UserData = "TreeNodeDataBound";
1542 		}
1543 		#endregion
1544 
1545 		[Test]
1546 		[Category ("NunitWeb")]
TreeView_PostBackFireEvents_2()1547 		public void TreeView_PostBackFireEvents_2 ()
1548 		{
1549 			WebTest t = new WebTest ("NoEventValidation.aspx");
1550 			t.Invoker = PageInvoker.CreateOnLoad (PostBackFireEvents_2);
1551 			string html = t.Run ();
1552 			FormRequest fr = new FormRequest (t.Response, "form1");
1553 
1554 #if DOT_NET
1555 			fr.Controls.Add ("__EVENTTARGET");
1556 			fr.Controls.Add ("__EVENTARGUMENT");
1557 			fr.Controls.Add ("treeview1_ExpandState");
1558 			fr.Controls.Add ("treeview1_SelectedNode");
1559 			fr.Controls.Add ("treeview1_PopulateLog");
1560 			fr.Controls.Add ("treeview1n0CheckBox");
1561 
1562 			fr.Controls["__EVENTTARGET"].Value = "treeview1";
1563 			fr.Controls["__EVENTARGUMENT"].Value = "sroot";
1564 			fr.Controls["treeview1_ExpandState"].Value = "n";
1565 			fr.Controls["treeview1_SelectedNode"].Value = "treeview1t0";
1566 			fr.Controls["treeview1_PopulateLog"].Value = "";
1567 			fr.Controls["treeview1n0CheckBox"].Value = "on";
1568 #else
1569 			fr.Controls.Add ("__EVENTTARGET");
1570 			fr.Controls.Add ("__EVENTARGUMENT");
1571 			//fr.Controls.Add ("treeview1_ExpandState");
1572 			//fr.Controls.Add ("treeview1_SelectedNode");
1573 			//fr.Controls.Add ("treeview1_PopulateLog");
1574 			fr.Controls.Add ("treeview1_cs_0");
1575 
1576 			fr.Controls ["__EVENTTARGET"].Value = "treeview1";
1577 			fr.Controls ["__EVENTARGUMENT"].Value = "sel|0";
1578 			//fr.Controls ["treeview1_ExpandState"].Value = "n";
1579 			//fr.Controls ["treeview1_SelectedNode"].Value = "treeview1t0";
1580 			//fr.Controls ["treeview1_PopulateLog"].Value = "";
1581 			fr.Controls ["treeview1_cs_0"].Value = "on";
1582 #endif
1583 
1584 			t.Request = fr;
1585 			html = t.Run ();
1586 
1587 			Assert.AreEqual ("TreeNodeCheckChanged", t.UserData.ToString (), "PostBackFireEvents");
1588 		}
1589 
1590 		#region PostBackFireEvents_2
PostBackFireEvents_2(Page p)1591 		public static void PostBackFireEvents_2 (Page p)
1592 		{
1593 			TreeView tv = new TreeView ();
1594 			tv.TreeNodeCheckChanged+=new TreeNodeEventHandler(tv_TreeNodeCheckChanged);
1595 			tv.EnableClientScript = false;
1596 			tv.ID = "treeview1";
1597 			TreeNode root = new TreeNode ("root", "root");
1598 			root.ShowCheckBox = true;
1599 			root.Checked = false;
1600 			tv.Nodes.Add (root);
1601 			p.Form.Controls.Add (tv);
1602 		}
1603 
tv_TreeNodeCheckChanged(object sender, TreeNodeEventArgs e)1604 		static void tv_TreeNodeCheckChanged (object sender, TreeNodeEventArgs e)
1605 		{
1606 			WebTest.CurrentTest.UserData = "TreeNodeCheckChanged";
1607 		}
1608 		#endregion
1609 
1610 		[Test]
1611 		[Category ("NunitWeb")]
TreeView_PostBackFireEvents_3()1612 		public void TreeView_PostBackFireEvents_3 ()
1613 		{
1614 			WebTest t = new WebTest (PageInvoker.CreateOnLoad (PostBackFireEvents_3));
1615 			String html = t.Run ();
1616 			if (t.UserData == null)
1617 				Assert.Fail ("Event not fired fail");
1618 			Assert.AreEqual ("TreeNodeExpanded", t.UserData.ToString (), "PostBackFireEvents#1");
1619 
1620 			FormRequest fr = new FormRequest (t.Response, "form1");
1621 			fr.Controls.Add ("__EVENTTARGET");
1622 			fr.Controls.Add ("__EVENTARGUMENT");
1623 			fr.Controls["__EVENTTARGET"].Value = "treeview1";
1624 #if DOT_NET
1625 			fr.Controls["__EVENTARGUMENT"].Value = "tBook";
1626 #else
1627 			fr.Controls ["__EVENTARGUMENT"].Value = "ec|0";
1628 #endif
1629 			t.Request = fr;
1630 			html = t.Run ();
1631 			Assert.AreEqual ("TreeNodeCollapsed", t.UserData.ToString (), "PostBackFireEvents#2");
1632 
1633 		}
1634 
1635 		#region PostBackFireEvents_3
PostBackFireEvents_3(Page p)1636 		public static void PostBackFireEvents_3 (Page p)
1637 		{
1638 			TreeView tv = new TreeView ();
1639 			tv.TreeNodeCollapsed += new TreeNodeEventHandler (tv_TreeNodeCollapsed);
1640 			tv.TreeNodeExpanded +=new TreeNodeEventHandler(tv_TreeNodeExpanded);
1641 			tv.EnableClientScript = false;
1642 			tv.ID = "treeview1";
1643 			XmlDataSource xmlds = new XmlDataSource ();
1644 			xmlds.EnableCaching = false;
1645 			xmlds.Data = xmlDataBind;
1646 			tv.DataSource = xmlds;
1647 			tv.DataBind ();
1648 			tv.Nodes[0].Checked = true;
1649 			tv.Nodes[0].ChildNodes[0].Selected = false;
1650 			tv.Nodes[0].ChildNodes[0].Expanded = true;
1651 			tv.Nodes[0].ChildNodes[0].ChildNodes[0].PopulateOnDemand = false;
1652 			tv.Nodes[0].ChildNodes[0].ChildNodes[1].ShowCheckBox = true;
1653 			tv.Nodes[0].ChildNodes[1].SelectAction = TreeNodeSelectAction.SelectExpand;
1654 			p.Form.Controls.Add (tv);
1655 
1656 
1657 		}
1658 
tv_TreeNodeCollapsed(object sender, TreeNodeEventArgs e)1659 		public static void tv_TreeNodeCollapsed (object sender, TreeNodeEventArgs e)
1660 		{
1661 			WebTest.CurrentTest.UserData = "TreeNodeCollapsed";
1662 		}
1663 
tv_TreeNodeExpanded(object sender, TreeNodeEventArgs e)1664 		static void tv_TreeNodeExpanded (object sender, TreeNodeEventArgs e)
1665 		{
1666 			WebTest.CurrentTest.UserData = "TreeNodeExpanded";
1667 		}
1668 		#endregion
1669 
1670 		[Test]
1671 		[Category ("NunitWeb")]
TreeView_PostBackFireEvents_4()1672 		public void TreeView_PostBackFireEvents_4 ()
1673 		{
1674 			WebTest t = new WebTest (PageInvoker.CreateOnLoad (PostBackFireEvents_4));
1675 		        String html = t.Run ();
1676 			Assert.AreEqual ("TreeNodePopulate", t.UserData.ToString (), "PostBackFireEvents");
1677 		}
1678 
1679 		#region PostBackFireEvents_4
PostBackFireEvents_4(Page p)1680 		public static void PostBackFireEvents_4 (Page p)
1681 		{
1682 			TreeView tv = new TreeView ();
1683 			tv.TreeNodePopulate += new TreeNodeEventHandler (tv_TreeNodePopulate_1);
1684 			tv.EnableClientScript = false;
1685 			tv.ID = "treeview1";
1686 			TreeNode root = new TreeNode ("Root", "Root");
1687 			root.PopulateOnDemand = true;
1688 			root.Expanded = true;
1689 			tv.Nodes.Add (root);
1690 			p.Form.Controls.Add (tv);
1691 		}
1692 
tv_TreeNodePopulate_1(object sender, TreeNodeEventArgs e)1693 		public static void tv_TreeNodePopulate_1 (object sender, TreeNodeEventArgs e)
1694 		{
1695 			WebTest.CurrentTest.UserData = "TreeNodePopulate";
1696 		}
1697 		#endregion
1698 
1699 		[Test]
1700 		[Category ("NunitWeb")]
TreeView_PostBackFireEvents_5()1701 		public void TreeView_PostBackFireEvents_5 ()
1702 		{
1703 			WebTest t = new WebTest ("NoEventValidation.aspx");
1704 			t.Invoker = PageInvoker.CreateOnLoad (PostBackFireEvents_5);
1705 			t.Run ();
1706 			FormRequest fr = new FormRequest (t.Response, "form1");
1707 #if DOT_NET
1708 			fr.Controls.Add ("__EVENTTARGET");
1709 			fr.Controls.Add ("__EVENTARGUMENT");
1710 			fr.Controls.Add ("TreeView2_ExpandState");
1711 			fr.Controls.Add ("TreeView2_SelectedNode");
1712 
1713 			fr.Controls["__EVENTTARGET"].Value = "treeview1";
1714 			fr.Controls["__EVENTARGUMENT"].Value = "snode";
1715 			fr.Controls["TreeView2_ExpandState"].Value = "nn";
1716 			fr.Controls["TreeView2_SelectedNode"].Value = "treeview1t1";
1717 #else
1718 			fr.Controls.Add ("__EVENTTARGET");
1719 			fr.Controls.Add ("__EVENTARGUMENT");
1720 			//fr.Controls.Add ("TreeView2_ExpandState");
1721 			//fr.Controls.Add ("TreeView2_SelectedNode");
1722 
1723 			fr.Controls ["__EVENTTARGET"].Value = "treeview1";
1724 			fr.Controls ["__EVENTARGUMENT"].Value = "sel|1";
1725 			//fr.Controls ["TreeView2_ExpandState"].Value = "nn";
1726 			//fr.Controls ["TreeView2_SelectedNode"].Value = "treeview1t1";
1727 #endif
1728 			t.Request = fr;
1729 			t.Run ();
1730 			Assert.AreEqual ("SelectedNodeChanged", t.UserData.ToString (), "PostBackFireEvents");
1731 		}
1732 
1733 		#region PostBackFireEvents_5
PostBackFireEvents_5(Page p)1734 		public static void PostBackFireEvents_5 (Page p)
1735 		{
1736 			TreeView tv = new TreeView ();
1737 			tv.SelectedNodeChanged += new EventHandler (tv_SelectedNodeChanged);
1738 			tv.EnableClientScript = false;
1739 			tv.ID = "treeview1";
1740 			TreeNode root = new TreeNode ("root", "root");
1741 			root.Selected = true;
1742 			tv.Nodes.Add (root);
1743 			TreeNode node = new TreeNode ("node", "node");
1744 			tv.Nodes.Add (node);
1745 			node.Selected = false;
1746 			p.Form.Controls.Add (tv);
1747 		}
1748 
tv_SelectedNodeChanged(object sender, EventArgs e)1749 		static void tv_SelectedNodeChanged (object sender, EventArgs e)
1750 		{
1751 			WebTest.CurrentTest.UserData = "SelectedNodeChanged";
1752 		}
1753 		#endregion
1754 
1755 		[Test]
TreeView_NullDS()1756 		public void TreeView_NullDS ()
1757 		{
1758 			TreeView tv = new TreeView ();
1759 			tv.DataSource = null;
1760 			tv.DataBind ();
1761 			Assert.AreEqual (0, tv.Nodes.Count, "NullDS");
1762 		}
1763 
1764 
1765 		// Events Stuff
1766 		private bool eventDone = false;
1767 		private string treeNodeName = string.Empty;
TreeViewEventHandler1(object sender, EventArgs e)1768 		private void TreeViewEventHandler1 (object sender, EventArgs e) {
1769 			eventDone = true;
1770 		}
TreeViewEventHandler2(object sender, TreeNodeEventArgs e)1771 		private void TreeViewEventHandler2 (object sender, TreeNodeEventArgs e) {
1772 			eventDone = true;
1773 			treeNodeName = e.Node.Text;
1774 		}
ResetEvents()1775 		private void ResetEvents () {
1776 			eventDone = false;
1777 			treeNodeName = string.Empty;
1778 		}
1779 
1780 		[Test]
TreeView_Event_Init()1781 		public void TreeView_Event_Init () {
1782 			PokerTreeView tv = new PokerTreeView ();
1783 			ResetEvents ();
1784 			Page p = new Page ();
1785 			p.Controls.Add (tv);
1786 			tv.Init += new EventHandler (TreeViewEventHandler1);
1787 			Assert.AreEqual (false, eventDone, "BeforeInit");
1788 			tv.OnInitBase (new EventArgs ());
1789 			Assert.AreEqual (true, eventDone, "AfterInit");
1790 		}
1791 		[Test]
TreeView_Event_SelectedNodeChanged()1792 		public void TreeView_Event_SelectedNodeChanged () {
1793 			PokerTreeView tv = new PokerTreeView ();
1794 			ResetEvents ();
1795 			tv.SelectedNodeChanged += new EventHandler (TreeViewEventHandler1);
1796 			Assert.AreEqual (false, eventDone, "BeforeSelectedNodeChanged");
1797 			tv.OnSelectedNodeChangedBase (new EventArgs ());
1798 			Assert.AreEqual (true, eventDone, "AfterSelectedNodeChanged");
1799 		}
1800 		[Test]
TreeView_Event_TreeNodeCheckChanged()1801 		public void TreeView_Event_TreeNodeCheckChanged () {
1802 			string methodName = "TreeNodeCheckChanged";
1803 			PokerTreeView tv = new PokerTreeView ();
1804 			ResetEvents ();
1805 			tv.TreeNodeCheckChanged += new TreeNodeEventHandler (TreeViewEventHandler2);
1806 			Assert.AreEqual (false, eventDone, "Before1 " + methodName);
1807 			Assert.AreEqual (string.Empty, treeNodeName, "Before2 " + methodName);
1808 			tv.OnTreeNodeCheckChangedBase (new TreeNodeEventArgs (new TreeNode (methodName)));
1809 			Assert.AreEqual (true, eventDone, "After1 " + methodName);
1810 			Assert.AreEqual (methodName, treeNodeName, "After2 " + methodName);
1811 		}
1812 		[Test]
TreeView_Event_TreeNodeCollapsed()1813 		public void TreeView_Event_TreeNodeCollapsed () {
1814 			string methodName = "TreeNodeCollapsed";
1815 			PokerTreeView tv = new PokerTreeView ();
1816 			ResetEvents ();
1817 			tv.TreeNodeCollapsed += new TreeNodeEventHandler (TreeViewEventHandler2);
1818 			Assert.AreEqual (false, eventDone, "Before1 " + methodName);
1819 			Assert.AreEqual (string.Empty, treeNodeName, "Before2 " + methodName);
1820 			tv.OnTreeNodeCollapsedBase (new TreeNodeEventArgs (new TreeNode (methodName)));
1821 			Assert.AreEqual (true, eventDone, "After1 " + methodName);
1822 			Assert.AreEqual (methodName, treeNodeName, "After2 " + methodName);
1823 		}
1824 		[Test]
TreeView_Event_TreeNodeDataBound()1825 		public void TreeView_Event_TreeNodeDataBound () {
1826 			string methodName = "TreeNodeDataBound";
1827 			PokerTreeView tv = new PokerTreeView ();
1828 			ResetEvents ();
1829 			tv.TreeNodeDataBound += new TreeNodeEventHandler (TreeViewEventHandler2);
1830 			Assert.AreEqual (false, eventDone, "Before1 " + methodName);
1831 			Assert.AreEqual (string.Empty, treeNodeName, "Before2 " + methodName);
1832 			tv.OnTreeNodeDataBoundBase (new TreeNodeEventArgs (new TreeNode (methodName)));
1833 			Assert.AreEqual (true, eventDone, "After1 " + methodName);
1834 			Assert.AreEqual (methodName, treeNodeName, "After2 " + methodName);
1835 		}
1836 		[Test]
TreeView_Event_TreeNodeExpanded()1837 		public void TreeView_Event_TreeNodeExpanded () {
1838 			string methodName = "TreeNodeExpanded";
1839 			PokerTreeView tv = new PokerTreeView ();
1840 			ResetEvents ();
1841 			tv.TreeNodeExpanded += new TreeNodeEventHandler (TreeViewEventHandler2);
1842 			Assert.AreEqual (false, eventDone, "Before1 " + methodName);
1843 			Assert.AreEqual (string.Empty, treeNodeName, "Before2 " + methodName);
1844 			tv.OnTreeNodeExpandedBase (new TreeNodeEventArgs (new TreeNode (methodName)));
1845 			Assert.AreEqual (true, eventDone, "After1 " + methodName);
1846 			Assert.AreEqual (methodName, treeNodeName, "After2 " + methodName);
1847 		}
1848 		[Test]
TreeView_Event_TreeNodePopulate()1849 		public void TreeView_Event_TreeNodePopulate () {
1850 			string methodName = "TreeNodePopulate";
1851 			PokerTreeView tv = new PokerTreeView ();
1852 			ResetEvents ();
1853 			tv.TreeNodePopulate += new TreeNodeEventHandler (TreeViewEventHandler2);
1854 			Assert.AreEqual (false, eventDone, "Before1 " + methodName);
1855 			Assert.AreEqual (string.Empty, treeNodeName, "Before2 " + methodName);
1856 			tv.OnTreeNodePopulateBase (new TreeNodeEventArgs (new TreeNode (methodName)));
1857 			Assert.AreEqual (true, eventDone, "After1 " + methodName);
1858 			Assert.AreEqual (methodName, treeNodeName, "After2 " + methodName);
1859 		}
1860 
1861 		[TestFixtureTearDown]
TearDown()1862 		public void TearDown () {
1863 			WebTest.Unload ();
1864 		}
1865 	}
1866 }
1867 
1868