[resgen] Implement conditional resources (#if/#ifdef)
[mono.git] / mcs / class / System.Web / Test / System.Web.UI.WebControls / MenuTest.cs
1 //
2 // Tests for System.Web.UI.WebControls.MenuTest.cs
3 //
4 // Author:
5 //      Yoni Klein (yonik@mainsoft.com)
6 //
7 //
8 // Copyright (C) 2005 Novell, Inc (http://www.novell.com)
9 //
10 // Permission is hereby granted, free of charge, to any person obtaining
11 // a copy of this software and associated documentation files (the
12 // "Software"), to deal in the Software without restriction, including
13 // without limitation the rights to use, copy, modify, merge, publish,
14 // distribute, sublicense, and/or sell copies of the Software, and to
15 // permit persons to whom the Software is furnished to do so, subject to
16 // the following conditions:
17 //
18 // The above copyright notice and this permission notice shall be
19 // included in all copies or substantial portions of the Software.
20 //
21 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
24 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
25 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
26 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
27 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28
29
30
31
32 using NUnit.Framework;
33 using System;
34 using System.Collections.Generic;
35 using System.Text;
36 using System.Web;
37 using System.Web.UI;
38 using System.Web.UI.WebControls;
39 using System.IO;
40 using System.Drawing;
41 using System.Threading;
42 using MyWebControl = System.Web.UI.WebControls;
43 using System.Collections;
44 using MonoTests.SystemWeb.Framework;
45 using MonoTests.stand_alone.WebHarness;
46 using System.Text.RegularExpressions;
47 using System.Reflection;
48 using System.Xml;
49
50 using MonoTests.Common;
51
52 namespace MonoTests.System.Web.UI.WebControls
53 {
54         class MenuTable : Menu
55         {
56                 public MenuTable ()
57                 {
58 #if NET_4_0
59                         RenderingMode = MenuRenderingMode.Table;
60 #endif
61                 }
62         }
63         
64         class PokerMenu : Menu
65         {
66                 public PokerMenu ()
67                 {
68                     TrackViewState();
69                 }
70                 public StateBag StateBag
71                 {
72                     get { return base.ViewState; }
73                 }
74                 public HtmlTextWriterTag OnTagKey()
75                 {
76                         return  TagKey;
77                 }
78                 public void DoOnDataBind(EventArgs e)
79                 {
80                         OnDataBinding(e);
81                 }
82                 public void DoOnDataBound (EventArgs e)
83                 {
84                         OnDataBound(e);
85                 }
86                 public void DoCreateChildControls ()
87                 {
88                         CreateChildControls ();
89                 }
90                 public void DoEnsureDataBound ()
91                 {
92                         EnsureDataBound ();
93                 }
94                 public void DoLoadViewState (object state)
95                 {
96                         LoadViewState (state);
97                 }
98                 public object DoSaveViewState ()
99                 {
100                         return SaveViewState ();
101                 }
102                 public void DoLoadControlState (object state)
103                 {
104                         LoadControlState (state);
105                 }
106                 public object DoSaveControlState ()
107                 {
108                        return SaveControlState ();
109                 }
110                 public void DoOnMenuItemClick (MenuEventArgs e)
111                 {
112                         OnMenuItemClick(e);
113                 }
114                 public void DoOnInit(EventArgs e)
115                 {
116                         OnInit(e);
117                 }
118                 public void DoMenuItemDataBound (MenuEventArgs e)
119                 {
120                         OnMenuItemDataBound (e);        
121                 }
122                 public void DoOnPreRender (EventArgs e)
123                 {
124                         base.OnPreRender(e);
125                 }
126                 public bool DoOnBubbleEvent(EventArgs e)
127                 {
128                         return base.OnBubbleEvent(this,e);
129                 }
130         }
131
132         [Serializable]
133         [TestFixture]
134         public class MenuTest
135         {       
136
137                 [TestFixtureSetUp]
138                 public void SetUp ()
139                 {
140                         WebTest.CopyResource (GetType (), "menuclass.aspx", "menuclass.aspx");
141                         WebTest.CopyResource (GetType (), "PostBackMenuTest.aspx", "PostBackMenuTest.aspx");
142                 }
143
144                 [Test]
145                 public void Menu_DefaultProperties ()
146                 {
147                         PokerMenu p = new PokerMenu ();
148                         Assert.AreEqual ("Click",PokerMenu.MenuItemClickCommandName,"Staic_MenuItemClickCommandName");
149                         Assert.AreEqual (0,p.Controls.Count,"ControlsCollection");
150                         Assert.AreEqual (0,p.DataBindings.Count,"DataBindings");
151                         Assert.AreEqual (500,p.DisappearAfter,"DisappearAfter");
152                         Assert.AreEqual (string.Empty, p.DynamicBottomSeparatorImageUrl, "DynamicBottomSeparatorImageUrl");
153                         Assert.IsTrue (p.DynamicEnableDefaultPopOutImage, "DynamicEnableDefaultPopOutImage");
154                         Assert.AreEqual (0, p.DynamicHorizontalOffset, "DynamicHorizontalOffset");
155                         Assert.IsNotNull (p.DynamicHoverStyle, "DynamicHoverStyle");
156                         Assert.AreEqual ("", p.DynamicItemFormatString, "DynamicItemFormatString");
157                         Assert.IsNull (p.DynamicItemTemplate, "DynamicItemTemplate");
158                         Assert.IsNotNull (p.DynamicMenuItemStyle, "DynamicMenuItemStyle");
159                         Assert.IsNotNull (p.DynamicMenuStyle, "DynamicMenuStyle");
160                         Assert.AreEqual (string.Empty,p.DynamicPopOutImageUrl,"DynamicPopOutImageUrl");
161                         Assert.IsNotNull (p.DynamicSelectedStyle, "DynamicSelectedStyle");
162                         Assert.AreEqual (string.Empty, p.DynamicTopSeparatorImageUrl, "DynamicTopSeparatorImageUrl");
163                         Assert.AreEqual (0, p.DynamicVerticalOffset, "DynamicVerticalOffset");
164                         Assert.AreEqual (0, p.Items.Count, "Items");
165                         Assert.AreEqual (false, p.ItemWrap, "ItemWrap");
166                         Assert.IsNotNull (p.LevelSelectedStyles, "LevelSelectedStyles");
167                         Assert.IsNotNull (p.LevelSubMenuStyles, "LevelSubMenuStyles");
168                         Assert.AreEqual (3, p.MaximumDynamicDisplayLevels, "MaximumDynamicDisplayLevels");
169                         Assert.AreEqual (Orientation.Vertical, p.Orientation, "Orientation");
170                         Assert.AreEqual ("/", p.PathSeparator.ToString(), "PathSeparator");
171                         Assert.AreEqual (string.Empty, p.ScrollDownImageUrl, "ScrollDownImageUrl");
172                         Assert.AreEqual (null, p.SelectedItem, "p.SelectedItem");
173                         Assert.AreEqual (string.Empty, p.StaticBottomSeparatorImageUrl, "StaticBottomSeparatorImageUrl");
174                         Assert.AreEqual (1, p.StaticDisplayLevels, "StaticDisplayLevels");
175                         Assert.AreEqual (true, p.StaticEnableDefaultPopOutImage, "StaticEnableDefaultPopOutImage");
176                         Assert.IsNotNull (p.StaticHoverStyle, "StaticHoverStyle");
177                         Assert.AreEqual ("", p.StaticItemFormatString, "StaticItemFormatString");
178                         Assert.AreEqual (null, p.StaticItemTemplate, "StaticItemTemplate");
179                         Assert.IsNotNull (p.StaticMenuItemStyle, "StaticMenuItemStyle");
180                         Assert.IsNotNull (p.StaticMenuStyle, "StaticMenuStyle");
181                         Assert.AreEqual ("", p.StaticPopOutImageUrl, "StaticPopOutImageUrl");
182                         Assert.IsNotNull (p.StaticSelectedStyle, "StaticSelectedStyle");
183 #if NET_4_0
184                         Assert.IsTrue (p.StaticSubMenuIndent.IsEmpty, "StaticSubMenuIndent");
185 #else
186                         Assert.AreEqual (Unit.Pixel(16), p.StaticSubMenuIndent, "StaticSubMenuIndent");
187 #endif
188                         Assert.AreEqual ("", p.StaticTopSeparatorImageUrl, "StaticTopSeparatorImageUrl");
189                         Assert.AreEqual ("", p.Target, "Target");
190                         Assert.IsNotNull (p.OnTagKey (), "TagKey");
191
192                 }
193
194                 [Test]
195                 public void Menu_DefaultProperties_2 ()
196                 {
197                         PokerMenu p = new PokerMenu ();
198                         Assert.AreEqual ("Skip Navigation Links", p.SkipLinkText, "SkipLinkText");
199                         Assert.AreEqual (string.Empty, p.SelectedValue, "SelectedValue");
200                         Assert.AreEqual ("Scroll up", p.ScrollUpText, "ScrollUpText");
201                         Assert.AreEqual ("Expand {0}", p.StaticPopOutImageTextFormatString, "StaticPopOutImageTextFormatString"); //not implemented
202                         Assert.AreEqual ("Scroll down", p.ScrollDownText, "ScrollDownText");
203                         Assert.AreEqual ("Expand {0}", p.DynamicPopOutImageTextFormatString, "DynamicPopOutImageTextFormatString"); //not implemented 
204                 }
205
206
207
208                 [Test]
209                 public void Menu_ChangeDefaultProperties ()
210                 {
211                         PokerMenu p = new PokerMenu ();
212                         Button B = new Button ();
213                         p.Controls.Add (B);
214                         Assert.AreEqual (1,p.Controls.Count, "ControlsCollection");
215
216                         MenuItemBinding M = new MenuItemBinding ();
217                         M.DataMember = "test";
218                         M.Depth = 0;
219                         M.TextField = "title"; 
220                         M.NavigateUrl="url";
221                         Object C = p.DataBindings;
222                         Assert.AreEqual (0, p.DataBindings.Count, "DataBindings#1");
223                         ((MenuItemBindingCollection)C).Add (M);
224                         Assert.AreEqual (1,p.DataBindings.Count,"DataBindings#2");
225
226                         p.DisappearAfter = 100;
227                         Assert.AreEqual (100, p.DisappearAfter, "DisappearAfter");
228
229                         p.DynamicBottomSeparatorImageUrl = "test.aspx";
230                         Assert.AreEqual ("test.aspx", p.DynamicBottomSeparatorImageUrl, "DynamicBottomSeparatorImageUrl");
231
232                         p.DynamicEnableDefaultPopOutImage = false;
233                         Assert.AreEqual (false,p.DynamicEnableDefaultPopOutImage, "DynamicEnableDefaultPopOutImage");
234
235                         p.DynamicHorizontalOffset = 10;
236                         Assert.AreEqual (10, p.DynamicHorizontalOffset, "DynamicHorizontalOffset");
237
238                         p.DynamicHoverStyle.BackColor = Color.Red;
239                         Assert.AreEqual (Color.Red ,p.DynamicHoverStyle.BackColor, "DynamicHoverStyle");
240
241                         p.DynamicItemFormatString = "Mytest";
242                         Assert.AreEqual ("Mytest", p.DynamicItemFormatString, "DynamicItemFormatString");
243
244                         MyWebControl.Image myImage = new MyWebControl.Image ();
245                         myImage.ImageUrl = "myimage.jpg";
246                         ImageTemplate Template = new ImageTemplate ();
247                         Template.MyImage = myImage;
248                         // end create template image
249                         p.DynamicItemTemplate = Template;
250                         Assert.IsNotNull (p.DynamicItemTemplate, "RootNodeTemplate");
251                         Assert.AreEqual (typeof (ImageTemplate), p.DynamicItemTemplate.GetType (), "RootNodeTemplate#1");
252
253                         p.DynamicMenuItemStyle.BackColor = Color.Red;                   
254                         Assert.AreEqual (Color.Red, p.DynamicMenuItemStyle.BackColor, "DynamicMenuItemStyle");
255
256                         p.DynamicMenuStyle.BackColor = Color.Red;
257                         Assert.AreEqual (Color.Red,p.DynamicMenuStyle.BackColor, "DynamicMenuStyle");
258
259                         p.DynamicPopOutImageUrl = "test";
260                         Assert.AreEqual ("test", p.DynamicPopOutImageUrl, "DynamicPopOutImageUrl");
261
262                         p.DynamicSelectedStyle.BackColor = Color.Red;
263                         Assert.AreEqual (Color.Red,p.DynamicSelectedStyle.BackColor, "DynamicSelectedStyle");
264
265                         p.DynamicTopSeparatorImageUrl = "test";
266                         Assert.AreEqual ("test", p.DynamicTopSeparatorImageUrl, "DynamicTopSeparatorImageUrl");
267
268                         p.DynamicVerticalOffset = 10;
269                         Assert.AreEqual (10, p.DynamicVerticalOffset, "DynamicVerticalOffset");
270
271                         MenuItem I = new MenuItem ();
272                         I.NavigateUrl = "default.aspx";
273                         I.Text = "MyText";
274                         I.ToolTip = "Test";
275                         p.Items.Add (I);
276                         Assert.AreEqual (1, p.Items.Count, "Items");
277
278                         p.ItemWrap = true;
279                         Assert.AreEqual (true, p.ItemWrap, "ItemWrap");
280
281                         MenuItemStyle S = new MenuItemStyle ();
282                         S.BackColor = Color.Red;
283                         p.LevelSelectedStyles.Add (S);
284                         Assert.AreEqual (1,p.LevelSelectedStyles.Count , "LevelSelectedStyles#1");
285                         Assert.AreEqual (true, p.LevelSelectedStyles.Contains (S), "LevelSelectedStyles#2");
286
287                         SubMenuStyle SM = new SubMenuStyle ();
288                         SM.BackColor = Color.Red;
289                         p.LevelSubMenuStyles.Add (SM);
290                         Assert.AreEqual(1, p.LevelSubMenuStyles.Count, "LevelSubMenuStyles#1");
291                         Assert.AreEqual (true, p.LevelSubMenuStyles.Contains (SM), "LevelSubMenuStyles#2");
292
293                         p.MaximumDynamicDisplayLevels = 5; 
294                         Assert.AreEqual (5, p.MaximumDynamicDisplayLevels, "MaximumDynamicDisplayLevels");
295
296                         p.Orientation = Orientation.Horizontal;
297                         Assert.AreEqual (Orientation.Horizontal, p.Orientation, "Orientation");
298
299                         p.PathSeparator = 'A';
300                         Assert.AreEqual ('A', p.PathSeparator, "PathSeparator");
301
302                         p.ScrollDownImageUrl = "test";
303                         Assert.AreEqual ("test", p.ScrollDownImageUrl, "ScrollDownImageUrl");
304
305                         p.ScrollDownText = "test";
306                         Assert.AreEqual ("test", p.ScrollDownText, "ScrollDownText");
307
308                         // This properties will be checked in events part of tests
309                         // Assert.AreEqual (0, p.SelectedItem, "p.SelectedItem");
310                         // Assert.AreEqual (string.Empty, p.SelectedValue, "SelectedValue");
311
312                         p.SkipLinkText = "test";
313                         Assert.AreEqual ("test", p.SkipLinkText, "SkipLinkText");
314
315                         p.StaticBottomSeparatorImageUrl = "test";
316                         Assert.AreEqual ("test", p.StaticBottomSeparatorImageUrl, "StaticBottomSeparatorImageUrl");
317
318                         p.StaticDisplayLevels = 2;
319                         Assert.AreEqual (2, p.StaticDisplayLevels, "StaticDisplayLevels");
320
321                         p.StaticEnableDefaultPopOutImage = false;
322                         Assert.AreEqual (false, p.StaticEnableDefaultPopOutImage, "StaticEnableDefaultPopOutImage");
323
324                         p.StaticHoverStyle.BackColor = Color.Red;
325                         Assert.AreEqual(Color.Red, p.StaticHoverStyle.BackColor, "StaticHoverStyle");
326
327                         p.StaticItemFormatString = "test";
328                         Assert.AreEqual ("test", p.StaticItemFormatString, "StaticItemFormatString");
329
330                         
331                         p.StaticItemTemplate = Template;
332                         Assert.IsNotNull (p.StaticItemTemplate, "StaticItemTemplate");
333
334                         p.StaticMenuItemStyle.BackColor = Color.Red;
335                         Assert.AreEqual(Color.Red,p.StaticMenuItemStyle.BackColor, "StaticMenuItemStyle");
336
337                         p.StaticMenuStyle.BackColor = Color.Red;
338                         Assert.AreEqual (Color.Red,p.StaticMenuStyle.BackColor, "StaticMenuStyle");
339
340                         p.StaticPopOutImageUrl = "test";
341                         Assert.AreEqual ("test", p.StaticPopOutImageUrl, "StaticPopOutImageUrl");
342
343                         p.StaticSelectedStyle.BackColor = Color.Red;
344                         Assert.AreEqual(Color.Red,p.StaticSelectedStyle.BackColor, "StaticSelectedStyle");
345
346                         p.StaticSubMenuIndent = 20;
347                         Assert.AreEqual (Unit.Pixel (20), p.StaticSubMenuIndent, "StaticSubMenuIndent");
348
349                         p.StaticTopSeparatorImageUrl = "test";
350                         Assert.AreEqual ("test", p.StaticTopSeparatorImageUrl, "StaticTopSeparatorImageUrl");
351
352                         p.Target = "test";
353                         Assert.AreEqual ("test", p.Target, "Target");
354                 }
355
356                 [Test]
357                 public void Menu_ChangeDefaultProperties_2 ()
358                 {
359                         PokerMenu p = new PokerMenu ();
360                         p.ScrollUpText = "test";
361                         Assert.AreEqual ("test", p.ScrollUpText, "ScrollUpText");
362                         p.DynamicPopOutImageTextFormatString = "test";
363                         Assert.AreEqual ("test", p.DynamicPopOutImageTextFormatString, "DynamicPopOutImageTextFormatString");
364                         p.StaticPopOutImageTextFormatString = "test";
365                         Assert.AreEqual ("test", p.StaticPopOutImageTextFormatString, "StaticPopOutImageTextFormatString");
366                 }
367
368                 [Test]
369                 public void Menu_ControlState()
370                 {
371                         PokerMenu p = new PokerMenu ();
372                         MenuItem I1 = new MenuItem ();
373                         MenuItem I2 = new MenuItem ();
374                         p.Items.Add (I1);
375                         p.Items.Add (I2);
376                         MenuEventArgs e = new MenuEventArgs (I1);
377                         p.DoOnMenuItemClick (e);
378                         object state = p.DoSaveControlState ();
379                         p.DoLoadControlState (state);
380                         e = new MenuEventArgs (I2);
381                         p.DoOnMenuItemClick (e);
382                         Console.WriteLine();
383                 }
384
385                 [Test]
386                 public void Menu_FindItem ()
387                 {
388                         PokerMenu p = new PokerMenu ();
389                         MenuItem I = new MenuItem ();
390                         string path = I.ValuePath;  
391                         p.Items.Add (I);
392                         MenuItem V = new MenuItem ();
393                         I.ChildItems.Add (V);
394                         MenuItem copy = p.FindItem (path);
395                         Assert.AreEqual (I, copy, "FindItem#1");
396                         path = V.ValuePath;
397                         Assert.AreEqual (V, p.FindItem (path), "FindItem#2");
398                 }
399
400                 
401                  // Set & Get DesignModeState dosn't tested 
402                  // Can't test on Page Load event 
403                  
404
405                 [Test]
406                 [Category ("NunitWeb")]
407                 public void Menu_RenderBeginTag ()
408                 {
409                         new WebTest (PageInvoker.CreateOnLoad (_BeginTagRender)).Run ();
410                 }
411
412                 public static void _BeginTagRender(Page p)
413                 {
414                         PokerMenu pm = new PokerMenu ();
415 #if NET_4_0
416                         pm.RenderingCompatibility = new Version (2, 0);
417 #endif
418                         p.Form.Controls.Add (pm);
419                         StringWriter sw = new StringWriter ();
420                         HtmlTextWriter tw = new HtmlTextWriter (sw);
421                         pm.RenderBeginTag (tw);
422                         string RenderedControlHtml = sw.ToString();
423 #if NET_4_0
424                         string OriginControlHtml = "<a href=\"#ctl01_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><table id=\"ctl01\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\">\r\n";
425 #else
426                         string OriginControlHtml = "<a href=\"#ctl01_SkipLink\"><img alt=\"Skip Navigation Links\" src=\"/NunitWeb/WebResource.axd?d=4RHYfeNnynkXiM59uthjZg2&amp;t=633802729995006876\" width=\"0\" height=\"0\" style=\"border-width:0px;\" /></a><table id=\"ctl01\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\">\r\n";
427 #endif
428                         HtmlDiff.AssertAreEqual(OriginControlHtml,RenderedControlHtml,"RenderBeginTag");
429                 }
430 #if NET_4_0
431                 [Test]
432                 [Category ("NunitWeb")]
433                 public void Menu_RenderBeginTag_List ()
434                 {
435                         new WebTest (PageInvoker.CreateOnLoad (_BeginTagRender_List)).Run ();
436                 }
437
438                 public static void _BeginTagRender_List (Page p)
439                 {
440                         PokerMenu pm = new PokerMenu ();
441                         pm.RenderingCompatibility = new Version (4, 0);
442                         pm.RenderingMode = MenuRenderingMode.List;
443
444                         p.Form.Controls.Add (pm);
445                         StringWriter sw = new StringWriter ();
446                         HtmlTextWriter tw = new HtmlTextWriter (sw);
447                         pm.RenderBeginTag (tw);
448                         string RenderedControlHtml = sw.ToString ();
449                         string OriginControlHtml = "<a href=\"#ctl01_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=\"ctl01\">\r\n";
450                         HtmlDiff.AssertAreEqual (OriginControlHtml, RenderedControlHtml, "RenderBeginTag_List");
451                 }
452 #endif
453                 [Test]
454                 [Category ("NunitWeb")]
455                 public void Menu_RenderEndTag ()
456                 {
457                         new WebTest (PageInvoker.CreateOnLoad (_EndTagRender)).Run ();
458                 }
459                 public static void _EndTagRender (Page p)
460                 {
461                         PokerMenu pm = new PokerMenu ();
462 #if NET_4_0
463                         pm.RenderingCompatibility = new Version (2, 0);
464 #endif
465                         p.Form.Controls.Add (pm);
466                         StringWriter sw = new StringWriter ();
467                         HtmlTextWriter tw = new HtmlTextWriter (sw);
468                         pm.RenderBeginTag (tw);
469                         pm.RenderEndTag (tw);
470                         string RenderedControlHtml = sw.ToString ();
471 #if NET_4_0
472                         string OriginControlHtml = "<a href=\"#ctl01_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><table id=\"ctl01\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\">\r\n\r\n</table><a id=\"ctl01_SkipLink\"></a>";
473 #else
474                         string OriginControlHtml = "<a href=\"#ctl01_SkipLink\"><img alt=\"Skip Navigation Links\" src=\"/NunitWeb/WebResource.axd?d=4RHYfeNnynkXiM59uthjZg2&amp;t=633802729995006876\" width=\"0\" height=\"0\" style=\"border-width:0px;\" /></a><table id=\"ctl01\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\">\r\n\r\n</table><a id=\"ctl01_SkipLink\"></a>";
475 #endif
476                         HtmlDiff.AssertAreEqual(OriginControlHtml, RenderedControlHtml,"RenderEndTag"); 
477                 }
478 #if NET_4_0
479                 [Test]
480                 [Category ("NunitWeb")]
481                 public void Menu_RenderEndTag_List ()
482                 {
483                         new WebTest (PageInvoker.CreateOnLoad (_EndTagRender_List)).Run ();
484                 }
485                 public static void _EndTagRender_List (Page p)
486                 {
487                         PokerMenu pm = new PokerMenu ();
488                         pm.RenderingCompatibility = new Version (4, 0);
489                         pm.RenderingMode = MenuRenderingMode.List;
490
491                         p.Form.Controls.Add (pm);
492                         StringWriter sw = new StringWriter ();
493                         HtmlTextWriter tw = new HtmlTextWriter (sw);
494                         pm.RenderBeginTag (tw);
495                         pm.RenderEndTag (tw);
496                         string RenderedControlHtml = sw.ToString ();
497                         string OriginControlHtml = "<a href=\"#ctl01_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=\"ctl01\">\r\n\r\n</div><a id=\"ctl01_SkipLink\"></a>";
498                         HtmlDiff.AssertAreEqual (OriginControlHtml, RenderedControlHtml, "RenderEndTag");
499                 }
500 #endif
501                 [Test]
502                 public void Menu_DataBind () {
503                         Page p = new Page ();
504                         Menu m = CreateMenu ();
505                         m.DataBinding += new EventHandler (m_DataBinding);
506                         m.DataBound += new EventHandler (m_DataBound);
507                         p.Controls.Add (m);
508
509                         ResetTemplateBoundFlags ();
510                         m.DataBind ();
511                 }
512
513                 static void m_DataBinding (object sender, EventArgs e) {
514                         Assert.AreEqual (true, _StaticTemplateCreated, "StaticTemplateCreated");
515                         Assert.AreEqual (true, _DynamicTemplateCreated, "DynamicTemplateCreated");
516                 }
517                 
518                 static void m_DataBound (object sender, EventArgs e) {
519                         Assert.AreEqual (true, _StaticTemplateBound, "StaticTemplateBound");
520                         Assert.AreEqual (true, _DynamicTemplateBound, "DynamicTemplateBound");
521                 }
522
523                 private static void ResetTemplateBoundFlags() {
524                         _StaticTemplateBound = false;
525                         _DynamicTemplateBound = false;
526                         _StaticTemplateCreated = false;
527                         _DynamicTemplateCreated = false;
528                 }
529
530                 static Menu CreateMenu () {
531                         Menu m = new MenuTable ();
532                         MenuItem rootItem = new MenuItem ("RootItem-Text", "RootItem-Value");
533                         m.Items.Add (rootItem);
534                         rootItem.ChildItems.Add (new MenuItem ("Node1-Text", "Node1-Value"));
535                         rootItem.ChildItems.Add (new MenuItem ("Node2-Text", "Node2-Value"));
536                         m.StaticItemTemplate = new CompiledTemplateBuilder (_StaticItemTemplate);
537                         m.DynamicItemTemplate = new CompiledTemplateBuilder (_DynamicItemTemplate);
538                         return m;
539                 }
540
541                 [Test]
542                 [Category ("NunitWeb")]
543                 public void Menu_DataBindByDataSourceID () {
544                         PageDelegates pd = new PageDelegates ();
545                         pd.Init = Menu_DataBindByDataSourceID_PageInit;
546                         pd.PreRenderComplete = Menu_DataBindByDataSourceID_PagePreRenderComplete;
547                         PageInvoker pi = new PageInvoker (pd);
548                         new WebTest (pi).Run ();
549                 }
550
551                 public static void Menu_DataBindByDataSourceID_PageInit (Page p) {
552                         XmlDataSource xmlDs = new XmlDataSource ();
553                         xmlDs.ID = "XmlDataSource";
554                         xmlDs.Data = "<root><node /><node /><node><subnode /><subnode /></node></root>";
555                         p.Form.Controls.Add (xmlDs);
556
557                         Menu m = CreateMenu ();
558 #if NET_4_0
559                         m.RenderingMode = MenuRenderingMode.Table;
560 #endif
561                         m.DataSourceID = "XmlDataSource";
562                         m.MenuItemDataBound += new MenuEventHandler (m_MenuItemDataBound);
563                         p.Form.Controls.Add (m);
564
565                         ResetTemplateBoundFlags ();
566                         _MenuItemBoundCount = 0;
567                         _MenuItemCreatedCount = 0;
568                 }
569
570                 public static void m_MenuItemDataBound (object sender, MenuEventArgs e) {
571                         _MenuItemBoundCount++;
572                 }
573
574                 [Test]
575                 [Category ("NunitWeb")]
576                 public void Menu_Templates () {
577                         PageDelegates pd = new PageDelegates ();
578                         pd.Init = Menu_Templates_PageInit;
579                         pd.PreRenderComplete = Menu_Templates_PagePreRenderComplete;
580                         PageInvoker pi = new PageInvoker (pd);
581                         new WebTest (pi).Run ();
582                 }
583
584                 public static void Menu_Templates_PageInit (Page p) {
585                         Menu m = CreateMenu ();
586                         p.Form.Controls.Add (m);
587
588                         ResetTemplateBoundFlags ();
589                 }
590
591                 static bool _StaticTemplateBound;
592                 static bool _DynamicTemplateBound;
593
594                 static bool _StaticTemplateCreated;
595                 static bool _DynamicTemplateCreated;
596
597                 static int _MenuItemBoundCount;
598                 static int _MenuItemCreatedCount;
599
600                 private static void CheckTemplateBoundFlags () {
601                         Assert.AreEqual (true, _StaticTemplateCreated, "StaticTemplateCreated");
602                         Assert.AreEqual (true, _DynamicTemplateCreated, "DynamicTemplateCreated");
603                         Assert.AreEqual (true, _StaticTemplateBound, "StaticTemplateBound");
604                         Assert.AreEqual (true, _DynamicTemplateBound, "DynamicTemplateBound");
605                 }
606
607                 public static void Menu_Templates_PagePreRenderComplete (Page p) {
608                         CheckTemplateBoundFlags ();
609                 }
610
611                 public static void Menu_DataBindByDataSourceID_PagePreRenderComplete (Page p) {
612                         CheckTemplateBoundFlags ();
613                         Assert.AreEqual (6, _MenuItemBoundCount, "MenuItemBoundCount");
614                         Assert.AreEqual (6, _MenuItemCreatedCount, "MenuItemBoundCount");
615                 }
616
617                 private static void _StaticItemTemplate (Control container) {
618                         _StaticTemplateCreated = true;
619                         _MenuItemCreatedCount++;
620                         Literal l = new Literal ();
621                         container.Controls.Add (l);
622                         container.DataBinding += new EventHandler (StaticTemplate_DataBinding);
623                 }
624
625                 static void StaticTemplate_DataBinding (object sender, EventArgs e) {
626                         _StaticTemplateBound = true;
627                 }
628
629                 private static void _DynamicItemTemplate (Control container) {
630                         _DynamicTemplateCreated = true;
631                         _MenuItemCreatedCount++;
632                         Literal l = new Literal ();
633                         container.Controls.Add (l);
634                         container.DataBinding += new EventHandler (DynamicTemplate_DataBinding);
635                 }
636
637                 static void DynamicTemplate_DataBinding (object sender, EventArgs e) {
638                         _DynamicTemplateBound = true;
639                 }
640
641                 [Test]
642                 public void Menu_ViewState()
643                 {
644                         PokerMenu b = new PokerMenu ();
645                         PokerMenu copy = new PokerMenu ();
646                         b.ToolTip = "mytest1";
647                         b.Target = "mytest2";
648                         b.BackColor = Color.Red;
649                         b.BorderColor = Color.Red;
650                         b.BorderStyle = BorderStyle.Dotted;
651                         b.BorderWidth = 1;
652                         b.ForeColor = Color.Red;
653                         b.Height = 100;
654                         b.MaximumDynamicDisplayLevels = 2;
655                         b.Orientation = Orientation.Vertical;
656                         b.PathSeparator = '-';
657                         b.ScrollDownImageUrl = "test";
658                         b.ScrollDownText = "test";
659                         b.ScrollUpImageUrl = "test";
660                         b.ScrollUpText = "test";
661                         b.SkipLinkText = "test";
662                         b.Visible = false;
663                         b.Width = 100;
664                         b.TabIndex = 1;
665                         
666                         object state = b.DoSaveViewState ();
667                         copy.DoLoadViewState (state);
668                         Assert.AreEqual ("mytest1", copy.ToolTip, "ViewState#1");
669                         Assert.AreEqual ("mytest2", copy.Target, "ViewState#2");
670                         Assert.AreEqual (Color.Red, copy.BackColor, "ViewState#3");
671                         Assert.AreEqual (Color.Red, copy.BorderColor , "ViewState#4");
672                         Assert.AreEqual (BorderStyle.Dotted, copy.BorderStyle, "ViewState#5");
673                         Assert.AreEqual (Unit.Pixel(1), copy.BorderWidth, "ViewState#6");
674                         
675                         Assert.AreEqual (Color.Red, copy.ForeColor, "ViewState#8");
676                         Assert.AreEqual (Unit.Pixel(100), copy.Height, "ViewState#9");
677                         Assert.AreEqual (2, copy.MaximumDynamicDisplayLevels, "ViewState#10");
678                         Assert.AreEqual (Orientation.Vertical, copy.Orientation, "ViewState#11");
679                         Assert.AreEqual ('-', copy.PathSeparator, "ViewState#12");
680                         Assert.AreEqual ("test", copy.ScrollDownImageUrl, "ViewState#13");
681                         Assert.AreEqual ("test", copy.ScrollDownText, "ViewState#14");
682                         Assert.AreEqual ("test", copy.ScrollUpImageUrl, "ViewState#15");
683                         Assert.AreEqual ("test", copy.ScrollUpText, "ViewState#16");
684                         Assert.AreEqual ("test", copy.SkipLinkText, "ViewState#17");
685                         Assert.AreEqual (1, copy.TabIndex, "ViewState#18");
686                         Assert.AreEqual (false, copy.Visible, "ViewState#19");
687                         Assert.AreEqual (Unit.Pixel (100), copy.Width, "ViewState#20");
688                 
689
690                 }
691
692                 [Test]
693                 public void Menu_ViewStateNotWorking()
694                 {
695                         PokerMenu b = new PokerMenu ();
696                         PokerMenu copy = new PokerMenu ();
697                         b.Font.Size = 10;
698                         object state = b.DoSaveViewState ();
699                         copy.DoLoadViewState (state);
700                         Assert.AreEqual ("10pt", copy.Font.Size.ToString() , "ViewState#7");                    
701                 }
702
703                 [Test]
704                 public void Menu_ViewStateItems () {
705                         PokerMenu b = new PokerMenu ();
706                         MenuItem R = new MenuItem ("root", "value-root");
707                         MenuItem N1 = new MenuItem ("node1", "value-node1");
708                         MenuItem N2 = new MenuItem ("node2", "value-node2");
709                         R.ChildItems.Add (N1);
710                         R.ChildItems.Add (N2);
711                         b.Items.Add (R);
712                         PokerMenu copy = new PokerMenu ();
713                         object state = b.DoSaveViewState ();
714                         copy.DoLoadViewState (state);
715                         Assert.AreEqual (1, copy.Items.Count, "ViewStateItems#1");
716                         Assert.AreEqual (2, copy.Items [0].ChildItems.Count, "ViewStateItems#2");
717                         Assert.AreEqual (0, copy.Items [0].ChildItems [0].ChildItems.Count, "ViewStateItems#3");
718                         Assert.AreEqual ("node1", copy.Items [0].ChildItems [0].Text, "ViewStateItems#4");
719                         Assert.AreEqual ("value-node1", copy.Items [0].ChildItems [0].Value, "ViewStateItems#5");
720                         Assert.AreEqual (false, copy.Items [0].ChildItems [0].DataBound, "ViewStateItems#6");
721                         Assert.AreEqual ("", copy.Items [0].ChildItems [0].DataPath, "ViewStateItems#7");
722                 }
723
724
725                 [Test]
726                 public void Menu_ViewStateDataBoundItems () {
727                         PokerMenu b = new PokerMenu ();
728                         SetDataBindings (b);
729                         b.DataSource = CreateXmlDataSource ();
730                         b.DataBind ();
731                         PokerMenu copy = new PokerMenu ();
732                         object state = b.DoSaveViewState ();
733                         copy.DoLoadViewState (state);
734                         CheckMenuItems (copy);
735                 }
736
737                 private static void CheckMenuItems (Menu m) {
738                         Assert.AreEqual (1, m.Items.Count, "CheckMenuItems#1");
739                         Assert.AreEqual (10, m.Items [0].ChildItems.Count, "CheckMenuItems#2");
740                         Assert.AreEqual (0, m.Items [0].ChildItems [0].ChildItems.Count, "CheckMenuItems#3");
741                         Assert.AreEqual (true, m.Items [0].ChildItems [0].DataBound, "CheckMenuItems#4");
742                         Assert.AreEqual ("/*[position()=1]/*[position()=1]", m.Items [0].ChildItems [0].DataPath, "CheckMenuItems#5");
743
744                         Assert.AreEqual (false, m.Items [0].Enabled, "CheckMenuItems_Enabled#1");
745                         Assert.AreEqual (true, m.Items [0].ChildItems [0].Enabled, "CheckMenuItems_Enabled#2");
746                         Assert.AreEqual (false, m.Items [0].ChildItems [1].Enabled, "CheckMenuItems_Enabled#3");
747                         Assert.AreEqual (false, m.Items [0].ChildItems [2].Enabled, "CheckMenuItems_Enabled#4");
748                         Assert.AreEqual (true, m.Items [0].ChildItems [2].ChildItems [0].Enabled, "CheckMenuItems_Enabled#5");
749
750                         Assert.AreEqual ("img#root", m.Items [0].ImageUrl, "CheckMenuItems_ImageUrl#1");
751                         Assert.AreEqual ("img#1", m.Items [0].ChildItems [0].ImageUrl, "CheckMenuItems_ImageUrl#2");
752                         Assert.AreEqual ("img#2", m.Items [0].ChildItems [1].ImageUrl, "CheckMenuItems_ImageUrl#3");
753                         Assert.AreEqual ("img#default", m.Items [0].ChildItems [2].ImageUrl, "CheckMenuItems_ImageUrl#4");
754                         Assert.AreEqual ("", m.Items [0].ChildItems [2].ChildItems [0].ImageUrl, "CheckMenuItems_ImageUrl#5");
755
756                         Assert.AreEqual ("url#root", m.Items [0].NavigateUrl, "CheckMenuItems_NavigateUrl#1");
757                         Assert.AreEqual ("url#1", m.Items [0].ChildItems [0].NavigateUrl, "CheckMenuItems_NavigateUrl#2");
758                         Assert.AreEqual ("url#2", m.Items [0].ChildItems [1].NavigateUrl, "CheckMenuItems_NavigateUrl#3");
759                         Assert.AreEqual ("url#default", m.Items [0].ChildItems [2].NavigateUrl, "CheckMenuItems_NavigateUrl#4");
760                         Assert.AreEqual ("", m.Items [0].ChildItems [2].ChildItems [0].NavigateUrl, "CheckMenuItems_NavigateUrl#5");
761
762                         Assert.AreEqual ("popoutimg#root", m.Items [0].PopOutImageUrl, "CheckMenuItems_PopOutImageUrl#1");
763                         Assert.AreEqual ("popoutimg#1", m.Items [0].ChildItems [0].PopOutImageUrl, "CheckMenuItems_PopOutImageUrl#2");
764                         Assert.AreEqual ("popoutimg#2", m.Items [0].ChildItems [1].PopOutImageUrl, "CheckMenuItems_PopOutImageUrl#3");
765                         Assert.AreEqual ("popoutimg#default", m.Items [0].ChildItems [2].PopOutImageUrl, "CheckMenuItems_PopOutImageUrl#4");
766                         Assert.AreEqual ("", m.Items [0].ChildItems [2].ChildItems [0].PopOutImageUrl, "CheckMenuItems_PopOutImageUrl#5");
767
768                         Assert.AreEqual (false, m.Items [0].Selectable, "CheckMenuItems_Selectable#1");
769                         Assert.AreEqual (true, m.Items [0].ChildItems [0].Selectable, "CheckMenuItems_Selectable#2");
770                         Assert.AreEqual (false, m.Items [0].ChildItems [1].Selectable, "CheckMenuItems_Selectable#3");
771                         Assert.AreEqual (false, m.Items [0].ChildItems [2].Selectable, "CheckMenuItems_Selectable#4");
772                         Assert.AreEqual (true, m.Items [0].ChildItems [2].ChildItems [0].Selectable, "CheckMenuItems_Selectable#5");
773
774                         Assert.AreEqual ("separatorimg#root", m.Items [0].SeparatorImageUrl, "CheckMenuItems_SeparatorImageUrl#1");
775                         Assert.AreEqual ("separatorimg#1", m.Items [0].ChildItems [0].SeparatorImageUrl, "CheckMenuItems_SeparatorImageUrl#2");
776                         Assert.AreEqual ("separatorimg#2", m.Items [0].ChildItems [1].SeparatorImageUrl, "CheckMenuItems_SeparatorImageUrl#3");
777                         Assert.AreEqual ("separatorimg#default", m.Items [0].ChildItems [2].SeparatorImageUrl, "CheckMenuItems_SeparatorImageUrl#4");
778                         Assert.AreEqual ("", m.Items [0].ChildItems [2].ChildItems [0].SeparatorImageUrl, "CheckMenuItems_SeparatorImageUrl#5");
779
780                         Assert.AreEqual ("target#root", m.Items [0].Target, "CheckMenuItems_Target#1");
781                         Assert.AreEqual ("target#1", m.Items [0].ChildItems [0].Target, "CheckMenuItems_Target#2");
782                         Assert.AreEqual ("target#2", m.Items [0].ChildItems [1].Target, "CheckMenuItems_Target#3");
783                         Assert.AreEqual ("target#default", m.Items [0].ChildItems [2].Target, "CheckMenuItems_Target#4");
784                         Assert.AreEqual ("", m.Items [0].ChildItems [2].ChildItems [0].Target, "CheckMenuItems_Target#5");
785
786                         Assert.AreEqual ("text#root", m.Items [0].Text, "CheckMenuItems_Text#1");
787                         Assert.AreEqual ("text#1", m.Items [0].ChildItems [0].Text, "CheckMenuItems_Text#2");
788                         Assert.AreEqual ("text#2", m.Items [0].ChildItems [1].Text, "CheckMenuItems_Text#3");
789                         Assert.AreEqual ("text#", m.Items [0].ChildItems [2].Text, "CheckMenuItems_Text#4");
790                         Assert.AreEqual ("subnode", m.Items [0].ChildItems [2].ChildItems [0].Text, "CheckMenuItems_Text#5");
791
792                         Assert.AreEqual ("tooltip#root", m.Items [0].ToolTip, "CheckMenuItems_ToolTip#1");
793                         Assert.AreEqual ("tooltip#1", m.Items [0].ChildItems [0].ToolTip, "CheckMenuItems_ToolTip#2");
794                         Assert.AreEqual ("tooltip#2", m.Items [0].ChildItems [1].ToolTip, "CheckMenuItems_ToolTip#3");
795                         Assert.AreEqual ("tooltip#default", m.Items [0].ChildItems [2].ToolTip, "CheckMenuItems_ToolTip#4");
796                         Assert.AreEqual ("", m.Items [0].ChildItems [2].ChildItems [0].ToolTip, "CheckMenuItems_ToolTip#5");
797
798                         Assert.AreEqual ("value#root", m.Items [0].Value, "CheckMenuItems_Value#1");
799                         Assert.AreEqual ("value#1", m.Items [0].ChildItems [0].Value, "CheckMenuItems_Value#2");
800                         Assert.AreEqual ("value#2", m.Items [0].ChildItems [1].Value, "CheckMenuItems_Value#3");
801                         Assert.AreEqual ("value#default", m.Items [0].ChildItems [2].Value, "CheckMenuItems_Value#4");
802                         Assert.AreEqual ("subnode", m.Items [0].ChildItems [2].ChildItems [0].Value, "CheckMenuItems_Value#5");
803
804                         Assert.AreEqual ("text#extra1", m.Items [0].ChildItems [3].Text, "CheckMenuItems_Extra1#1");
805                         Assert.AreEqual ("text#extra1", m.Items [0].ChildItems [3].Value, "CheckMenuItems_Extra1#2");
806
807                         Assert.AreEqual ("value#extra2", m.Items [0].ChildItems [4].Text, "CheckMenuItems_Extra2#1");
808                         Assert.AreEqual ("value#extra2", m.Items [0].ChildItems [4].Value, "CheckMenuItems_Extra2#2");
809
810                         Assert.AreEqual ("text#extra3", m.Items [0].ChildItems [5].Text, "CheckMenuItems_Extra3#1");
811                         Assert.AreEqual ("", m.Items [0].ChildItems [5].Value, "CheckMenuItems_Extra3#2");
812                         Assert.AreEqual ("", m.Items [0].ChildItems [6].Text, "CheckMenuItems_Extra3#3");
813                         Assert.AreEqual ("value#extra3", m.Items [0].ChildItems [6].Value, "CheckMenuItems_Extra3#4");
814                         Assert.AreEqual ("", m.Items [0].ChildItems [7].Text, "CheckMenuItems_Extra3#5");
815                         Assert.AreEqual ("", m.Items [0].ChildItems [7].Value, "CheckMenuItems_Extra3#6");
816
817                         Assert.AreEqual ("text#extra4", m.Items [0].ChildItems [8].Text, "CheckMenuItems_Extra4#1");
818                         Assert.AreEqual ("text#default", m.Items [0].ChildItems [8].Value, "CheckMenuItems_Extra4#2");
819
820                         Assert.AreEqual ("value#default", m.Items [0].ChildItems [9].Text, "CheckMenuItems_Extra5#1");
821                         Assert.AreEqual ("value#extra5", m.Items [0].ChildItems [9].Value, "CheckMenuItems_Extra5#2");
822                 }
823
824                 void SetDataBindings (Menu menu) {
825                         MenuItemBinding b = new MenuItemBinding ();
826                         b.DataMember = "node";
827                         b.EnabledField = "enabled";
828                         b.Enabled = false;
829                         b.ImageUrlField = "img";
830                         b.ImageUrl = "img#default";
831                         b.NavigateUrlField = "url";
832                         b.NavigateUrl = "url#default";
833                         b.PopOutImageUrlField = "popoutimg";
834                         b.PopOutImageUrl = "popoutimg#default";
835                         b.SelectableField = "selectable";
836                         b.Selectable = false;
837                         b.SeparatorImageUrlField = "separatorimg";
838                         b.SeparatorImageUrl = "separatorimg#default";
839                         b.TargetField = "target";
840                         b.Target = "target#default";
841                         b.FormatString = "text#{0}";
842                         b.TextField = "text";
843                         b.Text = "text#default";
844                         b.ToolTipField = "tooltip";
845                         b.ToolTip = "tooltip#default";
846                         b.ValueField = "value";
847                         b.Value = "value#default";
848                         menu.DataBindings.Add (b);
849
850                         b = new MenuItemBinding ();
851                         b.DataMember = "root";
852                         b.Enabled = false;
853                         b.ImageUrl = "img#root";
854                         b.NavigateUrl = "url#root";
855                         b.PopOutImageUrl = "popoutimg#root";
856                         b.Selectable = false;
857                         b.SeparatorImageUrl = "separatorimg#root";
858                         b.Target = "target#root";
859                         b.Text = "text#root";
860                         b.ToolTip = "tooltip#root";
861                         b.Value = "value#root";
862                         menu.DataBindings.Add (b);
863
864                         b = new MenuItemBinding ();
865                         b.DataMember = "extra1";
866                         b.Text = "text#extra1";
867                         menu.DataBindings.Add (b);
868
869                         b = new MenuItemBinding ();
870                         b.DataMember = "extra2";
871                         b.Value = "value#extra2";
872                         menu.DataBindings.Add (b);
873
874                         b = new MenuItemBinding ();
875                         b.DataMember = "extra3";
876                         b.TextField = "text";
877                         b.ValueField = "value";
878                         menu.DataBindings.Add (b);
879
880                         b = new MenuItemBinding ();
881                         b.DataMember = "extra4";
882                         b.TextField = "text";
883                         b.Text = "text#default";
884                         b.ValueField = "value";
885                         menu.DataBindings.Add (b);
886
887                         b = new MenuItemBinding ();
888                         b.DataMember = "extra5";
889                         b.TextField = "text";
890                         b.Value = "value#default";
891                         b.ValueField = "value";
892                         menu.DataBindings.Add (b);
893                 }
894
895                 XmlDataSource CreateXmlDataSource () {
896                         XmlDataSource xmlDs = new XmlDataSource ();
897                         xmlDs.ID = "XmlDataSource";
898                         xmlDs.Data = "<root>"+
899                                 "<node url=\"url#1\" img=\"img#1\" enabled=\"true\" selectable=\"true\" popoutimg=\"popoutimg#1\" separatorimg=\"separatorimg#1\" target=\"target#1\" text=\"1\" tooltip=\"tooltip#1\" value=\"value#1\" />" +
900                                 "<node url=\"url#2\" img=\"img#2\" enabled=\"false\" selectable=\"false\" popoutimg=\"popoutimg#2\" separatorimg=\"separatorimg#2\" target=\"target#2\" text=\"2\" tooltip=\"tooltip#2\" value=\"value#2\" />" +
901                                 "<node url=\"\" img=\"\" enabled=\"\" selectable=\"\" popoutimg=\"\" separatorimg=\"\" target=\"\" text=\"\" tooltip=\"\" value=\"\">" +
902                                 "<subnode url=\"url#unreachable\" img=\"img#unreachable\" enabled=\"false\" selectable=\"false\" popoutimg=\"popoutimg#unreachable\" separatorimg=\"separatorimg#unreachable\" target=\"target#unreachable\" text=\"text#unreachable\" tooltip=\"tooltip#unreachable\" value=\"value#unreachable\" />" +
903                                 "<subnode /></node>"+
904                                 "<extra1 /><extra2 />"+
905                                 "<extra3 text=\"text#extra3\" value=\"\" />" +
906                                 "<extra3 text=\"\" value=\"value#extra3\" />" +
907                                 "<extra3 text=\"\" value=\"\" />" +
908                                 "<extra4 text=\"text#extra4\" value=\"\" />" +
909                                 "<extra5 text=\"\" value=\"value#extra5\" />" +
910                                 "</root>";
911                         return xmlDs;
912                 }
913
914                 [Test]
915                 public void Menu_DataBindings () {
916                         Menu m = new MenuTable ();
917                         SetDataBindings (m);
918                         m.DataSource = CreateXmlDataSource ();
919                         m.DataBind ();
920                         CheckMenuItems (m);
921                 }
922
923                 // Rendering Menu controll with some possible options, styles and items
924                  
925
926                 [Test]
927                 [Category ("NunitWeb")]
928                 [Ignore ("NUNIT 2.4 issue - temporarily disabled")]
929                 public void Menu_DefaultRender ()
930                 {
931                         string RenderedPageHtml = new WebTest (PageInvoker.CreateOnLoad (_DefaultRender)).Run ();
932                         string RenderedControlHtml = HtmlDiff.GetControlFromPageHtml (RenderedPageHtml);
933                         string OriginControlHtml = "";
934                         HtmlDiff.AssertAreEqual(OriginControlHtml, RenderedControlHtml,"RenderDefault");
935                 }
936         
937                  // All this methods are delegates for running tests in host assembly. 
938                  
939                 public static void _DefaultRender (Page p)
940                 {
941                         LiteralControl lcb = new LiteralControl (HtmlDiff.BEGIN_TAG);
942                         LiteralControl lce = new LiteralControl (HtmlDiff.END_TAG);
943                         Menu menu = new MenuTable ();
944                         p.Form.Controls.Add (lcb);
945                         p.Form.Controls.Add (menu);
946                         p.Form.Controls.Add (lce);
947                 }
948
949                 [Test]
950                 [Category ("NunitWeb")]
951                 public void Menu_RenderStaticItems () {
952                         string RenderedPageHtml, RenderedControlHtml, OriginControlHtml;
953                         #region OriginControlHtml
954 #if NET_4_0
955                         OriginControlHtml = "<a href=\"#Menu_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><table id=\"Menu\" class=\"Menu_2\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\">\r\n\t<tr onmouseover=\"Menu_HoverRoot(this)\" onmouseout=\"Menu_Unhover(this)\" onkeyup=\"Menu_Key(this)\" id=\"Menun0\">\r\n\t\t<td><table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"100%\">\r\n\t\t\t<tr>\r\n\t\t\t\t<td style=\"white-space:nowrap;width:100%;\"><a class=\"Menu_1\" href=\"javascript:__doPostBack(&#39;Menu&#39;,&#39;one-black-value&#39;)\">one-black</a></td>\r\n\t\t\t</tr>\r\n\t\t</table></td>\r\n\t</tr><tr>\r\n\t\t<td><table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">\r\n\t\t\t<tr onmouseover=\"Menu_HoverRoot(this)\" onmouseout=\"Menu_Unhover(this)\" onkeyup=\"Menu_Key(this)\" id=\"Menun1\">\r\n\t\t\t\t<td><table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"100%\">\r\n\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t<td style=\"white-space:nowrap;width:100%;\"><a class=\"Menu_1\" href=\"javascript:__doPostBack(&#39;Menu&#39;,&#39;one-black-value\\\\two-black-1-value&#39;)\" style=\"margin-left:16px;\">two-black-1</a></td>\r\n\t\t\t\t\t</tr>\r\n\t\t\t\t</table></td>\r\n\t\t\t</tr><tr>\r\n\t\t\t\t<td><table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">\r\n\t\t\t\t\t<tr onmouseover=\"Menu_HoverRoot(this)\" onmouseout=\"Menu_Unhover(this)\" onkeyup=\"Menu_Key(this)\" id=\"Menun2\">\r\n\t\t\t\t\t\t<td><table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"100%\">\r\n\t\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t\t<td style=\"white-space:nowrap;width:100%;\"><a class=\"Menu_1\" href=\"javascript:__doPostBack(&#39;Menu&#39;,&#39;one-black-value\\\\two-black-1-value\\\\three-black-1-value&#39;)\" style=\"margin-left:32px;\">three-black-1</a></td>\r\n\t\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t</table></td>\r\n\t\t\t\t\t</tr><tr>\r\n\t\t\t\t\t\t<td><table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">\r\n\t\t\t\t\t\t\t<tr onmouseover=\"Menu_HoverStatic(this)\" onmouseout=\"Menu_Unhover(this)\" onkeyup=\"Menu_Key(this)\" id=\"Menun3\">\r\n\t\t\t\t\t\t\t\t<td><table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"100%\">\r\n\t\t\t\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t\t\t\t<td style=\"white-space:nowrap;width:100%;\"><a class=\"Menu_1\" href=\"javascript:__doPostBack(&#39;Menu&#39;,&#39;one-black-value\\\\two-black-1-value\\\\three-black-1-value\\\\four-black-1-value&#39;)\" style=\"margin-left:48px;\">four-black-1</a></td>\r\n\t\t\t\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t\t\t</table></td>\r\n\t\t\t\t\t\t\t</tr><tr onmouseover=\"Menu_HoverStatic(this)\" onmouseout=\"Menu_Unhover(this)\" onkeyup=\"Menu_Key(this)\" id=\"Menun4\">\r\n\t\t\t\t\t\t\t\t<td><table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"100%\">\r\n\t\t\t\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t\t\t\t<td style=\"white-space:nowrap;width:100%;\"><a class=\"Menu_1\" href=\"javascript:__doPostBack(&#39;Menu&#39;,&#39;one-black-value\\\\two-black-1-value\\\\three-black-1-value\\\\four-black-2-value&#39;)\" style=\"margin-left:48px;\">four-black-2</a></td>\r\n\t\t\t\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t\t\t</table></td>\r\n\t\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t</table></td>\r\n\t\t\t\t\t</tr><tr onmouseover=\"Menu_HoverRoot(this)\" onmouseout=\"Menu_Unhover(this)\" onkeyup=\"Menu_Key(this)\" id=\"Menun5\">\r\n\t\t\t\t\t\t<td><table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"100%\">\r\n\t\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t\t<td style=\"white-space:nowrap;width:100%;\"><a class=\"Menu_1\" href=\"javascript:__doPostBack(&#39;Menu&#39;,&#39;one-black-value\\\\two-black-1-value\\\\three-black-2-value&#39;)\" style=\"margin-left:32px;\">three-black-2</a></td>\r\n\t\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t</table></td>\r\n\t\t\t\t\t</tr><tr>\r\n\t\t\t\t\t\t<td><table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">\r\n\t\t\t\t\t\t\t<tr onmouseover=\"Menu_HoverStatic(this)\" onmouseout=\"Menu_Unhover(this)\" onkeyup=\"Menu_Key(this)\" id=\"Menun6\">\r\n\t\t\t\t\t\t\t\t<td><table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"100%\">\r\n\t\t\t\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t\t\t\t<td style=\"white-space:nowrap;width:100%;\"><a class=\"Menu_1\" href=\"javascript:__doPostBack(&#39;Menu&#39;,&#39;one-black-value\\\\two-black-1-value\\\\three-black-2-value\\\\four-black-3-value&#39;)\" style=\"margin-left:48px;\">four-black-3</a></td>\r\n\t\t\t\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t\t\t</table></td>\r\n\t\t\t\t\t\t\t</tr><tr onmouseover=\"Menu_HoverStatic(this)\" onmouseout=\"Menu_Unhover(this)\" onkeyup=\"Menu_Key(this)\" id=\"Menun7\">\r\n\t\t\t\t\t\t\t\t<td><table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"100%\">\r\n\t\t\t\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t\t\t\t<td style=\"white-space:nowrap;width:100%;\"><a class=\"Menu_1\" href=\"javascript:__doPostBack(&#39;Menu&#39;,&#39;one-black-value\\\\two-black-1-value\\\\three-black-2-value\\\\four-black-4-value&#39;)\" style=\"margin-left:48px;\">four-black-4</a></td>\r\n\t\t\t\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t\t\t</table></td>\r\n\t\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t</table></td>\r\n\t\t\t\t\t</tr>\r\n\t\t\t\t</table></td>\r\n\t\t\t</tr><tr onmouseover=\"Menu_HoverRoot(this)\" onmouseout=\"Menu_Unhover(this)\" onkeyup=\"Menu_Key(this)\" id=\"Menun8\">\r\n\t\t\t\t<td><table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"100%\">\r\n\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t<td style=\"white-space:nowrap;width:100%;\"><a class=\"Menu_1\" href=\"javascript:__doPostBack(&#39;Menu&#39;,&#39;one-black-value\\\\two-black-2-value&#39;)\" style=\"margin-left:16px;\">two-black-2</a></td>\r\n\t\t\t\t\t</tr>\r\n\t\t\t\t</table></td>\r\n\t\t\t</tr><tr>\r\n\t\t\t\t<td><table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">\r\n\t\t\t\t\t<tr onmouseover=\"Menu_HoverRoot(this)\" onmouseout=\"Menu_Unhover(this)\" onkeyup=\"Menu_Key(this)\" id=\"Menun9\">\r\n\t\t\t\t\t\t<td><table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"100%\">\r\n\t\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t\t<td style=\"white-space:nowrap;width:100%;\"><a class=\"Menu_1\" href=\"javascript:__doPostBack(&#39;Menu&#39;,&#39;one-black-value\\\\two-black-2-value\\\\three-black-3-value&#39;)\" style=\"margin-left:32px;\">three-black-3</a></td>\r\n\t\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t</table></td>\r\n\t\t\t\t\t</tr><tr>\r\n\t\t\t\t\t\t<td><table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">\r\n\t\t\t\t\t\t\t<tr onmouseover=\"Menu_HoverStatic(this)\" onmouseout=\"Menu_Unhover(this)\" onkeyup=\"Menu_Key(this)\" id=\"Menun10\">\r\n\t\t\t\t\t\t\t\t<td><table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"100%\">\r\n\t\t\t\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t\t\t\t<td style=\"white-space:nowrap;width:100%;\"><a class=\"Menu_1\" href=\"javascript:__doPostBack(&#39;Menu&#39;,&#39;one-black-value\\\\two-black-2-value\\\\three-black-3-value\\\\four-black-5-value&#39;)\" style=\"margin-left:48px;\">four-black-5</a></td>\r\n\t\t\t\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t\t\t</table></td>\r\n\t\t\t\t\t\t\t</tr><tr onmouseover=\"Menu_HoverStatic(this)\" onmouseout=\"Menu_Unhover(this)\" onkeyup=\"Menu_Key(this)\" id=\"Menun11\">\r\n\t\t\t\t\t\t\t\t<td><table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"100%\">\r\n\t\t\t\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t\t\t\t<td style=\"white-space:nowrap;width:100%;\"><a class=\"Menu_1\" href=\"javascript:__doPostBack(&#39;Menu&#39;,&#39;one-black-value\\\\two-black-2-value\\\\three-black-3-value\\\\four-black-6-value&#39;)\" style=\"margin-left:48px;\">four-black-6</a></td>\r\n\t\t\t\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t\t\t</table></td>\r\n\t\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t</table></td>\r\n\t\t\t\t\t</tr><tr onmouseover=\"Menu_HoverRoot(this)\" onmouseout=\"Menu_Unhover(this)\" onkeyup=\"Menu_Key(this)\" id=\"Menun12\">\r\n\t\t\t\t\t\t<td><table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"100%\">\r\n\t\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t\t<td style=\"white-space:nowrap;width:100%;\"><a class=\"Menu_1\" href=\"javascript:__doPostBack(&#39;Menu&#39;,&#39;one-black-value\\\\two-black-2-value\\\\three-black-4-value&#39;)\" style=\"margin-left:32px;\">three-black-4</a></td>\r\n\t\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t</table></td>\r\n\t\t\t\t\t</tr><tr>\r\n\t\t\t\t\t\t<td><table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">\r\n\t\t\t\t\t\t\t<tr onmouseover=\"Menu_HoverStatic(this)\" onmouseout=\"Menu_Unhover(this)\" onkeyup=\"Menu_Key(this)\" id=\"Menun13\">\r\n\t\t\t\t\t\t\t\t<td><table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"100%\">\r\n\t\t\t\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t\t\t\t<td style=\"white-space:nowrap;width:100%;\"><a class=\"Menu_1\" href=\"javascript:__doPostBack(&#39;Menu&#39;,&#39;one-black-value\\\\two-black-2-value\\\\three-black-4-value\\\\four-black-7-value&#39;)\" style=\"margin-left:48px;\">four-black-7</a></td>\r\n\t\t\t\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t\t\t</table></td>\r\n\t\t\t\t\t\t\t</tr><tr onmouseover=\"Menu_HoverStatic(this)\" onmouseout=\"Menu_Unhover(this)\" onkeyup=\"Menu_Key(this)\" id=\"Menun14\">\r\n\t\t\t\t\t\t\t\t<td><table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"100%\">\r\n\t\t\t\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t\t\t\t<td style=\"white-space:nowrap;width:100%;\"><a class=\"Menu_1\" href=\"javascript:__doPostBack(&#39;Menu&#39;,&#39;one-black-value\\\\two-black-2-value\\\\three-black-4-value\\\\four-black-8-value&#39;)\" style=\"margin-left:48px;\">four-black-8</a></td>\r\n\t\t\t\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t\t\t</table></td>\r\n\t\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t</table></td>\r\n\t\t\t\t\t</tr>\r\n\t\t\t\t</table></td>\r\n\t\t\t</tr>\r\n\t\t</table></td>\r\n\t</tr>\r\n</table><a id=\"Menu_SkipLink\"></a>";
956 #else
957                         OriginControlHtml = @"<a href=""#Menu_SkipLink""><img alt=""Skip Navigation Links"" src=""/NunitWeb/WebResource.axd?d=QxfUEifeQdL5PTiZOF8HlA2&amp;t=632900536532114160"" width=""0"" height=""0"" style=""border-width:0px;"" /></a><table id=""Menu"" class=""Menu_2"" cellpadding=""0"" cellspacing=""0"" border=""0"">
958         <tr onmouseover=""Menu_HoverRoot(this)"" onmouseout=""Menu_Unhover(this)"" onkeyup=""Menu_Key(this)"" id=""Menun0"">
959                 <td><table cellpadding=""0"" cellspacing=""0"" border=""0"" width=""100%"">
960                         <tr>
961                                 <td style=""white-space:nowrap;width:100%;""><a class=""Menu_1"" href=""javascript:__doPostBack('Menu','one-black-value')"">one-black</a></td>
962                         </tr>
963                 </table></td>
964         </tr><tr>
965                 <td><table border=""0"" cellpadding=""0"" cellspacing=""0"" width=""100%"">
966                         <tr onmouseover=""Menu_HoverRoot(this)"" onmouseout=""Menu_Unhover(this)"" onkeyup=""Menu_Key(this)"" id=""Menun1"">
967                                 <td><table cellpadding=""0"" cellspacing=""0"" border=""0"" width=""100%"">
968                                         <tr>
969                                                 <td style=""white-space:nowrap;width:100%;""><a class=""Menu_1"" href=""javascript:__doPostBack('Menu','one-black-value\\two-black-1-value')"" style=""margin-left:16px;"">two-black-1</a></td>
970                                         </tr>
971                                 </table></td>
972                         </tr><tr>
973                                 <td><table border=""0"" cellpadding=""0"" cellspacing=""0"" width=""100%"">
974                                         <tr onmouseover=""Menu_HoverRoot(this)"" onmouseout=""Menu_Unhover(this)"" onkeyup=""Menu_Key(this)"" id=""Menun2"">
975                                                 <td><table cellpadding=""0"" cellspacing=""0"" border=""0"" width=""100%"">
976                                                         <tr>
977                                                                 <td style=""white-space:nowrap;width:100%;""><a class=""Menu_1"" href=""javascript:__doPostBack('Menu','one-black-value\\two-black-1-value\\three-black-1-value')"" style=""margin-left:32px;"">three-black-1</a></td>
978                                                         </tr>
979                                                 </table></td>
980                                         </tr><tr>
981                                                 <td><table border=""0"" cellpadding=""0"" cellspacing=""0"" width=""100%"">
982                                                         <tr onmouseover=""Menu_HoverStatic(this)"" onmouseout=""Menu_Unhover(this)"" onkeyup=""Menu_Key(this)"" id=""Menun3"">
983                                                                 <td><table cellpadding=""0"" cellspacing=""0"" border=""0"" width=""100%"">
984                                                                         <tr>
985                                                                                 <td style=""white-space:nowrap;width:100%;""><a class=""Menu_1"" href=""javascript:__doPostBack('Menu','one-black-value\\two-black-1-value\\three-black-1-value\\four-black-1-value')"" style=""margin-left:48px;"">four-black-1</a></td>
986                                                                         </tr>
987                                                                 </table></td>
988                                                         </tr><tr onmouseover=""Menu_HoverStatic(this)"" onmouseout=""Menu_Unhover(this)"" onkeyup=""Menu_Key(this)"" id=""Menun4"">
989                                                                 <td><table cellpadding=""0"" cellspacing=""0"" border=""0"" width=""100%"">
990                                                                         <tr>
991                                                                                 <td style=""white-space:nowrap;width:100%;""><a class=""Menu_1"" href=""javascript:__doPostBack('Menu','one-black-value\\two-black-1-value\\three-black-1-value\\four-black-2-value')"" style=""margin-left:48px;"">four-black-2</a></td>
992                                                                         </tr>
993                                                                 </table></td>
994                                                         </tr>
995                                                 </table></td>
996                                         </tr><tr onmouseover=""Menu_HoverRoot(this)"" onmouseout=""Menu_Unhover(this)"" onkeyup=""Menu_Key(this)"" id=""Menun5"">
997                                                 <td><table cellpadding=""0"" cellspacing=""0"" border=""0"" width=""100%"">
998                                                         <tr>
999                                                                 <td style=""white-space:nowrap;width:100%;""><a class=""Menu_1"" href=""javascript:__doPostBack('Menu','one-black-value\\two-black-1-value\\three-black-2-value')"" style=""margin-left:32px;"">three-black-2</a></td>
1000                                                         </tr>
1001                                                 </table></td>
1002                                         </tr><tr>
1003                                                 <td><table border=""0"" cellpadding=""0"" cellspacing=""0"" width=""100%"">
1004                                                         <tr onmouseover=""Menu_HoverStatic(this)"" onmouseout=""Menu_Unhover(this)"" onkeyup=""Menu_Key(this)"" id=""Menun6"">
1005                                                                 <td><table cellpadding=""0"" cellspacing=""0"" border=""0"" width=""100%"">
1006                                                                         <tr>
1007                                                                                 <td style=""white-space:nowrap;width:100%;""><a class=""Menu_1"" href=""javascript:__doPostBack('Menu','one-black-value\\two-black-1-value\\three-black-2-value\\four-black-3-value')"" style=""margin-left:48px;"">four-black-3</a></td>
1008                                                                         </tr>
1009                                                                 </table></td>
1010                                                         </tr><tr onmouseover=""Menu_HoverStatic(this)"" onmouseout=""Menu_Unhover(this)"" onkeyup=""Menu_Key(this)"" id=""Menun7"">
1011                                                                 <td><table cellpadding=""0"" cellspacing=""0"" border=""0"" width=""100%"">
1012                                                                         <tr>
1013                                                                                 <td style=""white-space:nowrap;width:100%;""><a class=""Menu_1"" href=""javascript:__doPostBack('Menu','one-black-value\\two-black-1-value\\three-black-2-value\\four-black-4-value')"" style=""margin-left:48px;"">four-black-4</a></td>
1014                                                                         </tr>
1015                                                                 </table></td>
1016                                                         </tr>
1017                                                 </table></td>
1018                                         </tr>
1019                                 </table></td>
1020                         </tr><tr onmouseover=""Menu_HoverRoot(this)"" onmouseout=""Menu_Unhover(this)"" onkeyup=""Menu_Key(this)"" id=""Menun8"">
1021                                 <td><table cellpadding=""0"" cellspacing=""0"" border=""0"" width=""100%"">
1022                                         <tr>
1023                                                 <td style=""white-space:nowrap;width:100%;""><a class=""Menu_1"" href=""javascript:__doPostBack('Menu','one-black-value\\two-black-2-value')"" style=""margin-left:16px;"">two-black-2</a></td>
1024                                         </tr>
1025                                 </table></td>
1026                         </tr><tr>
1027                                 <td><table border=""0"" cellpadding=""0"" cellspacing=""0"" width=""100%"">
1028                                         <tr onmouseover=""Menu_HoverRoot(this)"" onmouseout=""Menu_Unhover(this)"" onkeyup=""Menu_Key(this)"" id=""Menun9"">
1029                                                 <td><table cellpadding=""0"" cellspacing=""0"" border=""0"" width=""100%"">
1030                                                         <tr>
1031                                                                 <td style=""white-space:nowrap;width:100%;""><a class=""Menu_1"" href=""javascript:__doPostBack('Menu','one-black-value\\two-black-2-value\\three-black-3-value')"" style=""margin-left:32px;"">three-black-3</a></td>
1032                                                         </tr>
1033                                                 </table></td>
1034                                         </tr><tr>
1035                                                 <td><table border=""0"" cellpadding=""0"" cellspacing=""0"" width=""100%"">
1036                                                         <tr onmouseover=""Menu_HoverStatic(this)"" onmouseout=""Menu_Unhover(this)"" onkeyup=""Menu_Key(this)"" id=""Menun10"">
1037                                                                 <td><table cellpadding=""0"" cellspacing=""0"" border=""0"" width=""100%"">
1038                                                                         <tr>
1039                                                                                 <td style=""white-space:nowrap;width:100%;""><a class=""Menu_1"" href=""javascript:__doPostBack('Menu','one-black-value\\two-black-2-value\\three-black-3-value\\four-black-5-value')"" style=""margin-left:48px;"">four-black-5</a></td>
1040                                                                         </tr>
1041                                                                 </table></td>
1042                                                         </tr><tr onmouseover=""Menu_HoverStatic(this)"" onmouseout=""Menu_Unhover(this)"" onkeyup=""Menu_Key(this)"" id=""Menun11"">
1043                                                                 <td><table cellpadding=""0"" cellspacing=""0"" border=""0"" width=""100%"">
1044                                                                         <tr>
1045                                                                                 <td style=""white-space:nowrap;width:100%;""><a class=""Menu_1"" href=""javascript:__doPostBack('Menu','one-black-value\\two-black-2-value\\three-black-3-value\\four-black-6-value')"" style=""margin-left:48px;"">four-black-6</a></td>
1046                                                                         </tr>
1047                                                                 </table></td>
1048                                                         </tr>
1049                                                 </table></td>
1050                                         </tr><tr onmouseover=""Menu_HoverRoot(this)"" onmouseout=""Menu_Unhover(this)"" onkeyup=""Menu_Key(this)"" id=""Menun12"">
1051                                                 <td><table cellpadding=""0"" cellspacing=""0"" border=""0"" width=""100%"">
1052                                                         <tr>
1053                                                                 <td style=""white-space:nowrap;width:100%;""><a class=""Menu_1"" href=""javascript:__doPostBack('Menu','one-black-value\\two-black-2-value\\three-black-4-value')"" style=""margin-left:32px;"">three-black-4</a></td>
1054                                                         </tr>
1055                                                 </table></td>
1056                                         </tr><tr>
1057                                                 <td><table border=""0"" cellpadding=""0"" cellspacing=""0"" width=""100%"">
1058                                                         <tr onmouseover=""Menu_HoverStatic(this)"" onmouseout=""Menu_Unhover(this)"" onkeyup=""Menu_Key(this)"" id=""Menun13"">
1059                                                                 <td><table cellpadding=""0"" cellspacing=""0"" border=""0"" width=""100%"">
1060                                                                         <tr>
1061                                                                                 <td style=""white-space:nowrap;width:100%;""><a class=""Menu_1"" href=""javascript:__doPostBack('Menu','one-black-value\\two-black-2-value\\three-black-4-value\\four-black-7-value')"" style=""margin-left:48px;"">four-black-7</a></td>
1062                                                                         </tr>
1063                                                                 </table></td>
1064                                                         </tr><tr onmouseover=""Menu_HoverStatic(this)"" onmouseout=""Menu_Unhover(this)"" onkeyup=""Menu_Key(this)"" id=""Menun14"">
1065                                                                 <td><table cellpadding=""0"" cellspacing=""0"" border=""0"" width=""100%"">
1066                                                                         <tr>
1067                                                                                 <td style=""white-space:nowrap;width:100%;""><a class=""Menu_1"" href=""javascript:__doPostBack('Menu','one-black-value\\two-black-2-value\\three-black-4-value\\four-black-8-value')"" style=""margin-left:48px;"">four-black-8</a></td>
1068                                                                         </tr>
1069                                                                 </table></td>
1070                                                         </tr>
1071                                                 </table></td>
1072                                         </tr>
1073                                 </table></td>
1074                         </tr>
1075                 </table></td>
1076         </tr>
1077 </table><a id=""Menu_SkipLink""></a>";
1078 #endif
1079                         #endregion
1080                         RenderedPageHtml = new WebTest (PageInvoker.CreateOnLoad (Menu_RenderStaticItems_Vertical)).Run ();
1081                         RenderedControlHtml = HtmlDiff.GetControlFromPageHtml (RenderedPageHtml);
1082                         HtmlDiff.AssertAreEqual (OriginControlHtml, RenderedControlHtml, "Menu_RenderStaticItems_Vertical");
1083 #if !NET_4_0 || (NET_4_0 && !DOT_NET)
1084                         // Throws NREX on .NET 4.0, most probably because the adapter's Control is null
1085                         RenderedPageHtml = new WebTest (PageInvoker.CreateOnLoad (Menu_RenderStaticItemsWithBaseAdapter_Vertical)).Run ();
1086                         RenderedControlHtml = HtmlDiff.GetControlFromPageHtml (RenderedPageHtml);
1087                         HtmlDiff.AssertAreEqual (OriginControlHtml, RenderedControlHtml, "Menu_RenderStaticItemsWithDefaultAdapter_Vertical");
1088 #endif
1089                         #region OriginControlHtml
1090 #if NET_4_0
1091                         OriginControlHtml = "<a href=\"#Menu_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><table id=\"Menu\" class=\"Menu_2\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\">\r\n\t<tr>\r\n\t\t<td onmouseover=\"Menu_HoverRoot(this)\" onmouseout=\"Menu_Unhover(this)\" onkeyup=\"Menu_Key(this)\" id=\"Menun0\"><table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"100%\">\r\n\t\t\t<tr>\r\n\t\t\t\t<td style=\"white-space:nowrap;\"><a class=\"Menu_1\" href=\"javascript:__doPostBack(&#39;Menu&#39;,&#39;one-black-value&#39;)\">one-black</a></td>\r\n\t\t\t</tr>\r\n\t\t</table></td><td style=\"width:3px;\"></td><td><table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">\r\n\t\t\t<tr>\r\n\t\t\t\t<td onmouseover=\"Menu_HoverRoot(this)\" onmouseout=\"Menu_Unhover(this)\" onkeyup=\"Menu_Key(this)\" id=\"Menun1\"><table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"100%\">\r\n\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t<td style=\"white-space:nowrap;\"><a class=\"Menu_1\" href=\"javascript:__doPostBack(&#39;Menu&#39;,&#39;one-black-value\\\\two-black-1-value&#39;)\" style=\"margin-left:16px;\">two-black-1</a></td>\r\n\t\t\t\t\t</tr>\r\n\t\t\t\t</table></td><td style=\"width:3px;\"></td><td><table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">\r\n\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t<td onmouseover=\"Menu_HoverRoot(this)\" onmouseout=\"Menu_Unhover(this)\" onkeyup=\"Menu_Key(this)\" id=\"Menun2\"><table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"100%\">\r\n\t\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t\t<td style=\"white-space:nowrap;\"><a class=\"Menu_1\" href=\"javascript:__doPostBack(&#39;Menu&#39;,&#39;one-black-value\\\\two-black-1-value\\\\three-black-1-value&#39;)\" style=\"margin-left:32px;\">three-black-1</a></td>\r\n\t\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t</table></td><td style=\"width:3px;\"></td><td><table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">\r\n\t\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t\t<td onmouseover=\"Menu_HoverStatic(this)\" onmouseout=\"Menu_Unhover(this)\" onkeyup=\"Menu_Key(this)\" id=\"Menun3\"><table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"100%\">\r\n\t\t\t\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t\t\t\t<td style=\"white-space:nowrap;\"><a class=\"Menu_1\" href=\"javascript:__doPostBack(&#39;Menu&#39;,&#39;one-black-value\\\\two-black-1-value\\\\three-black-1-value\\\\four-black-1-value&#39;)\" style=\"margin-left:48px;\">four-black-1</a></td>\r\n\t\t\t\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t\t\t</table></td><td style=\"width:3px;\"></td><td onmouseover=\"Menu_HoverStatic(this)\" onmouseout=\"Menu_Unhover(this)\" onkeyup=\"Menu_Key(this)\" id=\"Menun4\"><table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"100%\">\r\n\t\t\t\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t\t\t\t<td style=\"white-space:nowrap;\"><a class=\"Menu_1\" href=\"javascript:__doPostBack(&#39;Menu&#39;,&#39;one-black-value\\\\two-black-1-value\\\\three-black-1-value\\\\four-black-2-value&#39;)\" style=\"margin-left:48px;\">four-black-2</a></td>\r\n\t\t\t\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t\t\t</table></td><td style=\"width:3px;\"></td>\r\n\t\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t</table></td><td onmouseover=\"Menu_HoverRoot(this)\" onmouseout=\"Menu_Unhover(this)\" onkeyup=\"Menu_Key(this)\" id=\"Menun5\"><table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"100%\">\r\n\t\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t\t<td style=\"white-space:nowrap;\"><a class=\"Menu_1\" href=\"javascript:__doPostBack(&#39;Menu&#39;,&#39;one-black-value\\\\two-black-1-value\\\\three-black-2-value&#39;)\" style=\"margin-left:32px;\">three-black-2</a></td>\r\n\t\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t</table></td><td style=\"width:3px;\"></td><td><table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">\r\n\t\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t\t<td onmouseover=\"Menu_HoverStatic(this)\" onmouseout=\"Menu_Unhover(this)\" onkeyup=\"Menu_Key(this)\" id=\"Menun6\"><table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"100%\">\r\n\t\t\t\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t\t\t\t<td style=\"white-space:nowrap;\"><a class=\"Menu_1\" href=\"javascript:__doPostBack(&#39;Menu&#39;,&#39;one-black-value\\\\two-black-1-value\\\\three-black-2-value\\\\four-black-3-value&#39;)\" style=\"margin-left:48px;\">four-black-3</a></td>\r\n\t\t\t\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t\t\t</table></td><td style=\"width:3px;\"></td><td onmouseover=\"Menu_HoverStatic(this)\" onmouseout=\"Menu_Unhover(this)\" onkeyup=\"Menu_Key(this)\" id=\"Menun7\"><table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"100%\">\r\n\t\t\t\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t\t\t\t<td style=\"white-space:nowrap;\"><a class=\"Menu_1\" href=\"javascript:__doPostBack(&#39;Menu&#39;,&#39;one-black-value\\\\two-black-1-value\\\\three-black-2-value\\\\four-black-4-value&#39;)\" style=\"margin-left:48px;\">four-black-4</a></td>\r\n\t\t\t\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t\t\t</table></td><td style=\"width:3px;\"></td>\r\n\t\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t</table></td>\r\n\t\t\t\t\t</tr>\r\n\t\t\t\t</table></td><td onmouseover=\"Menu_HoverRoot(this)\" onmouseout=\"Menu_Unhover(this)\" onkeyup=\"Menu_Key(this)\" id=\"Menun8\"><table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"100%\">\r\n\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t<td style=\"white-space:nowrap;\"><a class=\"Menu_1\" href=\"javascript:__doPostBack(&#39;Menu&#39;,&#39;one-black-value\\\\two-black-2-value&#39;)\" style=\"margin-left:16px;\">two-black-2</a></td>\r\n\t\t\t\t\t</tr>\r\n\t\t\t\t</table></td><td style=\"width:3px;\"></td><td><table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">\r\n\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t<td onmouseover=\"Menu_HoverRoot(this)\" onmouseout=\"Menu_Unhover(this)\" onkeyup=\"Menu_Key(this)\" id=\"Menun9\"><table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"100%\">\r\n\t\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t\t<td style=\"white-space:nowrap;\"><a class=\"Menu_1\" href=\"javascript:__doPostBack(&#39;Menu&#39;,&#39;one-black-value\\\\two-black-2-value\\\\three-black-3-value&#39;)\" style=\"margin-left:32px;\">three-black-3</a></td>\r\n\t\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t</table></td><td style=\"width:3px;\"></td><td><table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">\r\n\t\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t\t<td onmouseover=\"Menu_HoverStatic(this)\" onmouseout=\"Menu_Unhover(this)\" onkeyup=\"Menu_Key(this)\" id=\"Menun10\"><table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"100%\">\r\n\t\t\t\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t\t\t\t<td style=\"white-space:nowrap;\"><a class=\"Menu_1\" href=\"javascript:__doPostBack(&#39;Menu&#39;,&#39;one-black-value\\\\two-black-2-value\\\\three-black-3-value\\\\four-black-5-value&#39;)\" style=\"margin-left:48px;\">four-black-5</a></td>\r\n\t\t\t\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t\t\t</table></td><td style=\"width:3px;\"></td><td onmouseover=\"Menu_HoverStatic(this)\" onmouseout=\"Menu_Unhover(this)\" onkeyup=\"Menu_Key(this)\" id=\"Menun11\"><table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"100%\">\r\n\t\t\t\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t\t\t\t<td style=\"white-space:nowrap;\"><a class=\"Menu_1\" href=\"javascript:__doPostBack(&#39;Menu&#39;,&#39;one-black-value\\\\two-black-2-value\\\\three-black-3-value\\\\four-black-6-value&#39;)\" style=\"margin-left:48px;\">four-black-6</a></td>\r\n\t\t\t\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t\t\t</table></td><td style=\"width:3px;\"></td>\r\n\t\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t</table></td><td onmouseover=\"Menu_HoverRoot(this)\" onmouseout=\"Menu_Unhover(this)\" onkeyup=\"Menu_Key(this)\" id=\"Menun12\"><table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"100%\">\r\n\t\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t\t<td style=\"white-space:nowrap;\"><a class=\"Menu_1\" href=\"javascript:__doPostBack(&#39;Menu&#39;,&#39;one-black-value\\\\two-black-2-value\\\\three-black-4-value&#39;)\" style=\"margin-left:32px;\">three-black-4</a></td>\r\n\t\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t</table></td><td style=\"width:3px;\"></td><td><table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">\r\n\t\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t\t<td onmouseover=\"Menu_HoverStatic(this)\" onmouseout=\"Menu_Unhover(this)\" onkeyup=\"Menu_Key(this)\" id=\"Menun13\"><table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"100%\">\r\n\t\t\t\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t\t\t\t<td style=\"white-space:nowrap;\"><a class=\"Menu_1\" href=\"javascript:__doPostBack(&#39;Menu&#39;,&#39;one-black-value\\\\two-black-2-value\\\\three-black-4-value\\\\four-black-7-value&#39;)\" style=\"margin-left:48px;\">four-black-7</a></td>\r\n\t\t\t\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t\t\t</table></td><td style=\"width:3px;\"></td><td onmouseover=\"Menu_HoverStatic(this)\" onmouseout=\"Menu_Unhover(this)\" onkeyup=\"Menu_Key(this)\" id=\"Menun14\"><table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"100%\">\r\n\t\t\t\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t\t\t\t<td style=\"white-space:nowrap;\"><a class=\"Menu_1\" href=\"javascript:__doPostBack(&#39;Menu&#39;,&#39;one-black-value\\\\two-black-2-value\\\\three-black-4-value\\\\four-black-8-value&#39;)\" style=\"margin-left:48px;\">four-black-8</a></td>\r\n\t\t\t\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t\t\t</table></td>\r\n\t\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t</table></td>\r\n\t\t\t\t\t</tr>\r\n\t\t\t\t</table></td>\r\n\t\t\t</tr>\r\n\t\t</table></td>\r\n\t</tr>\r\n</table><a id=\"Menu_SkipLink\"></a>";
1092 #else
1093                         OriginControlHtml = @"<a href=""#Menu_SkipLink""><img alt=""Skip Navigation Links"" src=""/NunitWeb/WebResource.axd?d=QxfUEifeQdL5PTiZOF8HlA2&amp;t=632900536532114160"" width=""0"" height=""0"" style=""border-width:0px;"" /></a><table id=""Menu"" class=""Menu_2"" cellpadding=""0"" cellspacing=""0"" border=""0"">
1094         <tr>
1095                 <td onmouseover=""Menu_HoverRoot(this)"" onmouseout=""Menu_Unhover(this)"" onkeyup=""Menu_Key(this)"" id=""Menun0""><table cellpadding=""0"" cellspacing=""0"" border=""0"" width=""100%"">
1096                         <tr>
1097                                 <td style=""white-space:nowrap;""><a class=""Menu_1"" href=""javascript:__doPostBack('Menu','one-black-value')"">one-black</a></td>
1098                         </tr>
1099                 </table></td><td style=""width:3px;""></td><td><table border=""0"" cellpadding=""0"" cellspacing=""0"" width=""100%"">
1100                         <tr>
1101                                 <td onmouseover=""Menu_HoverRoot(this)"" onmouseout=""Menu_Unhover(this)"" onkeyup=""Menu_Key(this)"" id=""Menun1""><table cellpadding=""0"" cellspacing=""0"" border=""0"" width=""100%"">
1102                                         <tr>
1103                                                 <td style=""white-space:nowrap;""><a class=""Menu_1"" href=""javascript:__doPostBack('Menu','one-black-value\\two-black-1-value')"" style=""margin-left:16px;"">two-black-1</a></td>
1104                                         </tr>
1105                                 </table></td><td style=""width:3px;""></td><td><table border=""0"" cellpadding=""0"" cellspacing=""0"" width=""100%"">
1106                                         <tr>
1107                                                 <td onmouseover=""Menu_HoverRoot(this)"" onmouseout=""Menu_Unhover(this)"" onkeyup=""Menu_Key(this)"" id=""Menun2""><table cellpadding=""0"" cellspacing=""0"" border=""0"" width=""100%"">
1108                                                         <tr>
1109                                                                 <td style=""white-space:nowrap;""><a class=""Menu_1"" href=""javascript:__doPostBack('Menu','one-black-value\\two-black-1-value\\three-black-1-value')"" style=""margin-left:32px;"">three-black-1</a></td>
1110                                                         </tr>
1111                                                 </table></td><td style=""width:3px;""></td><td><table border=""0"" cellpadding=""0"" cellspacing=""0"" width=""100%"">
1112                                                         <tr>
1113                                                                 <td onmouseover=""Menu_HoverStatic(this)"" onmouseout=""Menu_Unhover(this)"" onkeyup=""Menu_Key(this)"" id=""Menun3""><table cellpadding=""0"" cellspacing=""0"" border=""0"" width=""100%"">
1114                                                                         <tr>
1115                                                                                 <td style=""white-space:nowrap;""><a class=""Menu_1"" href=""javascript:__doPostBack('Menu','one-black-value\\two-black-1-value\\three-black-1-value\\four-black-1-value')"" style=""margin-left:48px;"">four-black-1</a></td>
1116                                                                         </tr>
1117                                                                 </table></td><td style=""width:3px;""></td><td onmouseover=""Menu_HoverStatic(this)"" onmouseout=""Menu_Unhover(this)"" onkeyup=""Menu_Key(this)"" id=""Menun4""><table cellpadding=""0"" cellspacing=""0"" border=""0"" width=""100%"">
1118                                                                         <tr>
1119                                                                                 <td style=""white-space:nowrap;""><a class=""Menu_1"" href=""javascript:__doPostBack('Menu','one-black-value\\two-black-1-value\\three-black-1-value\\four-black-2-value')"" style=""margin-left:48px;"">four-black-2</a></td>
1120                                                                         </tr>
1121                                                                 </table></td><td style=""width:3px;""></td>
1122                                                         </tr>
1123                                                 </table></td><td onmouseover=""Menu_HoverRoot(this)"" onmouseout=""Menu_Unhover(this)"" onkeyup=""Menu_Key(this)"" id=""Menun5""><table cellpadding=""0"" cellspacing=""0"" border=""0"" width=""100%"">
1124                                                         <tr>
1125                                                                 <td style=""white-space:nowrap;""><a class=""Menu_1"" href=""javascript:__doPostBack('Menu','one-black-value\\two-black-1-value\\three-black-2-value')"" style=""margin-left:32px;"">three-black-2</a></td>
1126                                                         </tr>
1127                                                 </table></td><td style=""width:3px;""></td><td><table border=""0"" cellpadding=""0"" cellspacing=""0"" width=""100%"">
1128                                                         <tr>
1129                                                                 <td onmouseover=""Menu_HoverStatic(this)"" onmouseout=""Menu_Unhover(this)"" onkeyup=""Menu_Key(this)"" id=""Menun6""><table cellpadding=""0"" cellspacing=""0"" border=""0"" width=""100%"">
1130                                                                         <tr>
1131                                                                                 <td style=""white-space:nowrap;""><a class=""Menu_1"" href=""javascript:__doPostBack('Menu','one-black-value\\two-black-1-value\\three-black-2-value\\four-black-3-value')"" style=""margin-left:48px;"">four-black-3</a></td>
1132                                                                         </tr>
1133                                                                 </table></td><td style=""width:3px;""></td><td onmouseover=""Menu_HoverStatic(this)"" onmouseout=""Menu_Unhover(this)"" onkeyup=""Menu_Key(this)"" id=""Menun7""><table cellpadding=""0"" cellspacing=""0"" border=""0"" width=""100%"">
1134                                                                         <tr>
1135                                                                                 <td style=""white-space:nowrap;""><a class=""Menu_1"" href=""javascript:__doPostBack('Menu','one-black-value\\two-black-1-value\\three-black-2-value\\four-black-4-value')"" style=""margin-left:48px;"">four-black-4</a></td>
1136                                                                         </tr>
1137                                                                 </table></td><td style=""width:3px;""></td>
1138                                                         </tr>
1139                                                 </table></td>
1140                                         </tr>
1141                                 </table></td><td onmouseover=""Menu_HoverRoot(this)"" onmouseout=""Menu_Unhover(this)"" onkeyup=""Menu_Key(this)"" id=""Menun8""><table cellpadding=""0"" cellspacing=""0"" border=""0"" width=""100%"">
1142                                         <tr>
1143                                                 <td style=""white-space:nowrap;""><a class=""Menu_1"" href=""javascript:__doPostBack('Menu','one-black-value\\two-black-2-value')"" style=""margin-left:16px;"">two-black-2</a></td>
1144                                         </tr>
1145                                 </table></td><td style=""width:3px;""></td><td><table border=""0"" cellpadding=""0"" cellspacing=""0"" width=""100%"">
1146                                         <tr>
1147                                                 <td onmouseover=""Menu_HoverRoot(this)"" onmouseout=""Menu_Unhover(this)"" onkeyup=""Menu_Key(this)"" id=""Menun9""><table cellpadding=""0"" cellspacing=""0"" border=""0"" width=""100%"">
1148                                                         <tr>
1149                                                                 <td style=""white-space:nowrap;""><a class=""Menu_1"" href=""javascript:__doPostBack('Menu','one-black-value\\two-black-2-value\\three-black-3-value')"" style=""margin-left:32px;"">three-black-3</a></td>
1150                                                         </tr>
1151                                                 </table></td><td style=""width:3px;""></td><td><table border=""0"" cellpadding=""0"" cellspacing=""0"" width=""100%"">
1152                                                         <tr>
1153                                                                 <td onmouseover=""Menu_HoverStatic(this)"" onmouseout=""Menu_Unhover(this)"" onkeyup=""Menu_Key(this)"" id=""Menun10""><table cellpadding=""0"" cellspacing=""0"" border=""0"" width=""100%"">
1154                                                                         <tr>
1155                                                                                 <td style=""white-space:nowrap;""><a class=""Menu_1"" href=""javascript:__doPostBack('Menu','one-black-value\\two-black-2-value\\three-black-3-value\\four-black-5-value')"" style=""margin-left:48px;"">four-black-5</a></td>
1156                                                                         </tr>
1157                                                                 </table></td><td style=""width:3px;""></td><td onmouseover=""Menu_HoverStatic(this)"" onmouseout=""Menu_Unhover(this)"" onkeyup=""Menu_Key(this)"" id=""Menun11""><table cellpadding=""0"" cellspacing=""0"" border=""0"" width=""100%"">
1158                                                                         <tr>
1159                                                                                 <td style=""white-space:nowrap;""><a class=""Menu_1"" href=""javascript:__doPostBack('Menu','one-black-value\\two-black-2-value\\three-black-3-value\\four-black-6-value')"" style=""margin-left:48px;"">four-black-6</a></td>
1160                                                                         </tr>
1161                                                                 </table></td><td style=""width:3px;""></td>
1162                                                         </tr>
1163                                                 </table></td><td onmouseover=""Menu_HoverRoot(this)"" onmouseout=""Menu_Unhover(this)"" onkeyup=""Menu_Key(this)"" id=""Menun12""><table cellpadding=""0"" cellspacing=""0"" border=""0"" width=""100%"">
1164                                                         <tr>
1165                                                                 <td style=""white-space:nowrap;""><a class=""Menu_1"" href=""javascript:__doPostBack('Menu','one-black-value\\two-black-2-value\\three-black-4-value')"" style=""margin-left:32px;"">three-black-4</a></td>
1166                                                         </tr>
1167                                                 </table></td><td style=""width:3px;""></td><td><table border=""0"" cellpadding=""0"" cellspacing=""0"" width=""100%"">
1168                                                         <tr>
1169                                                                 <td onmouseover=""Menu_HoverStatic(this)"" onmouseout=""Menu_Unhover(this)"" onkeyup=""Menu_Key(this)"" id=""Menun13""><table cellpadding=""0"" cellspacing=""0"" border=""0"" width=""100%"">
1170                                                                         <tr>
1171                                                                                 <td style=""white-space:nowrap;""><a class=""Menu_1"" href=""javascript:__doPostBack('Menu','one-black-value\\two-black-2-value\\three-black-4-value\\four-black-7-value')"" style=""margin-left:48px;"">four-black-7</a></td>
1172                                                                         </tr>
1173                                                                 </table></td><td style=""width:3px;""></td><td onmouseover=""Menu_HoverStatic(this)"" onmouseout=""Menu_Unhover(this)"" onkeyup=""Menu_Key(this)"" id=""Menun14""><table cellpadding=""0"" cellspacing=""0"" border=""0"" width=""100%"">
1174                                                                         <tr>
1175                                                                                 <td style=""white-space:nowrap;""><a class=""Menu_1"" href=""javascript:__doPostBack('Menu','one-black-value\\two-black-2-value\\three-black-4-value\\four-black-8-value')"" style=""margin-left:48px;"">four-black-8</a></td>
1176                                                                         </tr>
1177                                                                 </table></td>
1178                                                         </tr>
1179                                                 </table></td>
1180                                         </tr>
1181                                 </table></td>
1182                         </tr>
1183                 </table></td>
1184         </tr>
1185 </table><a id=""Menu_SkipLink""></a>";
1186 #endif
1187                         #endregion
1188                         RenderedPageHtml = new WebTest (PageInvoker.CreateOnLoad (Menu_RenderStaticItems_Horizontal)).Run ();
1189                         RenderedControlHtml = HtmlDiff.GetControlFromPageHtml (RenderedPageHtml);
1190                         HtmlDiff.AssertAreEqual (OriginControlHtml, RenderedControlHtml, "Menu_RenderStaticItems_Horizontal");
1191 #if !NET_4_0 || (NET_4_0 && !DOT_NET)
1192                         RenderedPageHtml = new WebTest (PageInvoker.CreateOnLoad (Menu_RenderStaticItemsWithBaseAdapter_Horizontal)).Run ();
1193                         RenderedControlHtml = HtmlDiff.GetControlFromPageHtml (RenderedPageHtml);
1194                         HtmlDiff.AssertAreEqual (OriginControlHtml, RenderedControlHtml, "Menu_RenderStaticItemsWithBaseAdapter_Horizontal");
1195 #endif
1196                 }
1197 #if NET_4_0
1198                 [Test]
1199                 [Category ("NunitWeb")]
1200                 [Ignore ("Disabled temporarily")]
1201                 public void Menu_RenderStaticItems_List ()
1202                 {
1203                         string RenderedPageHtml, RenderedControlHtml, OriginControlHtml;
1204                         #region OriginControlHtml
1205                         OriginControlHtml = "<a href=\"#Menu_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=\"Menu\">\r\n\t<ul class=\"level1\">\r\n\t\t<li><a class=\"level1\" href=\"#\" onclick=\"__doPostBack(&#39;Menu&#39;,&#39;one-black-value&#39;)\">one-black</a></li><li><a class=\"level2\" href=\"#\" onclick=\"__doPostBack(&#39;Menu&#39;,&#39;one-black-value\\\\two-black-1-value&#39;)\">two-black-1</a></li><li><a class=\"level3\" href=\"#\" onclick=\"__doPostBack(&#39;Menu&#39;,&#39;one-black-value\\\\two-black-1-value\\\\three-black-1-value&#39;)\">three-black-1</a></li><li><a class=\"level4\" href=\"#\" onclick=\"__doPostBack(&#39;Menu&#39;,&#39;one-black-value\\\\two-black-1-value\\\\three-black-1-value\\\\four-black-1-value&#39;)\">four-black-1</a></li><li><a class=\"level4\" href=\"#\" onclick=\"__doPostBack(&#39;Menu&#39;,&#39;one-black-value\\\\two-black-1-value\\\\three-black-1-value\\\\four-black-2-value&#39;)\">four-black-2</a></li><li><a class=\"level3\" href=\"#\" onclick=\"__doPostBack(&#39;Menu&#39;,&#39;one-black-value\\\\two-black-1-value\\\\three-black-2-value&#39;)\">three-black-2</a></li><li><a class=\"level4\" href=\"#\" onclick=\"__doPostBack(&#39;Menu&#39;,&#39;one-black-value\\\\two-black-1-value\\\\three-black-2-value\\\\four-black-3-value&#39;)\">four-black-3</a></li><li><a class=\"level4\" href=\"#\" onclick=\"__doPostBack(&#39;Menu&#39;,&#39;one-black-value\\\\two-black-1-value\\\\three-black-2-value\\\\four-black-4-value&#39;)\">four-black-4</a></li><li><a class=\"level2\" href=\"#\" onclick=\"__doPostBack(&#39;Menu&#39;,&#39;one-black-value\\\\two-black-2-value&#39;)\">two-black-2</a></li><li><a class=\"level3\" href=\"#\" onclick=\"__doPostBack(&#39;Menu&#39;,&#39;one-black-value\\\\two-black-2-value\\\\three-black-3-value&#39;)\">three-black-3</a></li><li><a class=\"level4\" href=\"#\" onclick=\"__doPostBack(&#39;Menu&#39;,&#39;one-black-value\\\\two-black-2-value\\\\three-black-3-value\\\\four-black-5-value&#39;)\">four-black-5</a></li><li><a class=\"level4\" href=\"#\" onclick=\"__doPostBack(&#39;Menu&#39;,&#39;one-black-value\\\\two-black-2-value\\\\three-black-3-value\\\\four-black-6-value&#39;)\">four-black-6</a></li><li><a class=\"level3\" href=\"#\" onclick=\"__doPostBack(&#39;Menu&#39;,&#39;one-black-value\\\\two-black-2-value\\\\three-black-4-value&#39;)\">three-black-4</a></li><li><a class=\"level4\" href=\"#\" onclick=\"__doPostBack(&#39;Menu&#39;,&#39;one-black-value\\\\two-black-2-value\\\\three-black-4-value\\\\four-black-7-value&#39;)\">four-black-7</a></li><li><a class=\"level4\" href=\"#\" onclick=\"__doPostBack(&#39;Menu&#39;,&#39;one-black-value\\\\two-black-2-value\\\\three-black-4-value\\\\four-black-8-value&#39;)\">four-black-8</a></li>\r\n\t</ul>\r\n</div><a id=\"Menu_SkipLink\"></a>";
1206                         #endregion
1207                         RenderedPageHtml = new WebTest (PageInvoker.CreateOnLoad (Menu_RenderStaticItems_Vertical_List)).Run ();
1208                         RenderedControlHtml = HtmlDiff.GetControlFromPageHtml (RenderedPageHtml);
1209                         HtmlDiff.AssertAreEqual (OriginControlHtml, RenderedControlHtml, "Menu_RenderStaticItems_Vertical");
1210 #if !DOT_NET
1211                         // Throws NREX on .NET 4.0, most probably because the adapter's Control is null
1212                         RenderedPageHtml = new WebTest (PageInvoker.CreateOnLoad (Menu_RenderStaticItemsWithBaseAdapter_Vertical)).Run ();
1213                         RenderedControlHtml = HtmlDiff.GetControlFromPageHtml (RenderedPageHtml);
1214                         HtmlDiff.AssertAreEqual (OriginControlHtml, RenderedControlHtml, "Menu_RenderStaticItemsWithDefaultAdapter_Vertical");
1215 #endif
1216                         #region OriginControlHtml
1217                         OriginControlHtml = "<a href=\"#Menu_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=\"Menu\">\r\n\t<ul class=\"level1\">\r\n\t\t<li><a class=\"level1\" href=\"#\" onclick=\"__doPostBack(&#39;Menu&#39;,&#39;one-black-value&#39;)\">one-black</a></li><li><a class=\"level2\" href=\"#\" onclick=\"__doPostBack(&#39;Menu&#39;,&#39;one-black-value\\\\two-black-1-value&#39;)\">two-black-1</a></li><li><a class=\"level3\" href=\"#\" onclick=\"__doPostBack(&#39;Menu&#39;,&#39;one-black-value\\\\two-black-1-value\\\\three-black-1-value&#39;)\">three-black-1</a></li><li><a class=\"level4\" href=\"#\" onclick=\"__doPostBack(&#39;Menu&#39;,&#39;one-black-value\\\\two-black-1-value\\\\three-black-1-value\\\\four-black-1-value&#39;)\">four-black-1</a></li><li><a class=\"level4\" href=\"#\" onclick=\"__doPostBack(&#39;Menu&#39;,&#39;one-black-value\\\\two-black-1-value\\\\three-black-1-value\\\\four-black-2-value&#39;)\">four-black-2</a></li><li><a class=\"level3\" href=\"#\" onclick=\"__doPostBack(&#39;Menu&#39;,&#39;one-black-value\\\\two-black-1-value\\\\three-black-2-value&#39;)\">three-black-2</a></li><li><a class=\"level4\" href=\"#\" onclick=\"__doPostBack(&#39;Menu&#39;,&#39;one-black-value\\\\two-black-1-value\\\\three-black-2-value\\\\four-black-3-value&#39;)\">four-black-3</a></li><li><a class=\"level4\" href=\"#\" onclick=\"__doPostBack(&#39;Menu&#39;,&#39;one-black-value\\\\two-black-1-value\\\\three-black-2-value\\\\four-black-4-value&#39;)\">four-black-4</a></li><li><a class=\"level2\" href=\"#\" onclick=\"__doPostBack(&#39;Menu&#39;,&#39;one-black-value\\\\two-black-2-value&#39;)\">two-black-2</a></li><li><a class=\"level3\" href=\"#\" onclick=\"__doPostBack(&#39;Menu&#39;,&#39;one-black-value\\\\two-black-2-value\\\\three-black-3-value&#39;)\">three-black-3</a></li><li><a class=\"level4\" href=\"#\" onclick=\"__doPostBack(&#39;Menu&#39;,&#39;one-black-value\\\\two-black-2-value\\\\three-black-3-value\\\\four-black-5-value&#39;)\">four-black-5</a></li><li><a class=\"level4\" href=\"#\" onclick=\"__doPostBack(&#39;Menu&#39;,&#39;one-black-value\\\\two-black-2-value\\\\three-black-3-value\\\\four-black-6-value&#39;)\">four-black-6</a></li><li><a class=\"level3\" href=\"#\" onclick=\"__doPostBack(&#39;Menu&#39;,&#39;one-black-value\\\\two-black-2-value\\\\three-black-4-value&#39;)\">three-black-4</a></li><li><a class=\"level4\" href=\"#\" onclick=\"__doPostBack(&#39;Menu&#39;,&#39;one-black-value\\\\two-black-2-value\\\\three-black-4-value\\\\four-black-7-value&#39;)\">four-black-7</a></li><li><a class=\"level4\" href=\"#\" onclick=\"__doPostBack(&#39;Menu&#39;,&#39;one-black-value\\\\two-black-2-value\\\\three-black-4-value\\\\four-black-8-value&#39;)\">four-black-8</a></li>\r\n\t</ul>\r\n</div><a id=\"Menu_SkipLink\"></a>";
1218                         #endregion
1219                         RenderedPageHtml = new WebTest (PageInvoker.CreateOnLoad (Menu_RenderStaticItems_Horizontal_List)).Run ();
1220                         RenderedControlHtml = HtmlDiff.GetControlFromPageHtml (RenderedPageHtml);
1221                         HtmlDiff.AssertAreEqual (OriginControlHtml, RenderedControlHtml, "Menu_RenderStaticItems_Horizontal");
1222 #if !DOT_NET
1223                         RenderedPageHtml = new WebTest (PageInvoker.CreateOnLoad (Menu_RenderStaticItemsWithBaseAdapter_Horizontal)).Run ();
1224                         RenderedControlHtml = HtmlDiff.GetControlFromPageHtml (RenderedPageHtml);
1225                         HtmlDiff.AssertAreEqual (OriginControlHtml, RenderedControlHtml, "Menu_RenderStaticItemsWithBaseAdapter_Horizontal");
1226 #endif
1227                 }
1228 #endif
1229                 class MyMenuAdapter : global::System.Web.UI.WebControls.Adapters.MenuAdapter
1230                 {
1231                         protected internal override void RenderItem (HtmlTextWriter writer, 
1232                                                                     MenuItem item,
1233                                                                     int position)
1234                         {
1235                                 writer.Write ("{");
1236                                 base.RenderItem (writer, item, position);
1237                                 writer.Write ("}");                             
1238                         }                       
1239                 }
1240
1241                 [Test]
1242                 [Category ("NunitWeb")]
1243 #if NET_4_0
1244                 [Category ("NotDotNet")]
1245 #endif
1246                 public void Menu_RenderStaticItemsWithAdapter () 
1247                 {
1248                         string RenderedPageHtml, RenderedControlHtml, OriginControlHtml;
1249                         RenderedPageHtml = new WebTest (PageInvoker.CreateOnLoad (Menu_RenderStaticItemsWithAdapter_Vertical)).Run ();
1250                         RenderedControlHtml = HtmlDiff.GetControlFromPageHtml (RenderedPageHtml);
1251                         #region OriginControlHtml
1252                         OriginControlHtml = @"<a href=""#Menu_SkipLink""><img alt=""Skip Navigation Links"" src=""/NunitWeb/WebResource.axd?d=QxfUEifeQdL5PTiZOF8HlA2&amp;t=632900536532114160"" width=""0"" height=""0"" style=""border-width:0px;"" /></a><table id=""Menu"" class=""Menu_2"" cellpadding=""0"" cellspacing=""0"" border=""0"">
1253         {<tr onmouseover=""Menu_HoverRoot(this)"" onmouseout=""Menu_Unhover(this)"" onkeyup=""Menu_Key(this)"" id=""Menun0"">
1254                 <td><table cellpadding=""0"" cellspacing=""0"" border=""0"" width=""100%"">
1255                         <tr>
1256                                 <td style=""white-space:nowrap;width:100%;""><a class=""Menu_1"" href=""javascript:__doPostBack('Menu','one-black-value')"">one-black</a></td>
1257                         </tr>
1258                 </table></td>
1259         </tr><tr>
1260                 <td><table border=""0"" cellpadding=""0"" cellspacing=""0"" width=""100%"">
1261                         {<tr onmouseover=""Menu_HoverRoot(this)"" onmouseout=""Menu_Unhover(this)"" onkeyup=""Menu_Key(this)"" id=""Menun1"">
1262                                 <td><table cellpadding=""0"" cellspacing=""0"" border=""0"" width=""100%"">
1263                                         <tr>
1264                                                 <td style=""white-space:nowrap;width:100%;""><a class=""Menu_1"" href=""javascript:__doPostBack('Menu','one-black-value\\two-black-1-value')"" style=""margin-left:16px;"">two-black-1</a></td>
1265                                         </tr>
1266                                 </table></td>
1267                         </tr><tr>
1268                                 <td><table border=""0"" cellpadding=""0"" cellspacing=""0"" width=""100%"">
1269                                         {<tr onmouseover=""Menu_HoverRoot(this)"" onmouseout=""Menu_Unhover(this)"" onkeyup=""Menu_Key(this)"" id=""Menun2"">
1270                                                 <td><table cellpadding=""0"" cellspacing=""0"" border=""0"" width=""100%"">
1271                                                         <tr>
1272                                                                 <td style=""white-space:nowrap;width:100%;""><a class=""Menu_1"" href=""javascript:__doPostBack('Menu','one-black-value\\two-black-1-value\\three-black-1-value')"" style=""margin-left:32px;"">three-black-1</a></td>
1273                                                         </tr>
1274                                                 </table></td>
1275                                         </tr><tr>
1276                                                 <td><table border=""0"" cellpadding=""0"" cellspacing=""0"" width=""100%"">
1277                                                         {<tr onmouseover=""Menu_HoverStatic(this)"" onmouseout=""Menu_Unhover(this)"" onkeyup=""Menu_Key(this)"" id=""Menun3"">
1278                                                                 <td><table cellpadding=""0"" cellspacing=""0"" border=""0"" width=""100%"">
1279                                                                         <tr>
1280                                                                                 <td style=""white-space:nowrap;width:100%;""><a class=""Menu_1"" href=""javascript:__doPostBack('Menu','one-black-value\\two-black-1-value\\three-black-1-value\\four-black-1-value')"" style=""margin-left:48px;"">four-black-1</a></td>
1281                                                                         </tr>
1282                                                                 </table></td>
1283                                                         </tr>}{<tr onmouseover=""Menu_HoverStatic(this)"" onmouseout=""Menu_Unhover(this)"" onkeyup=""Menu_Key(this)"" id=""Menun4"">
1284                                                                 <td><table cellpadding=""0"" cellspacing=""0"" border=""0"" width=""100%"">
1285                                                                         <tr>
1286                                                                                 <td style=""white-space:nowrap;width:100%;""><a class=""Menu_1"" href=""javascript:__doPostBack('Menu','one-black-value\\two-black-1-value\\three-black-1-value\\four-black-2-value')"" style=""margin-left:48px;"">four-black-2</a></td>
1287                                                                         </tr>
1288                                                                 </table></td>
1289                                                         </tr>}
1290                                                 </table></td>
1291                                         </tr>}{<tr onmouseover=""Menu_HoverRoot(this)"" onmouseout=""Menu_Unhover(this)"" onkeyup=""Menu_Key(this)"" id=""Menun5"">
1292                                                 <td><table cellpadding=""0"" cellspacing=""0"" border=""0"" width=""100%"">
1293                                                         <tr>
1294                                                                 <td style=""white-space:nowrap;width:100%;""><a class=""Menu_1"" href=""javascript:__doPostBack('Menu','one-black-value\\two-black-1-value\\three-black-2-value')"" style=""margin-left:32px;"">three-black-2</a></td>
1295                                                         </tr>
1296                                                 </table></td>
1297                                         </tr><tr>
1298                                                 <td><table border=""0"" cellpadding=""0"" cellspacing=""0"" width=""100%"">
1299                                                         {<tr onmouseover=""Menu_HoverStatic(this)"" onmouseout=""Menu_Unhover(this)"" onkeyup=""Menu_Key(this)"" id=""Menun6"">
1300                                                                 <td><table cellpadding=""0"" cellspacing=""0"" border=""0"" width=""100%"">
1301                                                                         <tr>
1302                                                                                 <td style=""white-space:nowrap;width:100%;""><a class=""Menu_1"" href=""javascript:__doPostBack('Menu','one-black-value\\two-black-1-value\\three-black-2-value\\four-black-3-value')"" style=""margin-left:48px;"">four-black-3</a></td>
1303                                                                         </tr>
1304                                                                 </table></td>
1305                                                         </tr>}{<tr onmouseover=""Menu_HoverStatic(this)"" onmouseout=""Menu_Unhover(this)"" onkeyup=""Menu_Key(this)"" id=""Menun7"">
1306                                                                 <td><table cellpadding=""0"" cellspacing=""0"" border=""0"" width=""100%"">
1307                                                                         <tr>
1308                                                                                 <td style=""white-space:nowrap;width:100%;""><a class=""Menu_1"" href=""javascript:__doPostBack('Menu','one-black-value\\two-black-1-value\\three-black-2-value\\four-black-4-value')"" style=""margin-left:48px;"">four-black-4</a></td>
1309                                                                         </tr>
1310                                                                 </table></td>
1311                                                         </tr>}
1312                                                 </table></td>
1313                                         </tr>}
1314                                 </table></td>
1315                         </tr>}{<tr onmouseover=""Menu_HoverRoot(this)"" onmouseout=""Menu_Unhover(this)"" onkeyup=""Menu_Key(this)"" id=""Menun8"">
1316                                 <td><table cellpadding=""0"" cellspacing=""0"" border=""0"" width=""100%"">
1317                                         <tr>
1318                                                 <td style=""white-space:nowrap;width:100%;""><a class=""Menu_1"" href=""javascript:__doPostBack('Menu','one-black-value\\two-black-2-value')"" style=""margin-left:16px;"">two-black-2</a></td>
1319                                         </tr>
1320                                 </table></td>
1321                         </tr><tr>
1322                                 <td><table border=""0"" cellpadding=""0"" cellspacing=""0"" width=""100%"">
1323                                         {<tr onmouseover=""Menu_HoverRoot(this)"" onmouseout=""Menu_Unhover(this)"" onkeyup=""Menu_Key(this)"" id=""Menun9"">
1324                                                 <td><table cellpadding=""0"" cellspacing=""0"" border=""0"" width=""100%"">
1325                                                         <tr>
1326                                                                 <td style=""white-space:nowrap;width:100%;""><a class=""Menu_1"" href=""javascript:__doPostBack('Menu','one-black-value\\two-black-2-value\\three-black-3-value')"" style=""margin-left:32px;"">three-black-3</a></td>
1327                                                         </tr>
1328                                                 </table></td>
1329                                         </tr><tr>
1330                                                 <td><table border=""0"" cellpadding=""0"" cellspacing=""0"" width=""100%"">
1331                                                         {<tr onmouseover=""Menu_HoverStatic(this)"" onmouseout=""Menu_Unhover(this)"" onkeyup=""Menu_Key(this)"" id=""Menun10"">
1332                                                                 <td><table cellpadding=""0"" cellspacing=""0"" border=""0"" width=""100%"">
1333                                                                         <tr>
1334                                                                                 <td style=""white-space:nowrap;width:100%;""><a class=""Menu_1"" href=""javascript:__doPostBack('Menu','one-black-value\\two-black-2-value\\three-black-3-value\\four-black-5-value')"" style=""margin-left:48px;"">four-black-5</a></td>
1335                                                                         </tr>
1336                                                                 </table></td>
1337                                                         </tr>}{<tr onmouseover=""Menu_HoverStatic(this)"" onmouseout=""Menu_Unhover(this)"" onkeyup=""Menu_Key(this)"" id=""Menun11"">
1338                                                                 <td><table cellpadding=""0"" cellspacing=""0"" border=""0"" width=""100%"">
1339                                                                         <tr>
1340                                                                                 <td style=""white-space:nowrap;width:100%;""><a class=""Menu_1"" href=""javascript:__doPostBack('Menu','one-black-value\\two-black-2-value\\three-black-3-value\\four-black-6-value')"" style=""margin-left:48px;"">four-black-6</a></td>
1341                                                                         </tr>
1342                                                                 </table></td>
1343                                                         </tr>}
1344                                                 </table></td>
1345                                         </tr>}{<tr onmouseover=""Menu_HoverRoot(this)"" onmouseout=""Menu_Unhover(this)"" onkeyup=""Menu_Key(this)"" id=""Menun12"">
1346                                                 <td><table cellpadding=""0"" cellspacing=""0"" border=""0"" width=""100%"">
1347                                                         <tr>
1348                                                                 <td style=""white-space:nowrap;width:100%;""><a class=""Menu_1"" href=""javascript:__doPostBack('Menu','one-black-value\\two-black-2-value\\three-black-4-value')"" style=""margin-left:32px;"">three-black-4</a></td>
1349                                                         </tr>
1350                                                 </table></td>
1351                                         </tr><tr>
1352                                                 <td><table border=""0"" cellpadding=""0"" cellspacing=""0"" width=""100%"">
1353                                                         {<tr onmouseover=""Menu_HoverStatic(this)"" onmouseout=""Menu_Unhover(this)"" onkeyup=""Menu_Key(this)"" id=""Menun13"">
1354                                                                 <td><table cellpadding=""0"" cellspacing=""0"" border=""0"" width=""100%"">
1355                                                                         <tr>
1356                                                                                 <td style=""white-space:nowrap;width:100%;""><a class=""Menu_1"" href=""javascript:__doPostBack('Menu','one-black-value\\two-black-2-value\\three-black-4-value\\four-black-7-value')"" style=""margin-left:48px;"">four-black-7</a></td>
1357                                                                         </tr>
1358                                                                 </table></td>
1359                                                         </tr>}{<tr onmouseover=""Menu_HoverStatic(this)"" onmouseout=""Menu_Unhover(this)"" onkeyup=""Menu_Key(this)"" id=""Menun14"">
1360                                                                 <td><table cellpadding=""0"" cellspacing=""0"" border=""0"" width=""100%"">
1361                                                                         <tr>
1362                                                                                 <td style=""white-space:nowrap;width:100%;""><a class=""Menu_1"" href=""javascript:__doPostBack('Menu','one-black-value\\two-black-2-value\\three-black-4-value\\four-black-8-value')"" style=""margin-left:48px;"">four-black-8</a></td>
1363                                                                         </tr>
1364                                                                 </table></td>
1365                                                         </tr>}
1366                                                 </table></td>
1367                                         </tr>}
1368                                 </table></td>
1369                         </tr>}
1370                 </table></td>
1371         </tr>}
1372 </table><a id=""Menu_SkipLink""></a>";
1373                         #endregion
1374                         HtmlDiff.AssertAreEqual (OriginControlHtml, RenderedControlHtml, "Menu_RenderStaticItemsWithAdapter_Vertical");
1375                         RenderedPageHtml = new WebTest (PageInvoker.CreateOnLoad (Menu_RenderStaticItemsWithAdapter_Horizontal)).Run ();
1376                         RenderedControlHtml = HtmlDiff.GetControlFromPageHtml (RenderedPageHtml);
1377                         #region OriginControlHtml
1378                         OriginControlHtml = @"<a href=""#Menu_SkipLink""><img alt=""Skip Navigation Links"" src=""/NunitWeb/WebResource.axd?d=QxfUEifeQdL5PTiZOF8HlA2&amp;t=632900536532114160"" width=""0"" height=""0"" style=""border-width:0px;"" /></a><table id=""Menu"" class=""Menu_2"" cellpadding=""0"" cellspacing=""0"" border=""0"">
1379         <tr>
1380                 {<td onmouseover=""Menu_HoverRoot(this)"" onmouseout=""Menu_Unhover(this)"" onkeyup=""Menu_Key(this)"" id=""Menun0""><table cellpadding=""0"" cellspacing=""0"" border=""0"" width=""100%"">
1381                         <tr>
1382                                 <td style=""white-space:nowrap;""><a class=""Menu_1"" href=""javascript:__doPostBack('Menu','one-black-value')"">one-black</a></td>
1383                         </tr>
1384                 </table></td><td style=""width:3px;""></td><td><table border=""0"" cellpadding=""0"" cellspacing=""0"" width=""100%"">
1385                         <tr>
1386                                 {<td onmouseover=""Menu_HoverRoot(this)"" onmouseout=""Menu_Unhover(this)"" onkeyup=""Menu_Key(this)"" id=""Menun1""><table cellpadding=""0"" cellspacing=""0"" border=""0"" width=""100%"">
1387                                         <tr>
1388                                                 <td style=""white-space:nowrap;""><a class=""Menu_1"" href=""javascript:__doPostBack('Menu','one-black-value\\two-black-1-value')"" style=""margin-left:16px;"">two-black-1</a></td>
1389                                         </tr>
1390                                 </table></td><td style=""width:3px;""></td><td><table border=""0"" cellpadding=""0"" cellspacing=""0"" width=""100%"">
1391                                         <tr>
1392                                                 {<td onmouseover=""Menu_HoverRoot(this)"" onmouseout=""Menu_Unhover(this)"" onkeyup=""Menu_Key(this)"" id=""Menun2""><table cellpadding=""0"" cellspacing=""0"" border=""0"" width=""100%"">
1393                                                         <tr>
1394                                                                 <td style=""white-space:nowrap;""><a class=""Menu_1"" href=""javascript:__doPostBack('Menu','one-black-value\\two-black-1-value\\three-black-1-value')"" style=""margin-left:32px;"">three-black-1</a></td>
1395                                                         </tr>
1396                                                 </table></td><td style=""width:3px;""></td><td><table border=""0"" cellpadding=""0"" cellspacing=""0"" width=""100%"">
1397                                                         <tr>
1398                                                                 {<td onmouseover=""Menu_HoverStatic(this)"" onmouseout=""Menu_Unhover(this)"" onkeyup=""Menu_Key(this)"" id=""Menun3""><table cellpadding=""0"" cellspacing=""0"" border=""0"" width=""100%"">
1399                                                                         <tr>
1400                                                                                 <td style=""white-space:nowrap;""><a class=""Menu_1"" href=""javascript:__doPostBack('Menu','one-black-value\\two-black-1-value\\three-black-1-value\\four-black-1-value')"" style=""margin-left:48px;"">four-black-1</a></td>
1401                                                                         </tr>
1402                                                                 </table></td><td style=""width:3px;""></td>}{<td onmouseover=""Menu_HoverStatic(this)"" onmouseout=""Menu_Unhover(this)"" onkeyup=""Menu_Key(this)"" id=""Menun4""><table cellpadding=""0"" cellspacing=""0"" border=""0"" width=""100%"">
1403                                                                         <tr>
1404                                                                                 <td style=""white-space:nowrap;""><a class=""Menu_1"" href=""javascript:__doPostBack('Menu','one-black-value\\two-black-1-value\\three-black-1-value\\four-black-2-value')"" style=""margin-left:48px;"">four-black-2</a></td>
1405                                                                         </tr>
1406                                                                 </table></td><td style=""width:3px;""></td>}
1407                                                         </tr>
1408                                                 </table></td>}{<td onmouseover=""Menu_HoverRoot(this)"" onmouseout=""Menu_Unhover(this)"" onkeyup=""Menu_Key(this)"" id=""Menun5""><table cellpadding=""0"" cellspacing=""0"" border=""0"" width=""100%"">
1409                                                         <tr>
1410                                                                 <td style=""white-space:nowrap;""><a class=""Menu_1"" href=""javascript:__doPostBack('Menu','one-black-value\\two-black-1-value\\three-black-2-value')"" style=""margin-left:32px;"">three-black-2</a></td>
1411                                                         </tr>
1412                                                 </table></td><td style=""width:3px;""></td><td><table border=""0"" cellpadding=""0"" cellspacing=""0"" width=""100%"">
1413                                                         <tr>
1414                                                                 {<td onmouseover=""Menu_HoverStatic(this)"" onmouseout=""Menu_Unhover(this)"" onkeyup=""Menu_Key(this)"" id=""Menun6""><table cellpadding=""0"" cellspacing=""0"" border=""0"" width=""100%"">
1415                                                                         <tr>
1416                                                                                 <td style=""white-space:nowrap;""><a class=""Menu_1"" href=""javascript:__doPostBack('Menu','one-black-value\\two-black-1-value\\three-black-2-value\\four-black-3-value')"" style=""margin-left:48px;"">four-black-3</a></td>
1417                                                                         </tr>
1418                                                                 </table></td><td style=""width:3px;""></td>}{<td onmouseover=""Menu_HoverStatic(this)"" onmouseout=""Menu_Unhover(this)"" onkeyup=""Menu_Key(this)"" id=""Menun7""><table cellpadding=""0"" cellspacing=""0"" border=""0"" width=""100%"">
1419                                                                         <tr>
1420                                                                                 <td style=""white-space:nowrap;""><a class=""Menu_1"" href=""javascript:__doPostBack('Menu','one-black-value\\two-black-1-value\\three-black-2-value\\four-black-4-value')"" style=""margin-left:48px;"">four-black-4</a></td>
1421                                                                         </tr>
1422                                                                 </table></td><td style=""width:3px;""></td>}
1423                                                         </tr>
1424                                                 </table></td>}
1425                                         </tr>
1426                                 </table></td>}{<td onmouseover=""Menu_HoverRoot(this)"" onmouseout=""Menu_Unhover(this)"" onkeyup=""Menu_Key(this)"" id=""Menun8""><table cellpadding=""0"" cellspacing=""0"" border=""0"" width=""100%"">
1427                                         <tr>
1428                                                 <td style=""white-space:nowrap;""><a class=""Menu_1"" href=""javascript:__doPostBack('Menu','one-black-value\\two-black-2-value')"" style=""margin-left:16px;"">two-black-2</a></td>
1429                                         </tr>
1430                                 </table></td><td style=""width:3px;""></td><td><table border=""0"" cellpadding=""0"" cellspacing=""0"" width=""100%"">
1431                                         <tr>
1432                                                 {<td onmouseover=""Menu_HoverRoot(this)"" onmouseout=""Menu_Unhover(this)"" onkeyup=""Menu_Key(this)"" id=""Menun9""><table cellpadding=""0"" cellspacing=""0"" border=""0"" width=""100%"">
1433                                                         <tr>
1434                                                                 <td style=""white-space:nowrap;""><a class=""Menu_1"" href=""javascript:__doPostBack('Menu','one-black-value\\two-black-2-value\\three-black-3-value')"" style=""margin-left:32px;"">three-black-3</a></td>
1435                                                         </tr>
1436                                                 </table></td><td style=""width:3px;""></td><td><table border=""0"" cellpadding=""0"" cellspacing=""0"" width=""100%"">
1437                                                         <tr>
1438                                                                 {<td onmouseover=""Menu_HoverStatic(this)"" onmouseout=""Menu_Unhover(this)"" onkeyup=""Menu_Key(this)"" id=""Menun10""><table cellpadding=""0"" cellspacing=""0"" border=""0"" width=""100%"">
1439                                                                         <tr>
1440                                                                                 <td style=""white-space:nowrap;""><a class=""Menu_1"" href=""javascript:__doPostBack('Menu','one-black-value\\two-black-2-value\\three-black-3-value\\four-black-5-value')"" style=""margin-left:48px;"">four-black-5</a></td>
1441                                                                         </tr>
1442                                                                 </table></td><td style=""width:3px;""></td>}{<td onmouseover=""Menu_HoverStatic(this)"" onmouseout=""Menu_Unhover(this)"" onkeyup=""Menu_Key(this)"" id=""Menun11""><table cellpadding=""0"" cellspacing=""0"" border=""0"" width=""100%"">
1443                                                                         <tr>
1444                                                                                 <td style=""white-space:nowrap;""><a class=""Menu_1"" href=""javascript:__doPostBack('Menu','one-black-value\\two-black-2-value\\three-black-3-value\\four-black-6-value')"" style=""margin-left:48px;"">four-black-6</a></td>
1445                                                                         </tr>
1446                                                                 </table></td><td style=""width:3px;""></td>}
1447                                                         </tr>
1448                                                 </table></td>}{<td onmouseover=""Menu_HoverRoot(this)"" onmouseout=""Menu_Unhover(this)"" onkeyup=""Menu_Key(this)"" id=""Menun12""><table cellpadding=""0"" cellspacing=""0"" border=""0"" width=""100%"">
1449                                                         <tr>
1450                                                                 <td style=""white-space:nowrap;""><a class=""Menu_1"" href=""javascript:__doPostBack('Menu','one-black-value\\two-black-2-value\\three-black-4-value')"" style=""margin-left:32px;"">three-black-4</a></td>
1451                                                         </tr>
1452                                                 </table></td><td style=""width:3px;""></td><td><table border=""0"" cellpadding=""0"" cellspacing=""0"" width=""100%"">
1453                                                         <tr>
1454                                                                 {<td onmouseover=""Menu_HoverStatic(this)"" onmouseout=""Menu_Unhover(this)"" onkeyup=""Menu_Key(this)"" id=""Menun13""><table cellpadding=""0"" cellspacing=""0"" border=""0"" width=""100%"">
1455                                                                         <tr>
1456                                                                                 <td style=""white-space:nowrap;""><a class=""Menu_1"" href=""javascript:__doPostBack('Menu','one-black-value\\two-black-2-value\\three-black-4-value\\four-black-7-value')"" style=""margin-left:48px;"">four-black-7</a></td>
1457                                                                         </tr>
1458                                                                 </table></td><td style=""width:3px;""></td>}{<td onmouseover=""Menu_HoverStatic(this)"" onmouseout=""Menu_Unhover(this)"" onkeyup=""Menu_Key(this)"" id=""Menun14""><table cellpadding=""0"" cellspacing=""0"" border=""0"" width=""100%"">
1459                                                                         <tr>
1460                                                                                 <td style=""white-space:nowrap;""><a class=""Menu_1"" href=""javascript:__doPostBack('Menu','one-black-value\\two-black-2-value\\three-black-4-value\\four-black-8-value')"" style=""margin-left:48px;"">four-black-8</a></td>
1461                                                                         </tr>
1462                                                                 </table></td>}
1463                                                         </tr>
1464                                                 </table></td>}
1465                                         </tr>
1466                                 </table></td>}
1467                         </tr>
1468                 </table></td>}
1469         </tr>
1470 </table><a id=""Menu_SkipLink""></a>";
1471                         #endregion
1472                         HtmlDiff.AssertAreEqual (OriginControlHtml, RenderedControlHtml, "Menu_RenderStaticItemsWithAdapter_Horizontal");
1473                 }
1474
1475                 public static void Menu_RenderStaticItems_Vertical (Page p) {
1476                         Menu m = CreateMenuForRenderTests (null);
1477                         m.StaticDisplayLevels = 4;
1478                         AddMenuToPage (p, m);
1479                 }
1480
1481                 public static void Menu_RenderStaticItems_Horizontal (Page p) {
1482                         Menu m = CreateMenuForRenderTests (null);
1483                         m.Orientation = Orientation.Horizontal;
1484                         m.StaticDisplayLevels = 4;
1485                         AddMenuToPage (p, m);
1486                 }
1487 #if NET_4_0
1488                 public static void Menu_RenderStaticItems_Vertical_List (Page p)
1489                 {
1490                         Menu m = CreateMenuForRenderTests (null, false);
1491                         m.RenderingCompatibility = new Version (4, 0);
1492                         m.RenderingMode = MenuRenderingMode.List;
1493                         m.StaticDisplayLevels = 4;
1494                         AddMenuToPage (p, m);
1495                 }
1496
1497                 public static void Menu_RenderStaticItems_Horizontal_List (Page p)
1498                 {
1499                         Menu m = CreateMenuForRenderTests (null, false);
1500                         m.Orientation = Orientation.Horizontal;
1501                         m.StaticDisplayLevels = 4;
1502                         m.RenderingCompatibility = new Version (4, 0);
1503                         m.RenderingMode = MenuRenderingMode.List;
1504                         AddMenuToPage (p, m);
1505                 }
1506 #endif
1507                 public static void Menu_RenderStaticItemsWithBaseAdapter_Vertical (Page p) {
1508                         Menu m = CreateMenuForRenderTests (new MyWebControl.Adapters.MenuAdapter());
1509                         m.StaticDisplayLevels = 4;
1510                         AddMenuToPage (p, m);
1511                 }
1512
1513                 public static void Menu_RenderStaticItemsWithBaseAdapter_Horizontal (Page p) {
1514                         Menu m = CreateMenuForRenderTests (new MyWebControl.Adapters.MenuAdapter());
1515                         m.Orientation = Orientation.Horizontal;
1516                         m.StaticDisplayLevels = 4;
1517                         AddMenuToPage (p, m);
1518                 }
1519
1520                 public static void Menu_RenderStaticItemsWithAdapter_Vertical (Page p) {
1521                         Menu m = CreateMenuForRenderTests (new MyMenuAdapter());
1522                         m.StaticDisplayLevels = 4;
1523                         AddMenuToPage (p, m);
1524                 }
1525
1526                 public static void Menu_RenderStaticItemsWithAdapter_Horizontal (Page p) {
1527                         Menu m = CreateMenuForRenderTests (new MyMenuAdapter());
1528                         m.Orientation = Orientation.Horizontal;
1529                         m.StaticDisplayLevels = 4;
1530                         AddMenuToPage (p, m);
1531                 }
1532
1533                 private static void AddMenuToPage (Page p, Menu m) {
1534                         LiteralControl lcb = new LiteralControl (HtmlDiff.BEGIN_TAG);
1535                         LiteralControl lce = new LiteralControl (HtmlDiff.END_TAG);
1536                         p.Form.Controls.Add (lcb);
1537                         p.Form.Controls.Add (m);
1538                         p.Form.Controls.Add (lce);
1539                 }
1540                 
1541                 class MyMenu : Menu
1542                 {
1543                         internal MyMenu (MyWebControl.Adapters.MenuAdapter adapter) : base ()
1544                         {
1545                                 menu_adapter = adapter;
1546                         }
1547
1548                         MyWebControl.Adapters.MenuAdapter menu_adapter;
1549                         protected override global::System.Web.UI.Adapters.ControlAdapter ResolveAdapter ()
1550                         {
1551                                 return menu_adapter;
1552                         }                       
1553                 }
1554
1555                 static Menu CreateMenuForRenderTests (MyWebControl.Adapters.MenuAdapter adapter)
1556                 {
1557                         return CreateMenuForRenderTests (adapter, true);
1558                 }
1559                 
1560                 static Menu CreateMenuForRenderTests (MyWebControl.Adapters.MenuAdapter adapter, bool compatibilityRendering) 
1561                 {
1562                         Menu menu = new MyMenu (adapter);
1563 #if NET_4_0
1564                         if (compatibilityRendering)
1565                                 menu.RenderingCompatibility = new Version (3, 5);
1566 #endif
1567                         menu.ID = "Menu";
1568                         MenuItem R, N1, N2, SN1, SN2, SN3, SN4;
1569                         R = new MenuItem ("one-black", "one-black-value");
1570                         N1 = new MenuItem ("two-black-1", "two-black-1-value");
1571                         N2 = new MenuItem ("two-black-2", "two-black-2-value");
1572                         SN1 = new MenuItem ("three-black-1", "three-black-1-value");
1573                         SN2 = new MenuItem ("three-black-2", "three-black-2-value");
1574                         SN3 = new MenuItem ("three-black-3", "three-black-3-value");
1575                         SN4 = new MenuItem ("three-black-4", "three-black-4-value");
1576                         SN1.ChildItems.Add (new MenuItem ("four-black-1", "four-black-1-value"));
1577                         SN1.ChildItems.Add (new MenuItem ("four-black-2", "four-black-2-value"));
1578                         SN2.ChildItems.Add (new MenuItem ("four-black-3", "four-black-3-value"));
1579                         SN2.ChildItems.Add (new MenuItem ("four-black-4", "four-black-4-value"));
1580                         SN3.ChildItems.Add (new MenuItem ("four-black-5", "four-black-5-value"));
1581                         SN3.ChildItems.Add (new MenuItem ("four-black-6", "four-black-6-value"));
1582                         SN4.ChildItems.Add (new MenuItem ("four-black-7", "four-black-7-value"));
1583                         SN4.ChildItems.Add (new MenuItem ("four-black-8", "four-black-8-value"));
1584                         N1.ChildItems.Add (SN1);
1585                         N1.ChildItems.Add (SN2);
1586                         N2.ChildItems.Add (SN3);
1587                         N2.ChildItems.Add (SN4);
1588                         R.ChildItems.Add (N1);
1589                         R.ChildItems.Add (N2);
1590                         menu.Items.Add (R);
1591                         return menu;
1592                 }
1593
1594                  //Events Stuff
1595                 private bool OnDataBinding;
1596                 private bool OnDataBound;
1597                 private bool OnMenuItemClick;
1598                 private bool OnInit;
1599                 private bool OnMenuItemDataBound;
1600                 private bool OnPreRender;
1601                                 
1602                 private void OnMenuItemDataBoundHandler(object sender, MenuEventArgs e)
1603                 {
1604                         OnMenuItemDataBound = true;
1605                 }
1606                 private void OnInitHandler (object sender, EventArgs e)
1607                 {
1608                         OnInit = true;
1609                 }
1610                 private void OnDataBindingHandler (object sender, EventArgs e)
1611                 {
1612                         OnDataBinding = true;
1613                 }
1614                 private void OnDataDataBoundHandler (object sender, EventArgs e)
1615                 {
1616                         OnDataBound = true;
1617                 }
1618                 private void OnMenuItemClickHandler (object sender, MenuEventArgs e)
1619                 {
1620                         OnMenuItemClick = true;
1621                 }
1622                 private void OnPreRenderHandler (object sender, EventArgs e)
1623                 {
1624                         OnPreRender = true;
1625                 }
1626                 private void ResetEvents ()
1627                 {
1628                         OnMenuItemClick = false;
1629                         OnDataBinding = false;
1630                         OnDataBound = false;
1631                         OnInit = false;
1632                         OnPreRender = false;
1633                 }
1634                 [Test]
1635                 public void Menu_Events ()
1636                 {
1637                         Page myPage = new Page ();
1638                         PokerMenu p = new PokerMenu ();
1639                         MenuItem I = new MenuItem ();
1640                         p.Items.Add (I);
1641                         myPage.Controls.Add(p);
1642
1643                         
1644                         p.Init += new EventHandler(OnInitHandler); 
1645                         p.DataBinding += new EventHandler (OnDataBindingHandler);
1646                         p.DataBound  += new EventHandler(OnDataDataBoundHandler);
1647                         p.MenuItemClick += new MenuEventHandler(OnMenuItemClickHandler);
1648                         p.MenuItemDataBound += new MenuEventHandler (OnMenuItemDataBoundHandler);
1649                         Assert.AreEqual (false, OnDataBinding, "BeforeOnDataBinding");
1650                         p.DoOnDataBind (new EventArgs ());
1651                         Assert.AreEqual (true, OnDataBinding, "AfterOnDataBinding");
1652                         Assert.AreEqual (false, OnDataBound, "BeforeOnDataBound");
1653                         p.DoOnDataBound (new EventArgs ());
1654                         Assert.AreEqual (true, OnDataBound, "AfterOnDataBinding");
1655                         MenuEventArgs e = new MenuEventArgs (I);
1656                         Assert.AreEqual (false, OnMenuItemClick, "BeforeMenuItemClick");
1657                         p.DoOnMenuItemClick (e);
1658                         Assert.AreEqual (true, OnMenuItemClick, "AfterMenuItemClick");
1659                         Assert.AreEqual (false, OnInit, "BeforeOnInit");
1660                         p.DoOnInit (new EventArgs());
1661                         Assert.AreEqual (true, OnInit, "AfterOnInit");
1662                         Assert.AreEqual (false, OnMenuItemDataBound, "BeforeMenuItemDataBound");
1663                         p.DoMenuItemDataBound(e);
1664                         Assert.AreEqual (true, OnMenuItemDataBound, "AfterMenuItemDataBound");
1665                 }
1666                 [Test]
1667                 public void Menu_BubbleEvent () {
1668                         PokerMenu pm = new PokerMenu ();
1669                         MenuItem item = new MenuItem ("Root");
1670                         pm.Items.Add (item);
1671                         pm.MenuItemClick += new MenuEventHandler (pm_MenuItemClick);
1672                         _MenuItemClick = false;
1673                         MenuEventArgs clickCommandArg = new MenuEventArgs (item, null, new CommandEventArgs (Menu.MenuItemClickCommandName, null));
1674                         CommandEventArgs notClickCommandArg = new CommandEventArgs (Menu.MenuItemClickCommandName + "No", null);
1675                         Assert.AreEqual (true, pm.DoOnBubbleEvent (notClickCommandArg), "Bubble Event#1");
1676                         Assert.AreEqual (false, _MenuItemClick, "MenuItemClick Bubbled");
1677                         Assert.AreEqual (true, pm.DoOnBubbleEvent (clickCommandArg), "Bubble Event#2");
1678                         Assert.AreEqual (true, _MenuItemClick, "MenuItemClick Bubbled");
1679                         Assert.AreEqual (false, pm.DoOnBubbleEvent (new EventArgs ()), "Bubble Event#3");
1680                 }
1681
1682                 bool _MenuItemClick;
1683
1684                 void pm_MenuItemClick (object sender, MenuEventArgs e) {
1685                         _MenuItemClick = true;
1686                 }
1687
1688                 [Test]
1689                 [Category ("NunitWeb")]
1690                 public void Menu_PreRenderEvent ()
1691                 {
1692                         new WebTest (PageInvoker.CreateOnLoad (PreRenderEvent)).Run ();
1693                 }
1694                 public void PreRenderEvent (Page p)
1695                 {
1696                         PokerMenu pm = new PokerMenu ();
1697                         p.Controls.Add (pm);
1698                         pm.PreRender += new EventHandler (OnPreRenderHandler);
1699                         Assert.AreEqual (false, OnPreRender, "BeforePreRender");
1700                         pm.DoOnPreRender (new EventArgs ());
1701                         Assert.AreEqual (true, OnPreRender, "AfterPreRender");
1702                 }
1703                 [TestFixtureTearDown]
1704                 public void TearDown ()
1705                 {
1706                         WebTest.Unload ();
1707                 }
1708         
1709                 // A simple Template class to wrap an image.
1710                 public class ImageTemplate : ITemplate
1711                 {
1712                         private MyWebControl.Image myImage;
1713                         public MyWebControl.Image MyImage
1714                         {
1715                                 get
1716                                 {
1717                                         return myImage;
1718                                 }
1719                                 set
1720                                 {
1721                                         myImage = value;
1722                                 }
1723                         }
1724                         public void InstantiateIn (Control container)
1725                         {
1726                                 container.Controls.Add (MyImage);
1727                         }
1728                 }
1729                 [Test]
1730                 [Category ("NunitWeb")]
1731 #if NET_4_0 && !DOT_NET
1732                 [Ignore ("Temporarily ignored on Mono until the Menu control is updated for 4.0")]
1733 #endif
1734                 public void MenuClass ()
1735                 {
1736                         string res = new WebTest ("menuclass.aspx").Run ();
1737 #if NET_4_0
1738                         string menua_pattern="<div[^>]*class=\"[^\"]*menua[^\"]*\"[^>]*>";
1739 #else
1740                         string menua_pattern="<table[^>]*class=\"[^\"]*menua[^\"]*\"[^>]*>";
1741 #endif
1742                         Assert.IsTrue (Regex.IsMatch (res, ".*"+menua_pattern+".*",
1743                                 RegexOptions.IgnoreCase|RegexOptions.Singleline),
1744                                 "check that <table class=\"menua\"> is found");
1745                         Assert.IsFalse (Regex.IsMatch (res, ".*"+menua_pattern+".*"+menua_pattern+".*",
1746                                 RegexOptions.IgnoreCase|RegexOptions.Singleline),
1747                                 "check that <table class=\"menua\"> is found only once");
1748                 }
1749
1750                 [Test]
1751                 [Category ("NunitWeb")]
1752                 [Category ("NotDotNet")] // implementation specific
1753                 public void Menu_PostBack ()
1754                 {
1755                         PageDelegates pd = new PageDelegates ();
1756                         pd.Init = Menu_SetTableMode;
1757                         WebTest t = new WebTest ("PostBackMenuTest.aspx");
1758                         t.Invoker = new PageInvoker (pd);
1759
1760                         string str = t.Run ();
1761                         FormRequest fr = new FormRequest (t.Response, "form1");
1762                         fr.Controls.Add ("__EVENTTARGET");
1763                         fr.Controls.Add ("__EVENTARGUMENT");
1764                         fr.Controls["__EVENTTARGET"].Value = "Menu1";
1765                         fr.Controls ["__EVENTARGUMENT"].Value = "0_1";
1766                         t.Request = fr;
1767                         pd.PreRender = _MenuItemsPost;
1768                         t.Invoker = new PageInvoker (pd);
1769                         t.Run ();
1770                 }
1771
1772                 public static void Menu_SetTableMode (Page p)
1773                 {
1774 #if NET_4_0
1775                         Menu m = p.Form.FindControl ("Menu1") as Menu;
1776                         Assert.IsNotNull (m, "Menu present");
1777                         m.RenderingMode = MenuRenderingMode.Table;
1778 #endif
1779                 }
1780                 
1781                 public static void _MenuItemsPost (Page p)
1782                 {
1783                         foreach (Control c in p.Form.Controls) {
1784                                 Menu m = c as Menu;
1785                                 if (m != null) {
1786                                         Assert.AreEqual ("node2", m.SelectedValue, "MenuItemsPostBack");
1787                                 }
1788                         }
1789                 }
1790
1791                 [Test]
1792                 [Category ("NunitWeb")]
1793                 public void Menu_PostBackFireEvents_1 ()
1794                 {
1795                         PageDelegates pd = new PageDelegates ();
1796                         pd.Init = Menu_SetTableMode;
1797                         WebTest t = new WebTest ("PostBackMenuTest.aspx");
1798                         t.Invoker = new PageInvoker (pd);
1799                         
1800                         string str = t.Run ();
1801                         FormRequest fr = new FormRequest (t.Response, "form1");
1802                         fr.Controls.Add ("__EVENTTARGET");
1803                         fr.Controls.Add ("__EVENTARGUMENT");
1804                         fr.Controls["__EVENTTARGET"].Value = "Menu1";
1805 #if DOT_NET
1806                         fr.Controls["__EVENTARGUMENT"].Value = "root";  // "0_1";
1807 #else
1808                         fr.Controls ["__EVENTARGUMENT"].Value = "0";  // "0_1";
1809 #endif
1810                         t.Request = fr;
1811                         str = t.Run ();
1812                         Assert.AreEqual ("MenuItemClick", t.UserData.ToString (), "PostBackEvent");
1813                 }
1814
1815                 [Test]
1816                 [Category ("NunitWeb")]
1817                 public void Menu_PostBackFireEvents_2 ()
1818                 {
1819                         WebTest t = new WebTest ("PostBackMenuTest.aspx");
1820                         PageDelegates pd = new PageDelegates ();
1821                         pd.Init = PostBackFireEvents_Init ;
1822                         t.Invoker = new PageInvoker (pd);
1823                         t.Run ();
1824                         Assert.AreEqual ("MenuItemDataBound", t.UserData.ToString (), "MenuItemDataBound");
1825                 }
1826
1827                 public static void PostBackFireEvents_Init (Page p)
1828                 {
1829                         Menu_SetTableMode (p);
1830                         Menu m = new MenuTable ();
1831                         m.MenuItemDataBound += new MenuEventHandler (MenuItemDataBound_Event);
1832                         m.DataSource = LoadXml ();
1833                         p.Controls.Add (m);
1834                         m.DataBind ();
1835                 }
1836
1837                 public static XmlDataSource LoadXml ()
1838                 {
1839                         XmlDataSource ds = new XmlDataSource ();
1840                         ds.EnableCaching = false;
1841                         #region xml_doc
1842                         String xml_text = @"<siteMapNode url=""1"" title=""root""  description="""">
1843                                                 <siteMapNode url=""~/MyPage.aspx"" title=""node1""  description="""" />
1844                                             </siteMapNode>";
1845                         #endregion
1846                         ds.Data = xml_text;
1847                         return ds;
1848                 }
1849
1850                 static void MenuItemDataBound_Event (object sender, MenuEventArgs e)
1851                 {
1852                         WebTest.CurrentTest.UserData = "MenuItemDataBound"; 
1853                 }
1854
1855                 [Test]
1856                 public void MenuItemCollection1 ()
1857                 {
1858                         Menu m = new MenuTable ();
1859                         fillMenu (m);
1860
1861                         ((IStateManager) m.Items).TrackViewState ();
1862                         m.Items [0].Text = "root";
1863                         m.Items [0].ChildItems [0].Text = "node";
1864                         m.Items [0].ChildItems [0].ChildItems [0].Text = "subnode";
1865                         object state = ((IStateManager) m.Items).SaveViewState ();
1866
1867                         Menu copy = new MenuTable ();
1868                         fillMenu (copy);
1869                         ((IStateManager) copy.Items).TrackViewState ();
1870                         ((IStateManager) copy.Items).LoadViewState (state);
1871
1872                         Assert.AreEqual (1, copy.Items.Count);
1873                         Assert.AreEqual (2, copy.Items [0].ChildItems.Count);
1874                         Assert.AreEqual (1, copy.Items [0].ChildItems [0].ChildItems.Count);
1875
1876                         Assert.AreEqual ("root", copy.Items [0].Text);
1877                         Assert.AreEqual ("node", copy.Items [0].ChildItems [0].Text);
1878                         Assert.AreEqual ("subnode", copy.Items [0].ChildItems [0].ChildItems [0].Text);
1879                 }
1880                 
1881                 [Test]
1882                 public void MenuItemCollection2 ()
1883                 {
1884                         Menu m = new MenuTable ();
1885                         fillMenu (m);
1886
1887                         ((IStateManager) m.Items).TrackViewState ();
1888                         m.Items [0].Text = "root";
1889                         m.Items [0].ChildItems [0].Text = "node";
1890                         m.Items [0].ChildItems [0].ChildItems [0].Text = "subnode";
1891                         m.Items.Add (new MenuItem ("root 2"));
1892                         object state = ((IStateManager) m.Items).SaveViewState ();
1893
1894                         Menu copy = new MenuTable ();
1895                         fillMenu (copy);
1896                         ((IStateManager) copy.Items).TrackViewState ();
1897                         ((IStateManager) copy.Items).LoadViewState (state);
1898
1899                         Assert.AreEqual (2, copy.Items.Count);
1900                         Assert.AreEqual (2, copy.Items [0].ChildItems.Count);
1901                         Assert.AreEqual (1, copy.Items [0].ChildItems [0].ChildItems.Count);
1902
1903                         Assert.AreEqual ("root", copy.Items [0].Text);
1904                         Assert.AreEqual ("node", copy.Items [0].ChildItems [0].Text);
1905                         Assert.AreEqual ("subnode", copy.Items [0].ChildItems [0].ChildItems [0].Text);
1906                         Assert.AreEqual ("root 2", copy.Items [1].Text);
1907                 }
1908
1909                 [Test]
1910                 public void MenuItemCollection3 ()
1911                 {
1912                         Menu m = new MenuTable ();
1913                         fillMenu (m);
1914                         m.Items.Add (new MenuItem ("root 2"));
1915
1916                         ((IStateManager) m.Items).TrackViewState ();
1917                         m.Items [0].Text = "root";
1918                         m.Items [0].ChildItems [0].Text = "node";
1919                         m.Items [0].ChildItems [0].ChildItems [0].Text = "subnode";
1920                         m.Items.RemoveAt (1);
1921                         object state = ((IStateManager) m.Items).SaveViewState ();
1922
1923                         Menu copy = new MenuTable ();
1924                         fillMenu (copy);
1925                         copy.Items.Add (new MenuItem ("root 2"));
1926                         ((IStateManager) copy.Items).TrackViewState ();
1927                         ((IStateManager) copy.Items).LoadViewState (state);
1928
1929                         Assert.AreEqual (1, copy.Items.Count);
1930                         Assert.AreEqual (2, copy.Items [0].ChildItems.Count);
1931                         Assert.AreEqual (1, copy.Items [0].ChildItems [0].ChildItems.Count);
1932
1933                         Assert.AreEqual ("root", copy.Items [0].Text);
1934                         Assert.AreEqual ("node", copy.Items [0].ChildItems [0].Text);
1935                         Assert.AreEqual ("subnode", copy.Items [0].ChildItems [0].ChildItems [0].Text);
1936                 }
1937                 
1938                 [Test]
1939                 public void MenuItemCollection4 ()
1940                 {
1941                         Menu m = new MenuTable ();
1942                         fillMenu (m);
1943                         m.Items.Add (new MenuItem ("root 2"));
1944                         m.Items [0].ChildItems.RemoveAt (1);
1945
1946                         ((IStateManager) m.Items).TrackViewState ();
1947                         m.Items [0].Text = "root";
1948                         m.Items [0].ChildItems [0].Text = "node";
1949                         m.Items [0].ChildItems [0].ChildItems [0].Text = "subnode";
1950                         object state = ((IStateManager) m.Items).SaveViewState ();
1951
1952                         Menu copy = new MenuTable ();
1953                         fillMenu (copy);
1954                         copy.Items.Add (new MenuItem ("root 2"));
1955                         copy.Items [0].ChildItems.RemoveAt (1);
1956                         ((IStateManager) copy.Items).TrackViewState ();
1957                         ((IStateManager) copy.Items).LoadViewState (state);
1958
1959                         Assert.AreEqual (2, copy.Items.Count);
1960                         Assert.AreEqual (1, copy.Items [0].ChildItems.Count);
1961                         Assert.AreEqual (1, copy.Items [0].ChildItems [0].ChildItems.Count);
1962
1963                         Assert.AreEqual ("root", copy.Items [0].Text);
1964                         Assert.AreEqual ("node", copy.Items [0].ChildItems [0].Text);
1965                         Assert.AreEqual ("subnode", copy.Items [0].ChildItems [0].ChildItems [0].Text);
1966                 }
1967
1968                 [Test]
1969                 public void MenuItemCollection5 ()
1970                 {
1971                         Menu m = new MenuTable ();
1972                         ((IStateManager) m.Items).TrackViewState ();
1973                         fillMenu (m);
1974
1975                         object state = ((IStateManager) m.Items).SaveViewState ();
1976
1977                         Menu copy = new MenuTable ();
1978                         ((IStateManager) copy.Items).TrackViewState ();
1979                         ((IStateManager) copy.Items).LoadViewState (state);
1980
1981                         Assert.AreEqual (1, copy.Items.Count);
1982                         Assert.AreEqual (2, copy.Items [0].ChildItems.Count);
1983                         Assert.AreEqual (1, copy.Items [0].ChildItems [0].ChildItems.Count);
1984                 }
1985
1986                 private static void fillMenu (Menu m) {
1987                         m.Items.Clear ();
1988                         m.Items.Add (new MenuItem ());
1989                         m.Items [0].ChildItems.Add (new MenuItem ());
1990                         m.Items [0].ChildItems.Add (new MenuItem ());
1991                         m.Items [0].ChildItems [0].ChildItems.Add (new MenuItem ());
1992                 }
1993
1994                 [Test]
1995                 public void MenuItem_TextValue1 ()
1996                 {
1997                         MenuItem item = new MenuItem ();
1998                         item.Text = "TTT";
1999                         Assert.AreEqual ("TTT", item.Value, "MenuItem_TextValue1#1");
2000                         item.Value = "";
2001                         Assert.AreEqual ("", item.Value, "MenuItem_TextValue1#2");
2002                         item.Value = null;
2003                         Assert.AreEqual ("TTT", item.Value, "MenuItem_TextValue1#3");
2004                 }
2005
2006                 [Test]
2007                 public void MenuItem_TextValue2 ()
2008                 {
2009                         MenuItem item = new MenuItem ();
2010                         item.Value = "VVV";
2011                         Assert.AreEqual ("VVV", item.Text, "MenuItem_TextValue2#1");
2012                         item.Text = "";
2013                         Assert.AreEqual ("", item.Text, "MenuItem_TextValue2#2");
2014                         item.Text = null;
2015                         Assert.AreEqual ("VVV", item.Text, "MenuItem_TextValue2#3");
2016                 }
2017 #if NET_4_0
2018                 [Test]
2019                 public void Menu_RenderingMode ()
2020                 {
2021                         var m = new PokerMenu ();
2022
2023                         Assert.AreEqual (MenuRenderingMode.Default, m.RenderingMode, "#A1");
2024
2025                         Array values = Enum.GetValues (typeof (MenuRenderingMode));
2026                         int minValue = Int32.MaxValue, maxValue = Int32.MinValue;
2027
2028                         foreach (object v in values) {
2029                                 int value = (int) v;
2030                                 if (value < minValue)
2031                                         minValue = value;
2032                                 else if (value > maxValue)
2033                                         maxValue = value;
2034                         }
2035
2036                         AssertExtensions.Throws<ArgumentOutOfRangeException> (() => {
2037                                 m.RenderingMode = (MenuRenderingMode) (minValue - 1);
2038                         }, "#A2-1");
2039
2040                         AssertExtensions.Throws<ArgumentOutOfRangeException> (() => {
2041                                 m.RenderingMode = (MenuRenderingMode) (maxValue + 1);
2042                         }, "#A2-2");
2043                 }
2044 #endif
2045         }
2046 }