Merge pull request #3715 from kumpera/fix-44707
[mono.git] / mcs / class / System.Web / Test / System.Web.UI.WebControls / WizardTest.cs
1 //
2 // Tests for System.Web.UI.WebControls.WizardTest.cs
3 //
4 // Author:
5 //      Vladimir Krasnov  <vladimirk@mainsoft.com>
6 //      Yoni Klein (yonik@mainsoft.com) 
7 //
8 //
9 // Copyright (C) 2005 Novell, Inc (http://www.novell.com)
10 //
11 // Permission is hereby granted, free of charge, to any person obtaining
12 // a copy of this software and associated documentation files (the
13 // "Software"), to deal in the Software without restriction, including
14 // without limitation the rights to use, copy, modify, merge, publish,
15 // distribute, sublicense, and/or sell copies of the Software, and to
16 // permit persons to whom the Software is furnished to do so, subject to
17 // the following conditions:
18 //
19 // The above copyright notice and this permission notice shall be
20 // included in all copies or substantial portions of the Software.
21 //
22 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
25 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
26 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
27 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29
30
31
32
33 using System;
34 using System.Collections.Generic;
35 using System.Text;
36 using System.Web;
37 using System.Web.UI;
38 using System.Drawing;
39 using System.Web.UI.WebControls;
40 using Template = System.Web.UI.WebControls;
41 using System.IO;
42 using System.Collections;
43 using System.Collections.Specialized;
44 using NUnit.Framework;
45 using MonoTests.SystemWeb.Framework;
46 using MonoTests.stand_alone.WebHarness;
47 using System.Threading;
48
49 using MonoTests.Common;
50
51
52 namespace MonoTests.System.Web.UI.WebControls
53 {
54
55         class PokerWizard : Wizard
56         {
57                 // View state Stuff
58                 public PokerWizard ()
59                         : base ()
60                 {
61                         TrackViewState ();
62                 }
63
64                 public object SaveState ()
65                 {
66                         return SaveViewState ();
67                 }
68
69                 public void LoadState (object o)
70                 {
71                         LoadViewState (o);
72                 }
73
74                 public StateBag StateBag
75                 {
76                         get { return base.ViewState; }
77                 }
78
79                 public static string PokerCancelButtonID
80                 {
81                         get
82                         {
83                                 return PokerWizard.CancelButtonID;
84                         }
85                 }
86
87                 public static string PokerCustomFinishButtonID
88                 {
89                         get
90                         {
91                                 return PokerWizard.CustomFinishButtonID;
92                         }
93                 }
94
95                 public static string PokerCustomNextButtonID
96                 {
97                         get
98                         {
99                                 return PokerWizard.CustomNextButtonID;
100                         }
101                 }
102
103                 public static string PokerCustomPreviousButtonID
104                 {
105                         get
106                         {
107                                 return PokerWizard.CustomPreviousButtonID;
108                         }
109                 }
110
111                 public static string PokerDataListID
112                 {
113                         get
114                         {
115                                 return PokerWizard.DataListID;
116                         }
117                 }
118
119                 public static string PokerFinishButtonID
120                 {
121                         get
122                         {
123                                 return PokerWizard.FinishButtonID;
124                         }
125                 }
126
127                 public static string PokerFinishPreviousButtonID
128                 {
129                         get
130                         {
131                                 return PokerWizard.FinishPreviousButtonID;
132                         }
133                 }
134
135                 public static string PokerSideBarButtonID
136                 {
137                         get
138                         {
139                                 return PokerWizard.SideBarButtonID;
140                         }
141                 }
142
143                 public static string PokerStartNextButtonID
144                 {
145                         get
146                         {
147                                 return PokerWizard.StartNextButtonID;
148                         }
149                 }
150
151                 public static string PokerStepNextButtonID
152                 {
153                         get
154                         {
155                                 return PokerWizard.StepNextButtonID;
156                         }
157                 }
158
159                 public static string PokerStepPreviousButtonID
160                 {
161                         get
162                         {
163                                 return PokerWizard.StepPreviousButtonID;
164                         }
165                 }
166
167                 public HtmlTextWriterTag PokerTagKey
168                 {
169                         get
170                         {
171                                 return base.TagKey;
172                         }
173                 }
174
175                 public object PokerSaveControlState ()
176                 {
177                         return base.SaveControlState ();
178                 }
179
180                 public void PokerLoadControlState (object state)
181                 {
182                         base.LoadControlState (state);
183                 }
184
185                 public bool PokerAllowNavigationToStep (int index)
186                 {
187                         return base.AllowNavigationToStep (index);
188                 }
189
190                 public void PokerCreateChildControls ()
191                 {
192                         base.CreateChildControls ();
193                 }
194
195                 public ControlCollection PokerCreateControlCollection ()
196                 {
197                         return base.CreateControlCollection ();
198                 }
199
200                 public Style PokerCreateControlStyle ()
201                 {
202                         return base.CreateControlStyle ();
203                 }
204
205                 public void DoOnActiveStepChanged (object source, EventArgs e)
206                 {
207                         base.OnActiveStepChanged (source, e);
208                 }
209
210                 public void DoOnCancelButtonClick (EventArgs e)
211                 {
212                         base.OnCancelButtonClick (e);
213                 }
214
215                 public void DoOnDataBinding (EventArgs e)
216                 {
217                         base.OnDataBinding (e);
218                 }
219
220                 public void DoOnFinishButtonClick (WizardNavigationEventArgs e)
221                 {
222                         base.OnFinishButtonClick (e);
223                 }
224
225                 public void DoOnInit (EventArgs e)
226                 {
227                         base.OnInit (e);
228                 }
229
230                 public void DoOnLoad (EventArgs e)
231                 {
232                         base.OnLoad (e);
233                 }
234
235                 public void DoOnNextButtonClick (WizardNavigationEventArgs e)
236                 {
237                         base.OnNextButtonClick (e);
238                 }
239
240                 public void DoOnPreRender (EventArgs e)
241                 {
242                         base.OnPreRender (e);
243                 }
244
245                 public void DoOnPreviousButtonClick (WizardNavigationEventArgs e)
246                 {
247                         base.OnPreviousButtonClick (e);
248                 }
249
250                 public void DoOnSideBarButtonClick (WizardNavigationEventArgs e)
251                 {
252                         base.OnSideBarButtonClick (e);
253                 }
254
255                 public string Tag
256                 {
257                         get { return base.TagName; }
258                 }
259
260                 public string Render ()
261                 {
262                         StringWriter sw = new StringWriter ();
263                         sw.NewLine = "\n";
264                         HtmlTextWriter writer = new HtmlTextWriter (sw);
265                         base.Render (writer);
266                         return writer.InnerWriter.ToString ();
267                 }
268
269                 public Style GetStyle ()
270                 {
271                         return base.CreateControlStyle ();
272                 }
273
274                 public void TrackState ()
275                 {
276                         TrackViewState ();
277                 }
278
279
280
281                 private bool onBubble;
282                 public bool OnBubbleEventCalled
283                 {
284                         get { return onBubble; }
285                         set { onBubble = value; }
286                 }
287                 protected override bool OnBubbleEvent (object source, EventArgs e)
288                 {
289                         onBubble = true;
290                         return base.OnBubbleEvent (source, e);
291                 }
292
293                 public bool DoBubbleEvent (object source, EventArgs e)
294                 {
295                         return base.OnBubbleEvent (source, e);
296                 }
297
298                 public void DoEnsureChildControls ()
299                 {
300                         base.EnsureChildControls ();
301                 }
302         }
303         class TestHeaderSpan : WebControl
304         {
305                 public TestHeaderSpan ()
306                         : base (HtmlTextWriterTag.Span)
307                 { }
308         }
309         class TestHeaderTemplate : ITemplate
310         {
311                 public void InstantiateIn (Control container)
312                 {
313                         container.Controls.Add (new LiteralControl ("Header"));
314                 }
315         }
316
317         class TestLayoutTemplate : ITemplate
318         {
319                 public bool HasHeaderPlaceHolder { get; set; }
320                 public bool HasNavigationPlaceHolder { get; set; }
321                 public bool HasSideBarPlaceHolder { get; set; }
322                 public bool HasWizardStepPlaceHolder { get; set; }
323
324                 public Type HeaderPlaceHolderType { get; set; }
325                 public Type NavigationPlaceHolderType { get; set; }
326                 public Type SideBarPlaceHolderType { get; set; }
327                 public Type WizardStepPlaceHolderType { get; set; }
328
329                 public TestLayoutTemplate ()
330                 {
331                         HeaderPlaceHolderType = typeof (PlaceHolder);
332                         NavigationPlaceHolderType = typeof (PlaceHolder);
333                         SideBarPlaceHolderType = typeof (PlaceHolder);
334                         WizardStepPlaceHolderType = typeof (PlaceHolder);
335                 }
336
337                 public void InstantiateIn (Control container)
338                 {
339                         if (HasHeaderPlaceHolder)
340                                 container.Controls.Add (MakePlaceHolder (HeaderPlaceHolderType, Wizard.HeaderPlaceholderId));
341
342                         if (HasSideBarPlaceHolder)
343                                 container.Controls.Add (MakePlaceHolder (SideBarPlaceHolderType, Wizard.SideBarPlaceholderId));
344
345                         if (HasNavigationPlaceHolder)
346                                 container.Controls.Add (MakePlaceHolder (NavigationPlaceHolderType, Wizard.NavigationPlaceholderId));
347
348                         if (HasWizardStepPlaceHolder)
349                                 container.Controls.Add (MakePlaceHolder (WizardStepPlaceHolderType, Wizard.WizardStepPlaceholderId));
350                 }
351
352                 Control MakePlaceHolder (Type type, string id)
353                 {
354                         Control ctl = Activator.CreateInstance (type) as Control;
355                         if (ctl == null)
356                                 throw new InvalidOperationException ("Placeholder must descend from the Control type.");
357
358                         ctl.ID = id;
359                         return ctl;
360                 }
361         }
362         [TestFixture]
363         public class WizardTest
364         {
365                 [Test]
366                 public void Wizard_DefaultProperty ()
367                 {
368                         PokerWizard wizard = new PokerWizard ();
369                         // Static members 
370                         Assert.AreEqual ("Cancel", Wizard.CancelCommandName, "CancelCommandName");
371                         Assert.AreEqual ("MoveComplete", Wizard.MoveCompleteCommandName, "MoveCompleteCommandName");
372                         Assert.AreEqual ("MoveNext", Wizard.MoveNextCommandName, "MoveNextCommandName");
373                         Assert.AreEqual ("MovePrevious", Wizard.MovePreviousCommandName, "MovePreviousCommandName");
374                         Assert.AreEqual ("Move", Wizard.MoveToCommandName, "MoveToCommandName");
375                         Assert.AreEqual ("headerPlaceholder", Wizard.HeaderPlaceholderId, "HeaderPlaceHolderId");
376                         Assert.AreEqual ("navigationPlaceholder", Wizard.NavigationPlaceholderId, "NavigationPlaceHolderId");
377                         Assert.AreEqual ("sideBarPlaceholder", Wizard.SideBarPlaceholderId, "SidePlaceholderId");
378                         Assert.AreEqual ("wizardStepPlaceholder", Wizard.WizardStepPlaceholderId, "WizardStepPlaceholderId");
379                         // Protected Fields 
380                         Assert.AreEqual ("CancelButton", PokerWizard.PokerCancelButtonID, "CancelButtonID");
381                         Assert.AreEqual ("CustomFinishButton", PokerWizard.PokerCustomFinishButtonID, "CustomFinishButtonID");
382                         Assert.AreEqual ("CustomNextButton", PokerWizard.PokerCustomNextButtonID, "CustomNextButtonID");
383                         Assert.AreEqual ("CustomPreviousButton", PokerWizard.PokerCustomPreviousButtonID, "CustomPreviousButtonID");
384                         Assert.AreEqual ("SideBarList", PokerWizard.PokerDataListID, "DataListID");
385                         Assert.AreEqual ("FinishButton", PokerWizard.PokerFinishButtonID, "FinishButtonID");
386                         Assert.AreEqual ("FinishPreviousButton", PokerWizard.PokerFinishPreviousButtonID, "FinishPreviousButtonID");
387                         Assert.AreEqual ("SideBarButton", PokerWizard.PokerSideBarButtonID, "SideBarButtonID");
388                         Assert.AreEqual ("StartNextButton", PokerWizard.PokerStartNextButtonID, "StartNextButtonID");
389                         Assert.AreEqual ("StepNextButton", PokerWizard.PokerStepNextButtonID, "StepNextButtonID");
390                         Assert.AreEqual ("StepPreviousButton", PokerWizard.PokerStepPreviousButtonID, "StepPreviousButtonID");
391                         //Public Properties 
392                         Assert.AreEqual ("", wizard.CancelButtonImageUrl, "CancelButtonImageUrl");
393                         Assert.AreEqual (typeof (Style), wizard.CancelButtonStyle.GetType (), "CancelButtonStyle");
394                         Assert.AreEqual ("Cancel", wizard.CancelButtonText, "CancelButtonText");
395                         Assert.AreEqual (ButtonType.Button, wizard.CancelButtonType, "CancelButtonType");
396                         Assert.AreEqual ("", wizard.CancelDestinationPageUrl, "CancelDestinationPageUrl");
397                         Assert.AreEqual (0, wizard.CellPadding, "CellPadding");
398                         Assert.AreEqual (0, wizard.CellSpacing, "CellSpacing");
399                         Assert.AreEqual (false, wizard.DisplayCancelButton, "DisplayCancelButton");
400                         Assert.AreEqual (true, wizard.DisplaySideBar, "DisplaySideBar");
401                         Assert.AreEqual ("", wizard.FinishCompleteButtonImageUrl, "FinishCompleteButtonImageUrl");
402                         Assert.AreEqual (typeof (Style), wizard.FinishCompleteButtonStyle.GetType (), "FinishCompleteButtonStyle");
403                         Assert.AreEqual ("Finish", wizard.FinishCompleteButtonText, "FinishCompleteButtonText");
404                         Assert.AreEqual (ButtonType.Button, wizard.FinishCompleteButtonType, "FinishCompleteButtonType");
405                         Assert.AreEqual ("", wizard.FinishDestinationPageUrl, "FinishDestinationPageUrl");
406                         Assert.AreEqual (null, wizard.FinishNavigationTemplate, "FinishNavigationTemplate");
407                         Assert.AreEqual ("", wizard.FinishPreviousButtonImageUrl, "FinishPreviousButtonImageUrl");
408                         Assert.AreEqual (typeof (Style), wizard.FinishPreviousButtonStyle.GetType (), "FinishPreviousButtonStyle");
409                         Assert.AreEqual ("Previous", wizard.FinishPreviousButtonText, "FinishPreviousButtonText");
410                         Assert.AreEqual (ButtonType.Button, wizard.FinishPreviousButtonType, "FinishPreviousButtonType");
411                         Assert.AreEqual (typeof (TableItemStyle), wizard.HeaderStyle.GetType (), "HeaderStyle");
412                         Assert.AreEqual (null, wizard.HeaderTemplate, "HeaderTemplate");
413                         Assert.AreEqual ("", wizard.HeaderText, "HeaderText");
414                         Assert.AreEqual (typeof (Style), wizard.NavigationButtonStyle.GetType (), "NavigationButtonStyle");
415                         Assert.AreEqual (typeof (TableItemStyle), wizard.NavigationStyle.GetType (), "NavigationStyle");
416                         Assert.AreEqual (typeof (Style), wizard.SideBarButtonStyle.GetType (), "SideBarButtonStyle");
417                         Assert.AreEqual (typeof (TableItemStyle), wizard.SideBarStyle.GetType (), "SideBarStyle");
418                         Assert.AreEqual (null, wizard.SideBarTemplate, "SideBarTemplate");
419                         Assert.AreEqual (null, wizard.StartNavigationTemplate, "StartNavigationTemplate");
420                         Assert.AreEqual ("", wizard.StartNextButtonImageUrl, "StartNextButtonImageUrl");
421                         Assert.AreEqual (typeof (Style), wizard.StartNextButtonStyle.GetType (), "StartNextButtonStyle");
422                         Assert.AreEqual ("Next", wizard.StartNextButtonText, "StartNextButtonText");
423                         Assert.AreEqual (ButtonType.Button, wizard.StartNextButtonType, "StartNextButtonType");
424                         Assert.AreEqual (null, wizard.StepNavigationTemplate, "StepNavigationTemplate");
425                         Assert.AreEqual ("", wizard.StepNextButtonImageUrl, "StepNextButtonImageUrl");
426                         Assert.AreEqual (typeof (Style), wizard.StepNextButtonStyle.GetType (), "StepNextButtonStyle");
427                         Assert.AreEqual ("Next", wizard.StepNextButtonText, "StepNextButtonText");
428                         Assert.AreEqual (ButtonType.Button, wizard.StepNextButtonType, "StepNextButtonType");
429                         Assert.AreEqual ("", wizard.StepPreviousButtonImageUrl, "StepPreviousButtonImageUrl");
430                         Assert.AreEqual (typeof (Style), wizard.StepPreviousButtonStyle.GetType (), "StepPreviousButtonStyle");
431                         Assert.AreEqual ("Previous", wizard.StepPreviousButtonText, "StepPreviousButtonText");
432                         Assert.AreEqual (ButtonType.Button, wizard.StepPreviousButtonType, "StepPreviousButtonType");
433                         Assert.AreEqual (typeof (TableItemStyle), wizard.StepStyle.GetType (), "StepStyle");
434                         Assert.AreEqual (typeof (WizardStepCollection), wizard.WizardSteps.GetType (), "WizardSteps");
435                         Assert.IsNotNull (wizard.WizardSteps, "WizardSteps");
436                 }
437
438                 [Test]
439                 public void Wizard_DefaultPropertyNotWorking ()
440                 {
441                         PokerWizard wizard = new PokerWizard ();
442                         Assert.AreEqual (null, wizard.ActiveStep, "ActiveStep");
443                         Assert.AreEqual ("Skip Navigation Links.", wizard.SkipLinkText, "SkipLinkText");
444                         // Protected Properties 
445                         Assert.AreEqual (typeof (HtmlTextWriterTag), wizard.PokerTagKey.GetType (), "TagKey");
446                 }
447
448                 [Test]
449                 public void Wizard_StateBag ()
450                 {
451                         PokerWizard w = new PokerWizard ();
452                         Assert.AreEqual (0, w.Attributes.Count, "Attributes.Count");
453                         Assert.AreEqual (0, w.StateBag.Count, "ViewState.Count");
454
455                         w.CancelButtonImageUrl = "value";
456                         Assert.AreEqual ("value", w.CancelButtonImageUrl, "CancelButtonImageUrl");
457                         Assert.AreEqual (1, w.StateBag.Count, "ViewState.Count-1");
458
459                         w.CancelDestinationPageUrl = "value";
460                         Assert.AreEqual ("value", w.CancelDestinationPageUrl, "CancelDestinationPageUrl");
461                         Assert.AreEqual (2, w.StateBag.Count, "ViewState.Count-2");
462
463                         w.FinishCompleteButtonImageUrl = "value";
464                         Assert.AreEqual ("value", w.FinishCompleteButtonImageUrl, "FinishCompleteButtonImageUrl");
465                         Assert.AreEqual (3, w.StateBag.Count, "ViewState.Count-3");
466
467                         w.FinishDestinationPageUrl = "value";
468                         Assert.AreEqual ("value", w.FinishDestinationPageUrl, "FinishDestinationPageUrl");
469                         Assert.AreEqual (4, w.StateBag.Count, "ViewState.Count-4");
470
471                         w.FinishPreviousButtonImageUrl = "value";
472                         Assert.AreEqual ("value", w.FinishPreviousButtonImageUrl, "FinishPreviousButtonImageUrl");
473                         Assert.AreEqual (5, w.StateBag.Count, "ViewState.Count-5");
474
475                         w.StartNextButtonImageUrl = "value";
476                         Assert.AreEqual ("value", w.StartNextButtonImageUrl, "StartNextButtonImageUrl");
477                         Assert.AreEqual (6, w.StateBag.Count, "ViewState.Count-6");
478
479                         w.StepNextButtonImageUrl = "value";
480                         Assert.AreEqual ("value", w.StepNextButtonImageUrl, "StepNextButtonImageUrl");
481                         Assert.AreEqual (7, w.StateBag.Count, "ViewState.Count-7");
482
483                         w.StepPreviousButtonImageUrl = "value";
484                         Assert.AreEqual ("value", w.StepPreviousButtonImageUrl, "StepPreviousButtonImageUrl");
485                         Assert.AreEqual (8, w.StateBag.Count, "ViewState.Count-8");
486
487                         w.CancelButtonText = "value";
488                         Assert.AreEqual ("value", w.CancelButtonText, "CancelButtonText");
489                         Assert.AreEqual (9, w.StateBag.Count, "ViewState.Count-9");
490
491                         w.FinishCompleteButtonText = "value";
492                         Assert.AreEqual ("value", w.FinishCompleteButtonText, "FinishCompleteButtonText");
493                         Assert.AreEqual (10, w.StateBag.Count, "ViewState.Count-10");
494
495                         w.StartNextButtonText = "value";
496                         Assert.AreEqual ("value", w.StartNextButtonText, "StartNextButtonText");
497                         Assert.AreEqual (11, w.StateBag.Count, "ViewState.Count-11");
498
499                         w.StepNextButtonText = "value";
500                         Assert.AreEqual ("value", w.StepNextButtonText, "StepNextButtonText");
501                         Assert.AreEqual (12, w.StateBag.Count, "ViewState.Count-12");
502
503                         w.StepPreviousButtonText = "value";
504                         Assert.AreEqual ("value", w.StepPreviousButtonText, "StepPreviousButtonText");
505                         Assert.AreEqual (13, w.StateBag.Count, "ViewState.Count-13");
506
507                         w.CancelButtonType = ButtonType.Button;
508                         Assert.AreEqual (ButtonType.Button, w.CancelButtonType, "CancelButtonType");
509                         Assert.AreEqual (14, w.StateBag.Count, "ViewState.Count-14");
510
511                         w.FinishCompleteButtonType = ButtonType.Button;
512                         Assert.AreEqual (ButtonType.Button, w.FinishCompleteButtonType, "FinishCompleteButtonType");
513                         Assert.AreEqual (15, w.StateBag.Count, "ViewState.Count-15");
514
515                         w.FinishPreviousButtonType = ButtonType.Button;
516                         Assert.AreEqual (ButtonType.Button, w.FinishPreviousButtonType, "FinishPreviousButtonType");
517                         Assert.AreEqual (16, w.StateBag.Count, "ViewState.Count-16");
518
519                         w.StartNextButtonType = ButtonType.Button;
520                         Assert.AreEqual (ButtonType.Button, w.StartNextButtonType, "StartNextButtonType");
521                         Assert.AreEqual (17, w.StateBag.Count, "ViewState.Count-17");
522
523                         w.StepNextButtonType = ButtonType.Button;
524                         Assert.AreEqual (ButtonType.Button, w.StepNextButtonType, "StepNextButtonType");
525                         Assert.AreEqual (18, w.StateBag.Count, "ViewState.Count-18");
526
527                         w.StepPreviousButtonType = ButtonType.Button;
528                         Assert.AreEqual (ButtonType.Button, w.StepPreviousButtonType, "StepPreviousButtonType");
529                         Assert.AreEqual (19, w.StateBag.Count, "ViewState.Count-19");
530                 }
531
532                 [Test]
533                 [Category ("NunitWeb")]
534                 public void Wizard_CancelButtonPropertyRendering ()
535                 {
536                         WebTest t = new WebTest (PageInvoker.CreateOnPreInit (_CancelButtonPropertyRendering));
537                         string html = t.Run ();
538                         string origin = "<table cellspacing=\"0\" cellpadding=\"0\" style=\"border-collapse:collapse;\">\r\n\t<tr style=\"height:100%;\">\r\n\t\t<td>Start</td>\r\n\t</tr><tr>\r\n\t\t<td align=\"right\"><table cellspacing=\"5\" cellpadding=\"5\">\r\n\t\t\t<tr>\r\n\t\t\t\t<td align=\"right\"><input type=\"submit\" name=\"ctl00$StartNavigationTemplateContainerID$StartNextButton\" value=\"Next\" id=\"ctl00_StartNavigationTemplateContainerID_StartNextButton\" /></td><td align=\"right\"><input type=\"submit\" name=\"ctl00$StartNavigationTemplateContainerID$CancelButton\" value=\"CancelButtonText\" id=\"ctl00_StartNavigationTemplateContainerID_CancelButton\" style=\"border-color:Red;\" /></td>\r\n\t\t\t</tr>\r\n\t\t</table></td>\r\n\t</tr>\r\n</table>";
539                         string renderedHtml = HtmlDiff.GetControlFromPageHtml (html);
540                         HtmlDiff.AssertAreEqual (origin, renderedHtml, "CancelButtonPropertyRendering");
541                 }
542
543                 public static void _CancelButtonPropertyRendering (Page p)
544                 {
545                         LiteralControl lcb = new LiteralControl (HtmlDiff.BEGIN_TAG);
546                         LiteralControl lce = new LiteralControl (HtmlDiff.END_TAG);
547                         PokerWizard w = new PokerWizard ();
548                         w.CancelButtonStyle.BorderColor = Color.Red;
549                         w.CancelButtonImageUrl = "CancelButtonImageUrl";
550                         w.CancelDestinationPageUrl = "CancelDestinationPageUrl";
551                         w.CancelButtonText = "CancelButtonText";
552                         w.CancelButtonType = ButtonType.Button;
553                         w.DisplayCancelButton = true;
554                         
555                         WizardStep ws1 = new WizardStep ();
556                         ws1.ID = "step1";
557                         ws1.StepType = WizardStepType.Start;
558                         ws1.Controls.Add (new LiteralControl ("Start"));
559
560                         WizardStep ws2 = new WizardStep ();
561                         ws2.ID = "step2";
562                         ws2.StepType = WizardStepType.Finish;
563                         ws2.Controls.Add (new LiteralControl ("Finish"));
564
565                         w.DisplaySideBar = false;
566                         w.WizardSteps.Add (ws1);
567                         w.WizardSteps.Add (ws2);
568                         p.Controls.Add(lcb);
569                         p.Controls.Add (w);
570                         p.Controls.Add (lce);
571                 }
572
573                 [Test]
574                 [Category ("NunitWeb")]
575                 public void Wizard_FinishButtonPropertyRendering ()
576                 {
577
578                         WebTest t = new WebTest (PageInvoker.CreateOnPreInit (_FinishButtonPropertyRendering));
579                         string html = t.Run ();
580                         string origin = "<table cellspacing=\"0\" cellpadding=\"0\" style=\"border-collapse:collapse;\">\r\n\t<tr style=\"height:100%;\">\r\n\t\t<td>Finish</td>\r\n\t</tr><tr>\r\n\t\t<td align=\"right\"><table cellspacing=\"5\" cellpadding=\"5\">\r\n\t\t\t<tr>\r\n\t\t\t\t<td align=\"right\"><input type=\"image\" name=\"ctl00$FinishNavigationTemplateContainerID$FinishPreviousImageButton\" id=\"ctl00_FinishNavigationTemplateContainerID_FinishPreviousImageButton\" src=\"http://FinishPreviousButtonImageUrl\" alt=\"FinishPreviousButtonText\" style=\"background-color:Red;\" /></td><td align=\"right\"><a id=\"ctl00_FinishNavigationTemplateContainerID_FinishLinkButton\" href=\"javascript:__doPostBack(&#39;ctl00$FinishNavigationTemplateContainerID$FinishLinkButton&#39;,&#39;&#39;)\" style=\"border-color:Red;\">FinishCompleteButtonText</a></td>\r\n\t\t\t</tr>\r\n\t\t</table></td>\r\n\t</tr>\r\n</table>";
581                         string renderedHtml = HtmlDiff.GetControlFromPageHtml (html);
582                         HtmlDiff.AssertAreEqual (origin, renderedHtml, "CancelButtonPropertyRendering");
583                 }
584
585                 public static void _FinishButtonPropertyRendering (Page p)
586                 {
587                         LiteralControl lcb = new LiteralControl (HtmlDiff.BEGIN_TAG);
588                         LiteralControl lce = new LiteralControl (HtmlDiff.END_TAG);
589                         PokerWizard w = new PokerWizard ();
590                         w.FinishCompleteButtonStyle.BorderColor = Color.Red;
591                         w.FinishCompleteButtonImageUrl = "http://FinishCompleteButtonImageUrl";
592                         w.FinishDestinationPageUrl = "FinishDestinationPageUrl";
593                         w.FinishCompleteButtonText = "FinishCompleteButtonText";
594                         w.FinishCompleteButtonType = ButtonType.Link;
595                         w.FinishPreviousButtonImageUrl = "http://FinishPreviousButtonImageUrl";
596                         w.FinishPreviousButtonStyle.BackColor = Color.Red;
597                         w.FinishPreviousButtonText = "FinishPreviousButtonText";
598                         w.FinishPreviousButtonType = ButtonType.Image;
599
600                         WizardStep ws0 = new WizardStep ();
601                         ws0.ID = "step0";
602                         ws0.StepType = WizardStepType.Start;
603                         ws0.Controls.Add (new LiteralControl ("Finish"));
604                         
605                         WizardStep ws1 = new WizardStep ();
606                         ws1.ID = "step1";
607                         ws1.StepType = WizardStepType.Finish;
608                         ws1.Controls.Add (new LiteralControl ("Finish"));
609                         
610                         w.DisplaySideBar = false;
611                         w.WizardSteps.Add (ws0);
612                         w.WizardSteps.Add (ws1);
613                         w.MoveTo (ws1);
614                         p.Controls.Add (lcb);
615                         p.Controls.Add (w);
616                         p.Controls.Add (lce);
617                 }
618
619                 [Test]
620                 [Category ("NunitWeb")]
621                 public void Wizard_HeaderRendering ()
622                 {
623                         WebTest t = new WebTest (PageInvoker.CreateOnPreInit (_HeaderRendering));
624                         string html = t.Run ();
625                         string origin = "<table cellspacing=\"0\" cellpadding=\"0\" style=\"border-collapse:collapse;\">\r\n\t<tr>\r\n\t\t<td style=\"background-color:Red;\"><input name=\"ctl00$HeaderContainer$TextBox1\" type=\"text\" id=\"ctl00_HeaderContainer_TextBox1\" /></td>\r\n\t</tr><tr style=\"height:100%;\">\r\n\t\t<td>Finish</td>\r\n\t</tr><tr>\r\n\t\t<td align=\"right\"><table cellspacing=\"5\" cellpadding=\"5\">\r\n\t\t\t<tr>\r\n\t\t\t\t<td align=\"right\"><input type=\"submit\" name=\"ctl00$FinishNavigationTemplateContainerID$FinishPreviousButton\" value=\"Previous\" id=\"ctl00_FinishNavigationTemplateContainerID_FinishPreviousButton\" /></td><td align=\"right\"><input type=\"submit\" name=\"ctl00$FinishNavigationTemplateContainerID$FinishButton\" value=\"Finish\" id=\"ctl00_FinishNavigationTemplateContainerID_FinishButton\" /></td>\r\n\t\t\t</tr>\r\n\t\t</table></td>\r\n\t</tr>\r\n</table>";
626                         string renderedHtml = HtmlDiff.GetControlFromPageHtml (html);
627                         HtmlDiff.AssertAreEqual (origin, renderedHtml, "HeaderRendering");
628                 }
629
630                 public static void _HeaderRendering (Page p)
631                 {
632                         LiteralControl lcb = new LiteralControl (HtmlDiff.BEGIN_TAG);
633                         LiteralControl lce = new LiteralControl (HtmlDiff.END_TAG);
634                         PokerWizard w = new PokerWizard ();
635                         w.HeaderStyle.BackColor = Color.Red;
636                         w.HeaderTemplate = new CompiledTemplateBuilder (_BuildHeader);
637                         w.HeaderText = "test";
638
639                         WizardStep ws0 = new WizardStep ();
640                         ws0.ID = "step0";
641                         ws0.StepType = WizardStepType.Start;
642                         ws0.Controls.Add (new LiteralControl ("Start"));
643                         
644                         WizardStep ws1 = new WizardStep ();
645                         ws1.ID = "step1";
646                         ws1.StepType = WizardStepType.Finish;
647                         ws1.Controls.Add (new LiteralControl ("Finish"));
648                         
649                         w.DisplaySideBar = false;
650                         w.WizardSteps.Add (ws0);
651                         w.WizardSteps.Add (ws1);
652                         w.MoveTo (ws1);
653                         p.Controls.Add (lcb);
654                         p.Controls.Add (w);
655                         p.Controls.Add (lce);
656                 }
657
658                 private static void _BuildHeader (Control container)
659                 {
660                         TextBox ctrl;
661                         ctrl = new TextBox ();
662                         ctrl.ID = "TextBox1";
663                         container.Controls.Add (ctrl);
664                 }
665
666                 [Test]
667                 [Category ("NunitWeb")]
668                 public void Wizard_SideBarRendering ()
669                 {
670                         WebTest t = new WebTest (PageInvoker.CreateOnPreInit (_SideBarRendering));
671                         string html = t.Run ();
672                         string origin = "<table cellspacing=\"0\" cellpadding=\"0\" style=\"border-collapse:collapse;\">\r\n\t<tr>\r\n\t\t<td style=\"background-color:Red;height:100%;\"><a href=\"#ctl00_SkipLink\"><img alt=\"Skip Navigation Links.\" height=\"0\" width=\"0\" src=\"/NunitWeb/WebResource.axd?d=8VpphgAbakKUC_J8R6hR0Q2&amp;t=634067491135766272\" style=\"border-width:0px;\" /></a><table id=\"ctl00_SideBarContainer_SideBarList\" cellspacing=\"0\" style=\"border-collapse:collapse;\">\r\n\t\t\t<tr>\r\n\t\t\t\t<td><input type=\"button\" name=\"ctl00$SideBarContainer$SideBarList$ctl00$SideBarButton\" value=\"step1\" onclick=\"javascript:__doPostBack(&#39;ctl00$SideBarContainer$SideBarList$ctl00$SideBarButton&#39;,&#39;&#39;)\" id=\"ctl00_SideBarContainer_SideBarList_SideBarButton_0\" /></td>\r\n\t\t\t</tr><tr>\r\n\t\t\t\t<td><input type=\"button\" name=\"ctl00$SideBarContainer$SideBarList$ctl01$SideBarButton\" value=\"step2\" onclick=\"javascript:__doPostBack(&#39;ctl00$SideBarContainer$SideBarList$ctl01$SideBarButton&#39;,&#39;&#39;)\" id=\"ctl00_SideBarContainer_SideBarList_SideBarButton_1\" /></td>\r\n\t\t\t</tr>\r\n\t\t</table><a id=\"ctl00_SkipLink\"></a></td><td style=\"height:100%;\"><table cellspacing=\"0\" cellpadding=\"0\" style=\"height:100%;width:100%;border-collapse:collapse;\">\r\n\t\t\t<tr style=\"height:100%;\">\r\n\t\t\t\t<td>Step 1</td>\r\n\t\t\t</tr><tr>\r\n\t\t\t\t<td align=\"right\"><table cellspacing=\"5\" cellpadding=\"5\">\r\n\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t<td align=\"right\"><input type=\"submit\" name=\"ctl00$StartNavigationTemplateContainerID$StartNextButton\" value=\"Next\" id=\"ctl00_StartNavigationTemplateContainerID_StartNextButton\" /></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>";
673                         string renderedHtml = HtmlDiff.GetControlFromPageHtml (html);
674                         HtmlDiff.AssertAreEqual (origin, renderedHtml, "SideBarRendering");
675                 }
676
677                 public static void _SideBarRendering (Page p)
678                 {
679                         LiteralControl lcb = new LiteralControl (HtmlDiff.BEGIN_TAG);
680                         LiteralControl lce = new LiteralControl (HtmlDiff.END_TAG);
681                         PokerWizard w = new PokerWizard ();
682                         
683                         w.SideBarButtonStyle.BackColor = Color.Red;
684                         w.SideBarStyle.BackColor = Color.Red;
685                         w.SideBarTemplate = new CompiledTemplateBuilder (_SideBarTemplate);
686
687                         WizardStep ws1 = new WizardStep ();
688                         ws1.ID = "step1";
689                         ws1.StepType = WizardStepType.Auto;
690                         ws1.Controls.Add (new LiteralControl ("Step 1"));
691
692                         WizardStep ws2 = new WizardStep ();
693                         ws2.ID = "step2";
694                         ws2.StepType = WizardStepType.Auto;
695                         ws2.Controls.Add (new LiteralControl ("Step 2"));
696
697                         w.WizardSteps.Add (ws1);
698                         w.WizardSteps.Add (ws2);
699                         p.Controls.Add (lcb);
700                         p.Controls.Add (w);
701                         p.Controls.Add (lce);
702                 }
703
704                 private static void _SideBarTemplate (Control container)
705                 {
706                         DataList list = new DataList ();
707                         list.ItemTemplate = new CompiledTemplateBuilder (_ItemTemplate);
708                         list.ID = "SideBarList";
709                         container.Controls.Add (list);
710                 }
711
712                 private static void _ItemTemplate (Control container)
713                 {
714                         Button button = new Button();
715                         button.ID = "SideBarButton";
716                         container.Controls.Add (button);
717                 }
718
719                 [Test]
720                 [Category ("NunitWeb")]
721                 public void Wizard_NavigationRendering ()
722                 {
723                         WebTest t = new WebTest (PageInvoker.CreateOnPreInit (_NavigationRendering));
724                         string html = t.Run ();
725                         string origin = "<table cellspacing=\"0\" cellpadding=\"0\" style=\"border-collapse:collapse;\">\r\n\t<tr>\r\n\t\t<td style=\"height:100%;\"><a href=\"#ctl00_SkipLink\"><img alt=\"Skip Navigation Links.\" height=\"0\" width=\"0\" src=\"/NunitWeb/WebResource.axd?d=8VpphgAbakKUC_J8R6hR0Q2&amp;t=634067491135766272\" style=\"border-width:0px;\" /></a><table id=\"ctl00_SideBarContainer_SideBarList\" cellspacing=\"0\" style=\"border-collapse:collapse;\">\r\n\t\t\t<tr>\r\n\t\t\t\t<td style=\"font-weight:bold;\"><a id=\"ctl00_SideBarContainer_SideBarList_SideBarButton_0\" href=\"javascript:__doPostBack(&#39;ctl00$SideBarContainer$SideBarList$ctl00$SideBarButton&#39;,&#39;&#39;)\">step1</a></td>\r\n\t\t\t</tr><tr>\r\n\t\t\t\t<td><a id=\"ctl00_SideBarContainer_SideBarList_SideBarButton_1\" href=\"javascript:__doPostBack(&#39;ctl00$SideBarContainer$SideBarList$ctl01$SideBarButton&#39;,&#39;&#39;)\">step2</a></td>\r\n\t\t\t</tr>\r\n\t\t</table><a id=\"ctl00_SkipLink\"></a></td><td style=\"height:100%;\"><table cellspacing=\"0\" cellpadding=\"0\" style=\"height:100%;width:100%;border-collapse:collapse;\">\r\n\t\t\t<tr style=\"height:100%;\">\r\n\t\t\t\t<td>Start</td>\r\n\t\t\t</tr><tr>\r\n\t\t\t\t<td align=\"right\" style=\"background-color:Yellow;\"><table cellspacing=\"5\" cellpadding=\"5\">\r\n\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t<td align=\"right\"><input type=\"submit\" name=\"ctl00$StartNavigationTemplateContainerID$StartNextButton\" value=\"Next\" id=\"ctl00_StartNavigationTemplateContainerID_StartNextButton\" style=\"background-color:Red;\" /></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>";
726                         string renderedHtml = HtmlDiff.GetControlFromPageHtml (html);
727                         HtmlDiff.AssertAreEqual (origin, renderedHtml, "NavigationRendering");
728                 }
729
730                 public static void _NavigationRendering (Page p)
731                 {
732                         LiteralControl lcb = new LiteralControl (HtmlDiff.BEGIN_TAG);
733                         LiteralControl lce = new LiteralControl (HtmlDiff.END_TAG);
734                         PokerWizard w = new PokerWizard ();
735                         WizardStep ws1 = new WizardStep ();
736                         WizardStep ws2 = new WizardStep ();
737                         
738                         ws1.ID = "step1";
739                         ws1.StepType = WizardStepType.Start;
740                         ws1.Controls.Add (new LiteralControl ("Start"));
741
742                         ws2.ID = "step2";
743                         ws2.StepType = WizardStepType.Start;
744                         ws2.Controls.Add (new LiteralControl ("Finish"));
745                         
746                         w.NavigationButtonStyle.BackColor = Color.Red;
747                         w.NavigationStyle.BackColor = Color.Yellow;
748                         
749                         w.WizardSteps.Add (ws1);
750                         w.WizardSteps.Add (ws2);
751                         p.Controls.Add (lcb);
752                         p.Controls.Add (w);
753                         p.Controls.Add (lce);
754                 }
755
756                 [Test]
757                 [Category ("NunitWeb")]
758                 public void Wizard_StartTypeRendering ()
759                 {
760                         WebTest t = new WebTest (PageInvoker.CreateOnPreInit (_StartTypeRendering));
761                         string html = t.Run ();
762                         string origin = "<table cellspacing=\"0\" cellpadding=\"0\" style=\"border-collapse:collapse;\">\r\n\t<tr>\r\n\t\t<td style=\"height:100%;\"><a href=\"#ctl00_SkipLink\"><img alt=\"Skip Navigation Links.\" height=\"0\" width=\"0\" src=\"/NunitWeb/WebResource.axd?d=8VpphgAbakKUC_J8R6hR0Q2&amp;t=634067491135766272\" style=\"border-width:0px;\" /></a><table id=\"ctl00_SideBarContainer_SideBarList\" cellspacing=\"0\" style=\"border-collapse:collapse;\">\r\n\t\t\t<tr>\r\n\t\t\t\t<td style=\"font-weight:bold;\"><a id=\"ctl00_SideBarContainer_SideBarList_SideBarButton_0\" href=\"javascript:__doPostBack(&#39;ctl00$SideBarContainer$SideBarList$ctl00$SideBarButton&#39;,&#39;&#39;)\">step1</a></td>\r\n\t\t\t</tr><tr>\r\n\t\t\t\t<td><a id=\"ctl00_SideBarContainer_SideBarList_SideBarButton_1\" href=\"javascript:__doPostBack(&#39;ctl00$SideBarContainer$SideBarList$ctl01$SideBarButton&#39;,&#39;&#39;)\">step2</a></td>\r\n\t\t\t</tr>\r\n\t\t</table><a id=\"ctl00_SkipLink\"></a></td><td style=\"height:100%;\"><table cellspacing=\"0\" cellpadding=\"0\" style=\"height:100%;width:100%;border-collapse:collapse;\">\r\n\t\t\t<tr style=\"height:100%;\">\r\n\t\t\t\t<td>Start</td>\r\n\t\t\t</tr><tr>\r\n\t\t\t\t<td align=\"right\"><table cellspacing=\"5\" cellpadding=\"5\">\r\n\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t<td align=\"right\"><input type=\"submit\" name=\"ctl00$StartNavigationTemplateContainerID$StartNextButton\" value=\"StartNextButtonText\" id=\"ctl00_StartNavigationTemplateContainerID_StartNextButton\" style=\"background-color:Red;\" /></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>";
763                         string renderedHtml = HtmlDiff.GetControlFromPageHtml (html);
764                         HtmlDiff.AssertAreEqual (origin, renderedHtml, "StartTypeRendering");
765                 }
766
767                 public static void _StartTypeRendering (Page p)
768                 {
769                         LiteralControl lcb = new LiteralControl (HtmlDiff.BEGIN_TAG);
770                         LiteralControl lce = new LiteralControl (HtmlDiff.END_TAG);
771                         PokerWizard w = new PokerWizard ();
772                         WizardStep ws1 = new WizardStep ();
773                         WizardStep ws2 = new WizardStep ();
774
775                         ws1.ID = "step1";
776                         ws1.StepType = WizardStepType.Start;
777                         ws1.Controls.Add (new LiteralControl ("Start"));
778
779                         ws2.ID = "step2";
780                         ws2.StepType = WizardStepType.Finish;
781                         ws2.Controls.Add (new LiteralControl ("Finish"));
782                         
783                         w.StartNextButtonImageUrl = "StartNextButtonImageUrl";
784                         w.StartNextButtonStyle.BackColor = Color.Red;
785                         w.StartNextButtonText = "StartNextButtonText";
786                         w.StartNextButtonType = ButtonType.Button;
787
788                         w.WizardSteps.Add (ws1);
789                         w.WizardSteps.Add (ws2);
790                         p.Controls.Add (lcb);
791                         p.Controls.Add (w);
792                         p.Controls.Add (lce);
793                 }
794
795                 [Test]
796                 [Category ("NunitWeb")]
797                 public void Wizard_StartTemplateRendering ()
798                 {
799                         WebTest t = new WebTest (PageInvoker.CreateOnPreInit (_StartTemplateRendering));
800                         string html = t.Run ();
801                         string origin = "<table cellspacing=\"0\" cellpadding=\"0\" style=\"border-collapse:collapse;\">\r\n\t<tr>\r\n\t\t<td style=\"height:100%;\"><a href=\"#ctl00_SkipLink\"><img alt=\"Skip Navigation Links.\" height=\"0\" width=\"0\" src=\"/NunitWeb/WebResource.axd?d=8VpphgAbakKUC_J8R6hR0Q2&amp;t=634067491135766272\" style=\"border-width:0px;\" /></a><table id=\"ctl00_SideBarContainer_SideBarList\" cellspacing=\"0\" style=\"border-collapse:collapse;\">\r\n\t\t\t<tr>\r\n\t\t\t\t<td style=\"font-weight:bold;\"><a id=\"ctl00_SideBarContainer_SideBarList_SideBarButton_0\" href=\"javascript:__doPostBack(&#39;ctl00$SideBarContainer$SideBarList$ctl00$SideBarButton&#39;,&#39;&#39;)\">step1</a></td>\r\n\t\t\t</tr>\r\n\t\t</table><a id=\"ctl00_SkipLink\"></a></td><td style=\"height:100%;\"><table cellspacing=\"0\" cellpadding=\"0\" style=\"height:100%;width:100%;border-collapse:collapse;\">\r\n\t\t\t<tr style=\"height:100%;\">\r\n\t\t\t\t<td>Start</td>\r\n\t\t\t</tr><tr>\r\n\t\t\t\t<td align=\"right\"><input type=\"submit\" name=\"ctl00$StartNavigationTemplateContainerID$SideBarButton\" value=\"\" id=\"ctl00_StartNavigationTemplateContainerID_SideBarButton\" style=\"background-color:Red;\" /></td>\r\n\t\t\t</tr>\r\n\t\t</table></td>\r\n\t</tr>\r\n</table>";
802                         string renderedHtml = HtmlDiff.GetControlFromPageHtml (html);
803                         HtmlDiff.AssertAreEqual (origin, renderedHtml, "StartTemplateRendering");
804                 }
805
806                 public static void _StartTemplateRendering (Page p)
807                 {
808                         LiteralControl lcb = new LiteralControl (HtmlDiff.BEGIN_TAG);
809                         LiteralControl lce = new LiteralControl (HtmlDiff.END_TAG);
810                         PokerWizard w = new PokerWizard ();
811                         WizardStep ws1 = new WizardStep ();
812
813                         ws1.ID = "step1";
814                         ws1.StepType = WizardStepType.Start;
815                         ws1.Controls.Add (new LiteralControl ("Start"));
816
817                         w.StartNavigationTemplate = new CompiledTemplateBuilder (_StartTemplate);
818
819                         w.WizardSteps.Add (ws1);
820                         p.Controls.Add (lcb);
821                         p.Controls.Add (w);
822                         p.Controls.Add (lce);
823                 }
824
825                 private static void _StartTemplate (Control container)
826                 {
827                         Button button = new Button();
828                         button.ID = "SideBarButton";
829                         button.BackColor = Color.Red;
830                         container.Controls.Add (button);
831                 }
832
833                 [Test]
834                 [Category ("NunitWeb")]
835                 public void Wizard_StepTypeRendering ()
836                 {
837                         WebTest t = new WebTest (PageInvoker.CreateOnPreInit (_StepTypeRendering));
838                         string html = t.Run ();
839                         string origin = "<table cellspacing=\"0\" cellpadding=\"0\" style=\"border-collapse:collapse;\">\r\n\t<tr>\r\n\t\t<td style=\"height:100%;\"><a href=\"#ctl00_SkipLink\"><img alt=\"Skip Navigation Links.\" height=\"0\" width=\"0\" src=\"/NunitWeb/WebResource.axd?d=8VpphgAbakKUC_J8R6hR0Q2&amp;t=634067491135766272\" style=\"border-width:0px;\" /></a><table id=\"ctl00_SideBarContainer_SideBarList\" cellspacing=\"0\" style=\"border-collapse:collapse;\">\r\n\t\t\t<tr>\r\n\t\t\t\t<td><a id=\"ctl00_SideBarContainer_SideBarList_SideBarButton_0\" href=\"javascript:__doPostBack(&#39;ctl00$SideBarContainer$SideBarList$ctl00$SideBarButton&#39;,&#39;&#39;)\">step1</a></td>\r\n\t\t\t</tr><tr>\r\n\t\t\t\t<td style=\"font-weight:bold;\"><a id=\"ctl00_SideBarContainer_SideBarList_SideBarButton_1\" href=\"javascript:__doPostBack(&#39;ctl00$SideBarContainer$SideBarList$ctl01$SideBarButton&#39;,&#39;&#39;)\">step2</a></td>\r\n\t\t\t</tr><tr>\r\n\t\t\t\t<td><a id=\"ctl00_SideBarContainer_SideBarList_SideBarButton_2\" href=\"javascript:__doPostBack(&#39;ctl00$SideBarContainer$SideBarList$ctl02$SideBarButton&#39;,&#39;&#39;)\">step3</a></td>\r\n\t\t\t</tr>\r\n\t\t</table><a id=\"ctl00_SkipLink\"></a></td><td style=\"height:100%;\"><table cellspacing=\"0\" cellpadding=\"0\" style=\"height:100%;width:100%;border-collapse:collapse;\">\r\n\t\t\t<tr style=\"height:100%;\">\r\n\t\t\t\t<td style=\"background-color:Red;\">Step2</td>\r\n\t\t\t</tr><tr>\r\n\t\t\t\t<td align=\"right\"><table cellspacing=\"5\" cellpadding=\"5\">\r\n\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t<td align=\"right\"><a id=\"ctl00_StepNavigationTemplateContainerID_StepPreviousLinkButton\" href=\"javascript:__doPostBack(&#39;ctl00$StepNavigationTemplateContainerID$StepPreviousLinkButton&#39;,&#39;&#39;)\" style=\"background-color:Red;\">StepPreviousButtonText</a></td><td align=\"right\"><input type=\"image\" name=\"ctl00$StepNavigationTemplateContainerID$StepNextImageButton\" id=\"ctl00_StepNavigationTemplateContainerID_StepNextImageButton\" src=\"http://StepNextButtonImageUrl\" alt=\"StepNextButtonText\" style=\"background-color:Red;\" /></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>";
840                         string renderedHtml = HtmlDiff.GetControlFromPageHtml (html);
841                         HtmlDiff.AssertAreEqual (origin, renderedHtml, "StepRendering");
842                 }
843
844                 public static void _StepTypeRendering (Page p)
845                 {
846                         LiteralControl lcb = new LiteralControl (HtmlDiff.BEGIN_TAG);
847                         LiteralControl lce = new LiteralControl (HtmlDiff.END_TAG);
848                         PokerWizard w = new PokerWizard ();
849                         WizardStep ws1 = new WizardStep ();
850                         WizardStep ws2 = new WizardStep ();
851                         WizardStep ws3 = new WizardStep ();
852
853                         ws1.ID = "step1";
854                         ws1.StepType = WizardStepType.Start;
855                         ws1.Controls.Add (new LiteralControl ("Step1"));
856
857                         ws2.ID = "step2";
858                         ws2.StepType = WizardStepType.Step;
859                         ws2.Controls.Add (new LiteralControl ("Step2"));
860
861                         ws3.ID = "step3";
862                         ws3.StepType = WizardStepType.Finish;
863                         ws3.Controls.Add (new LiteralControl ("Step3"));
864
865                         w.StepNextButtonImageUrl = "http://StepNextButtonImageUrl";
866                         w.StepNextButtonStyle.BackColor = Color.Red;
867                         w.StepNextButtonText = "StepNextButtonText";
868                         w.StepNextButtonType = ButtonType.Image;
869                         w.StepPreviousButtonImageUrl = "http://StepPreviousButtonImageUrl";
870                         w.StepPreviousButtonStyle.BackColor = Color.Red;
871                         w.StepPreviousButtonText = "StepPreviousButtonText";
872                         w.StepPreviousButtonType = ButtonType.Link;
873                         w.StepStyle.BackColor = Color.Red;
874                         
875                         w.WizardSteps.Add (ws1);
876                         w.WizardSteps.Add (ws2);
877                         w.WizardSteps.Add (ws3);
878                         w.MoveTo (ws2);
879
880                         p.Controls.Add (lcb);
881                         p.Controls.Add (w);
882                         p.Controls.Add (lce);
883                 }
884
885                 [Test]
886                 [Category ("NunitWeb")]
887                 public void Wizard_StepNavigationTemplateRendering ()
888                 {
889                         WebTest t = new WebTest (PageInvoker.CreateOnPreInit (_StepNavigationTemplate));
890                         string html = t.Run ();
891                         string origin = "<table cellspacing=\"0\" cellpadding=\"0\" style=\"border-collapse:collapse;\">\r\n\t<tr>\r\n\t\t<td style=\"height:100%;\"><a href=\"#ctl00_SkipLink\"><img alt=\"Skip Navigation Links.\" height=\"0\" width=\"0\" src=\"/NunitWeb/WebResource.axd?d=8VpphgAbakKUC_J8R6hR0Q2&amp;t=634067491135766272\" style=\"border-width:0px;\" /></a><table id=\"ctl00_SideBarContainer_SideBarList\" cellspacing=\"0\" style=\"border-collapse:collapse;\">\r\n\t\t\t<tr>\r\n\t\t\t\t<td style=\"font-weight:bold;\"><a id=\"ctl00_SideBarContainer_SideBarList_SideBarButton_0\" href=\"javascript:__doPostBack(&#39;ctl00$SideBarContainer$SideBarList$ctl00$SideBarButton&#39;,&#39;&#39;)\">step1</a></td>\r\n\t\t\t</tr><tr>\r\n\t\t\t\t<td><a id=\"ctl00_SideBarContainer_SideBarList_SideBarButton_1\" href=\"javascript:__doPostBack(&#39;ctl00$SideBarContainer$SideBarList$ctl01$SideBarButton&#39;,&#39;&#39;)\">step2</a></td>\r\n\t\t\t</tr>\r\n\t\t</table><a id=\"ctl00_SkipLink\"></a></td><td style=\"height:100%;\"><table cellspacing=\"0\" cellpadding=\"0\" style=\"height:100%;width:100%;border-collapse:collapse;\">\r\n\t\t\t<tr style=\"height:100%;\">\r\n\t\t\t\t<td>Step1</td>\r\n\t\t\t</tr><tr>\r\n\t\t\t\t<td align=\"right\"><input type=\"submit\" name=\"ctl00$StepNavigationTemplateContainerID$SideBarButton\" value=\"\" id=\"ctl00_StepNavigationTemplateContainerID_SideBarButton\" style=\"background-color:Red;\" />Test text</td>\r\n\t\t\t</tr>\r\n\t\t</table></td>\r\n\t</tr>\r\n</table>";
892                         string renderedHtml = HtmlDiff.GetControlFromPageHtml (html);
893                         HtmlDiff.AssertAreEqual (origin, renderedHtml, "StepNavigationTemplateRendering");
894                 }
895
896                 public static void _StepNavigationTemplate (Page p)
897                 {
898                         LiteralControl lcb = new LiteralControl (HtmlDiff.BEGIN_TAG);
899                         LiteralControl lce = new LiteralControl (HtmlDiff.END_TAG);
900                         PokerWizard w = new PokerWizard ();
901                         WizardStep ws1 = new WizardStep ();
902                         WizardStep ws2 = new WizardStep ();
903
904                         ws1.ID = "step1";
905                         ws1.StepType = WizardStepType.Step;
906                         ws1.Controls.Add (new LiteralControl ("Step1"));
907
908                         ws2.ID = "step2";
909                         ws2.StepType = WizardStepType.Step;
910                         ws2.Controls.Add (new LiteralControl ("Step2"));
911
912                         w.StepNavigationTemplate = new CompiledTemplateBuilder (_StepNavigationTemplateCreator);
913
914                         w.WizardSteps.Add (ws1);
915                         w.WizardSteps.Add (ws2);
916                         p.Controls.Add (lcb);
917                         p.Controls.Add (w);
918                         p.Controls.Add (lce);
919                 }
920
921
922                 private static void _StepNavigationTemplateCreator (Control container)
923                 {
924                         Button button = new Button();
925                         button.ID = "SideBarButton";
926                         button.BackColor = Color.Red;
927                         LiteralControl label = new LiteralControl ("Test text");
928                         container.Controls.Add (button);
929                         container.Controls.Add (label);
930                 }
931
932                 
933
934
935                 
936                 [Test]
937                 public void Wizard_AssignProperty ()
938                 {
939                         PokerWizard wizard = new PokerWizard ();
940                         wizard.CancelButtonImageUrl = "test";
941                         Assert.AreEqual ("test", wizard.CancelButtonImageUrl, "CancelButtonImageUrl");
942                         wizard.CancelButtonStyle.BackColor = Color.Red;
943                         Assert.AreEqual (Color.Red, wizard.CancelButtonStyle.BackColor, "CancelButtonStyle");
944                         wizard.CancelButtonText = "test";
945                         Assert.AreEqual ("test", wizard.CancelButtonText, "CancelButtonText");
946                         wizard.CancelButtonType = ButtonType.Image;
947                         Assert.AreEqual (ButtonType.Image, wizard.CancelButtonType, "CancelButtonType");
948                         wizard.CancelDestinationPageUrl = "test";
949                         Assert.AreEqual ("test", wizard.CancelDestinationPageUrl, "CancelDestinationPageUrl");
950                         wizard.CellPadding = 1;
951                         Assert.AreEqual (1, wizard.CellPadding, "CellPadding");
952                         wizard.CellSpacing = 1;
953                         Assert.AreEqual (1, wizard.CellSpacing, "CellSpacing");
954                         wizard.DisplayCancelButton = true;
955                         Assert.AreEqual (true, wizard.DisplayCancelButton, "DisplayCancelButton");
956                         wizard.DisplaySideBar = false;
957                         Assert.AreEqual (false, wizard.DisplaySideBar, "DisplaySideBar");
958                         wizard.FinishCompleteButtonImageUrl = "test";
959                         Assert.AreEqual ("test", wizard.FinishCompleteButtonImageUrl, "FinishCompleteButtonImageUrl");
960                         wizard.FinishCompleteButtonStyle.BackColor = Color.Red;
961                         Assert.AreEqual (Color.Red, wizard.FinishCompleteButtonStyle.BackColor, "FinishCompleteButtonStyle");
962                         wizard.FinishCompleteButtonText = "test";
963                         Assert.AreEqual ("test", wizard.FinishCompleteButtonText, "FinishCompleteButtonText");
964                         wizard.FinishCompleteButtonType = ButtonType.Image;
965                         Assert.AreEqual (ButtonType.Image, wizard.FinishCompleteButtonType, "FinishCompleteButtonType");
966                         wizard.FinishDestinationPageUrl = "test";
967                         Assert.AreEqual ("test", wizard.FinishDestinationPageUrl, "FinishDestinationPageUrl");
968                         wizard.FinishNavigationTemplate = new ImageTemplate ();
969                         Assert.AreEqual (typeof (ImageTemplate), wizard.FinishNavigationTemplate.GetType (), "FinishNavigationTemplate");
970                         wizard.FinishPreviousButtonImageUrl = "test";
971                         Assert.AreEqual ("test", wizard.FinishPreviousButtonImageUrl, "FinishPreviousButtonImageUrl");
972                         wizard.FinishPreviousButtonStyle.BackColor = Color.Red;
973                         Assert.AreEqual (Color.Red, wizard.FinishPreviousButtonStyle.BackColor, "FinishPreviousButtonStyle");
974                         wizard.FinishPreviousButtonText = "test";
975                         Assert.AreEqual ("test", wizard.FinishPreviousButtonText, "FinishPreviousButtonText");
976                         wizard.FinishPreviousButtonType = ButtonType.Image;
977                         Assert.AreEqual (ButtonType.Image, wizard.FinishPreviousButtonType, "FinishPreviousButtonType");
978                         wizard.HeaderStyle.BackColor = Color.Red;
979                         Assert.AreEqual (Color.Red, wizard.HeaderStyle.BackColor, "HeaderStyle");
980                         wizard.HeaderTemplate = new ImageTemplate ();
981                         Assert.AreEqual (typeof (ImageTemplate), wizard.HeaderTemplate.GetType (), "HeaderTemplate");
982                         wizard.HeaderText = "test";
983                         Assert.AreEqual ("test", wizard.HeaderText, "HeaderText");
984                         wizard.NavigationButtonStyle.BackColor = Color.Red;
985                         Assert.AreEqual (Color.Red, wizard.NavigationButtonStyle.BackColor, "NavigationButtonStyle");
986                         wizard.NavigationStyle.BackColor = Color.Red;
987                         Assert.AreEqual (Color.Red, wizard.NavigationStyle.BackColor, "NavigationStyle");
988                         wizard.SideBarButtonStyle.BackColor = Color.Red;
989                         wizard.SideBarButtonStyle.BackColor = Color.Red;
990                         Assert.AreEqual (Color.Red, wizard.SideBarButtonStyle.BackColor, "SideBarButtonStyle");
991                         wizard.SideBarStyle.BackColor = Color.Red;
992                         Assert.AreEqual (Color.Red, wizard.SideBarStyle.BackColor, "SideBarStyle");
993                         wizard.SideBarTemplate = new ImageTemplate ();
994                         Assert.AreEqual (typeof (ImageTemplate), wizard.SideBarTemplate.GetType (), "SideBarTemplate");
995                         // SkipLinkText throws System.NotImplementedException look not workihg properties
996                         // wizard.SkipLinkText = "test";
997                         // Assert.AreEqual ("test", wizard.SkipLinkText, "SkipLinkText");
998                         wizard.StartNavigationTemplate = new ImageTemplate ();
999                         Assert.AreEqual (typeof (ImageTemplate), wizard.StartNavigationTemplate.GetType (), "StartNavigationTemplate");
1000                         wizard.StartNextButtonImageUrl = "test";
1001                         Assert.AreEqual ("test", wizard.StartNextButtonImageUrl, "StartNextButtonImageUrl");
1002                         wizard.StartNextButtonStyle.BackColor = Color.Red;
1003                         Assert.AreEqual (Color.Red, wizard.StartNextButtonStyle.BackColor, "StartNextButtonStyle");
1004                         wizard.StartNextButtonText = "test";
1005                         Assert.AreEqual ("test", wizard.StartNextButtonText, "StartNextButtonText");
1006                         wizard.StartNextButtonType = ButtonType.Image;
1007                         Assert.AreEqual (ButtonType.Image, wizard.StartNextButtonType, "StartNextButtonType");
1008                         wizard.StepNavigationTemplate = new ImageTemplate ();
1009                         Assert.AreEqual (typeof (ImageTemplate), wizard.StepNavigationTemplate.GetType (), "StepNavigationTemplate");
1010                         wizard.StepNextButtonImageUrl = "test";
1011                         Assert.AreEqual ("test", wizard.StepNextButtonImageUrl, "StepNextButtonImageUrl");
1012                         wizard.StepNextButtonStyle.BackColor = Color.Red;
1013                         Assert.AreEqual (Color.Red, wizard.StepNextButtonStyle.BackColor, "StepNextButtonStyle");
1014                         wizard.StepNextButtonText = "test";
1015                         Assert.AreEqual ("test", wizard.StepNextButtonText, "StepNextButtonText");
1016                         wizard.StepNextButtonType = ButtonType.Image;
1017                         Assert.AreEqual (ButtonType.Image, wizard.StepNextButtonType, "StepNextButtonType");
1018                         wizard.StepPreviousButtonImageUrl = "test";
1019                         Assert.AreEqual ("test", wizard.StepPreviousButtonImageUrl, "StepPreviousButtonImageUrl");
1020                         wizard.StepPreviousButtonStyle.BackColor = Color.Red;
1021                         Assert.AreEqual (Color.Red, wizard.StepPreviousButtonStyle.BackColor, "StepPreviousButtonStyle");
1022                         wizard.StepPreviousButtonText = "test";
1023                         Assert.AreEqual ("test", wizard.StepPreviousButtonText, "StepPreviousButtonText");
1024                         wizard.StepPreviousButtonType = ButtonType.Image;
1025                         Assert.AreEqual (ButtonType.Image, wizard.StepPreviousButtonType, "StepPreviousButtonType");
1026                         wizard.StepStyle.BackColor = Color.Red;
1027                         Assert.AreEqual (Color.Red, wizard.StepStyle.BackColor, "StepStyle");
1028                 }
1029
1030
1031
1032                 [Test]
1033                 public void Wizard_GetHistory ()
1034                 {
1035                         PokerWizard wizard = new PokerWizard ();
1036                         WizardStep step1 = new WizardStep ();
1037                         step1.ID = "step1";
1038                         step1.StepType = WizardStepType.Start;
1039                         WizardStep step2 = new WizardStep ();
1040                         step2.ID = "step2";
1041                         step2.StepType = WizardStepType.Step;
1042                         WizardStep step3 = new WizardStep ();
1043                         step3.ID = "step3";
1044                         step3.StepType = WizardStepType.Finish;
1045                         wizard.WizardSteps.Add (step1);
1046                         wizard.WizardSteps.Add (step2);
1047                         wizard.WizardSteps.Add (step3);
1048                         wizard.ActiveStepIndex = 0;
1049                         wizard.MoveTo (step3);
1050                         object o = wizard.PokerSaveControlState ();
1051                         wizard.PokerLoadControlState (o);
1052                         wizard.MoveTo (step2);
1053                         o = wizard.PokerSaveControlState ();
1054                         wizard.PokerLoadControlState (o);
1055                         wizard.MoveTo (step3);
1056                         o = wizard.PokerSaveControlState ();
1057                         wizard.PokerLoadControlState (o);
1058                         ArrayList collection = (ArrayList) wizard.GetHistory ();
1059                         Assert.AreEqual (3, collection.Count, "GetHistoryCount");
1060                 }
1061
1062                 [Test]
1063                 public void Wizard_GetStepType ()
1064                 {
1065                         PokerWizard wizard = new PokerWizard ();
1066                         WizardStep step1 = new WizardStep ();
1067                         step1.ID = "step1";
1068                         step1.StepType = WizardStepType.Start;
1069                         wizard.WizardSteps.Add (step1);
1070                         wizard.ActiveStepIndex = 0;
1071                         WizardStepType result = wizard.GetStepType (wizard.ActiveStep, wizard.ActiveStepIndex);
1072                         Assert.AreEqual (WizardStepType.Start, result, "GetStepType");
1073                 }
1074
1075                 [Test]
1076                 public void Wizard_MoveTo ()
1077                 {
1078                         PokerWizard wizard = new PokerWizard ();
1079                         WizardStep step1 = new WizardStep ();
1080                         step1.ID = "step1";
1081                         step1.StepType = WizardStepType.Start;
1082                         WizardStep step2 = new WizardStep ();
1083                         step2.ID = "step2";
1084                         step2.StepType = WizardStepType.Step;
1085                         WizardStep step3 = new WizardStep ();
1086                         step3.ID = "step3";
1087                         step3.StepType = WizardStepType.Finish;
1088                         wizard.WizardSteps.Add (step1);
1089                         wizard.WizardSteps.Add (step2);
1090                         wizard.WizardSteps.Add (step3);
1091                         wizard.ActiveStepIndex = 0;
1092                         wizard.MoveTo (step3);
1093                         Assert.AreEqual (2, wizard.ActiveStepIndex, "MoveToStep3");
1094                         wizard.MoveTo (step2);
1095                         Assert.AreEqual (1, wizard.ActiveStepIndex, "MoveToStep2");
1096                         wizard.MoveTo (step1);
1097                         Assert.AreEqual (0, wizard.ActiveStepIndex, "MoveToStep1");
1098                 }
1099
1100
1101                 [Test]
1102                 public void Wizard_AllowNavigationToStep ()
1103                 {
1104                         PokerWizard wizard = new PokerWizard ();
1105                         WizardStep step1 = new WizardStep ();
1106                         step1.ID = "step1";
1107                         step1.StepType = WizardStepType.Start;
1108                         WizardStep step2 = new WizardStep ();
1109                         step2.ID = "step2";
1110                         step2.StepType = WizardStepType.Step;
1111                         WizardStep step3 = new WizardStep ();
1112                         step3.ID = "step3";
1113                         step3.StepType = WizardStepType.Finish;
1114                         wizard.WizardSteps.Add (step1);
1115                         wizard.WizardSteps.Add (step2);
1116                         wizard.WizardSteps.Add (step3);
1117                         wizard.ActiveStepIndex = 0;
1118                         wizard.MoveTo (step3);
1119                         object o = wizard.PokerSaveControlState ();
1120                         wizard.PokerLoadControlState (o);
1121                         bool result = wizard.PokerAllowNavigationToStep (2);
1122                         Assert.AreEqual (true, result, "AllowNavigationToStep#1");
1123                         step3.AllowReturn = false;
1124                         result = wizard.PokerAllowNavigationToStep (2);
1125                         Assert.AreEqual (false, result, "AllowNavigationToStep#2");
1126                 }
1127
1128                 [Test]
1129                 public void Wizard_AllowNavigationToStep_NoIndexCheck ()
1130                 {
1131                         PokerWizard wizard = new PokerWizard ();
1132                         Assert.IsTrue (wizard.PokerAllowNavigationToStep (0), "#A1-1");
1133                         Assert.IsTrue (wizard.PokerAllowNavigationToStep (10), "#A1-2");
1134                         Assert.IsTrue (wizard.PokerAllowNavigationToStep (-10), "#A1-3");
1135                 }
1136
1137                 [Test]
1138                 public void Wizard_CreateControlCollection ()
1139                 {
1140                         PokerWizard wizard = new PokerWizard ();
1141                         ControlCollection collection = wizard.PokerCreateControlCollection ();
1142                         Assert.IsNotNull (collection, "CreateControlCollection");
1143                         Assert.AreEqual (0, collection.Count, "CreateControlCollection#1");
1144                 }
1145
1146                 [Test]
1147                 public void Wizard_CreateControlStyle ()
1148                 {
1149                         PokerWizard wizard = new PokerWizard ();
1150                         Style style = wizard.PokerCreateControlStyle ();
1151                         Assert.AreEqual (typeof (TableStyle), style.GetType (), "CreateControlStyle#1");
1152                         Assert.AreEqual (0, ((TableStyle) style).CellPadding, "CreateControlStyle#2");
1153                         Assert.AreEqual (0, ((TableStyle) style).CellSpacing, "CreateControlStyle#3");
1154                 }
1155
1156                 [Test]
1157                 public void Wizard_ControlState ()
1158                 {
1159                         PokerWizard wizard = new PokerWizard ();
1160                         WizardStep step1 = new WizardStep ();
1161                         step1.ID = "step1";
1162                         step1.StepType = WizardStepType.Start;
1163                         WizardStep step3 = new WizardStep ();
1164                         step3.ID = "step3";
1165                         step3.StepType = WizardStepType.Finish;
1166                         wizard.WizardSteps.Add (step1);
1167                         wizard.WizardSteps.Add (step3);
1168                         wizard.ActiveStepIndex = 0;
1169                         wizard.MoveTo (step3);
1170                         // LAMESPEC: history updated when SaveControlState occured
1171                         Assert.AreEqual (0, ((ArrayList) wizard.GetHistory ()).Count, "ControlState#1");
1172                         object o = wizard.PokerSaveControlState ();
1173                         wizard.PokerLoadControlState (o);
1174                         wizard.MoveTo (step1);
1175                         Assert.AreEqual (0, wizard.ActiveStepIndex, "ControlState#2");
1176                         wizard.PokerLoadControlState (o);
1177                         Assert.AreEqual (1, wizard.ActiveStepIndex, "ControlState#3");
1178                         Assert.AreEqual (1, ((ArrayList) wizard.GetHistory ()).Count, "ControlState#4");
1179                 }
1180
1181                 [Test]
1182                 public void Wizard_ViewState ()
1183                 {
1184                         PokerWizard wizard = new PokerWizard ();
1185                         PokerWizard copy = new PokerWizard ();
1186                         wizard.ControlStyle.BackColor = Color.Red;
1187                         wizard.FinishCompleteButtonStyle.BackColor = Color.Red;
1188                         wizard.FinishPreviousButtonStyle.BackColor = Color.Red;
1189                         wizard.HeaderStyle.BackColor = Color.Red;
1190                         wizard.NavigationButtonStyle.BackColor = Color.Red;
1191                         wizard.NavigationStyle.BackColor = Color.Red;
1192                         wizard.SideBarButtonStyle.BackColor = Color.Red;
1193                         wizard.SideBarStyle.BackColor = Color.Red;
1194                         wizard.StartNextButtonStyle.BackColor = Color.Red;
1195                         wizard.StepPreviousButtonStyle.BackColor = Color.Red;
1196                         wizard.StepNextButtonStyle.BackColor = Color.Red;
1197                         wizard.StepStyle.BackColor = Color.Red;
1198                         object state = wizard.SaveState ();
1199                         copy.LoadState (state);
1200                         Assert.AreEqual (Color.Red, copy.ControlStyle.BackColor, "ViewStateControlStyle");
1201                         Assert.AreEqual (Color.Red, copy.FinishCompleteButtonStyle.BackColor, "ViewStateFinishCompleteButtonStyle");
1202                         Assert.AreEqual (Color.Red, copy.FinishPreviousButtonStyle.BackColor, "ViewStateFinishPreviousButtonStyle");
1203                         Assert.AreEqual (Color.Red, copy.HeaderStyle.BackColor, "ViewStateHeaderStyle");
1204                         Assert.AreEqual (Color.Red, copy.NavigationButtonStyle.BackColor, "ViewStateNavigationButtonStyle");
1205                         Assert.AreEqual (Color.Red, copy.NavigationStyle.BackColor, "ViewStateNavigationStyle");
1206                         Assert.AreEqual (Color.Red, copy.SideBarButtonStyle.BackColor, "ViewStateSideBarButtonStyle");
1207                         Assert.AreEqual (Color.Red, copy.SideBarStyle.BackColor, "ViewStateSideBarStyle");
1208                         Assert.AreEqual (Color.Red, copy.StartNextButtonStyle.BackColor, "ViewStateStartNextButtonStyle");
1209                         Assert.AreEqual (Color.Red, copy.StepNextButtonStyle.BackColor, "ViewStateStepNextButtonStyle");
1210                         Assert.AreEqual (Color.Red, copy.StepStyle.BackColor, "ViewStateStepStyle");
1211                 }
1212
1213                 [Test]
1214                 public void Wizard_Steps ()
1215                 {
1216                         PokerWizard w = new PokerWizard ();
1217                         Assert.AreEqual (-1, w.ActiveStepIndex, "ActiveStepIndex on no steps");
1218
1219                         w.WizardSteps.Add (new WizardStep ());
1220                         Assert.IsNotNull (w.WizardSteps[0].Wizard, "WizardStep.Wizard");
1221                         Assert.AreEqual (WizardStepType.Finish, w.GetStepType (w.WizardSteps[0], 0), "WizardStepType.Finish");
1222                 }
1223
1224                 /// <summary>
1225                 /// EVENTS
1226                 /// </summary>
1227
1228                 [Test]
1229                 public void Wizard_ActiveStepChanged ()
1230                 {
1231                         PokerWizard wizard = new PokerWizard ();
1232                         wizard.ActiveStepChanged += new EventHandler (wizard_handler);
1233                         wizard.DoOnActiveStepChanged (this, new EventArgs ());
1234                         eventassert ("ActiveStepChanged");
1235                 }
1236
1237                 [Test]
1238                 public void Wizard_CancelButtonClick ()
1239                 {
1240                         PokerWizard wizard = new PokerWizard ();
1241                         wizard.CancelButtonClick += new EventHandler (wizard_handler);
1242                         wizard.DoOnCancelButtonClick (new EventArgs ());
1243                         eventassert ("CancelButtonClick");
1244                 }
1245
1246                 [Test]
1247                 public void Wizard_FinishButtonClick ()
1248                 {
1249                         PokerWizard wizard = new PokerWizard ();
1250                         wizard.FinishButtonClick += new WizardNavigationEventHandler (wizard_handler);
1251                         wizard.DoOnFinishButtonClick (new WizardNavigationEventArgs (0, 0));
1252                         eventassert ("FinishButtonClick");
1253                 }
1254
1255                 [Test]
1256                 public void Wizard_NextButtonClick ()
1257                 {
1258                         PokerWizard wizard = new PokerWizard ();
1259                         wizard.NextButtonClick += new WizardNavigationEventHandler (wizard_handler);
1260                         wizard.DoOnNextButtonClick (new WizardNavigationEventArgs (0, 1));
1261                         eventassert ("NextButtonClick");
1262                 }
1263
1264                 [Test]
1265                 public void Wizard_PreviousButtonClick ()
1266                 {
1267                         PokerWizard wizard = new PokerWizard ();
1268                         wizard.PreviousButtonClick += new WizardNavigationEventHandler (wizard_handler);
1269                         wizard.DoOnPreviousButtonClick (new WizardNavigationEventArgs (0, 1));
1270                         eventassert ("PreviousButtonClick");
1271                 }
1272
1273                 [Test]
1274                 public void Wizard_SideBarButtonClick ()
1275                 {
1276                         PokerWizard wizard = new PokerWizard ();
1277                         wizard.SideBarButtonClick += new WizardNavigationEventHandler (wizard_handler);
1278                         wizard.DoOnSideBarButtonClick (new WizardNavigationEventArgs (0, 1));
1279                         eventassert ("SideBarButtonClick");
1280                 }
1281
1282                 public void wizard_handler (object o, EventArgs e)
1283                 {
1284                         _eventchecker = true;
1285                 }
1286
1287                 /// <summary>
1288                 /// Bubble Event
1289                 /// </summary>
1290                 [Test]
1291                 public void Wizard_BubbleEvent_CancelEvent ()
1292                 {
1293                         PokerWizard wizard = new PokerWizard ();
1294                         wizard.CancelButtonClick += new EventHandler (wizard_handler);
1295                         WizardStep step1 = new WizardStep ();
1296                         step1.ID = "step1";
1297                         step1.StepType = WizardStepType.Start;
1298                         WizardStep step3 = new WizardStep ();
1299                         step3.ID = "step3";
1300                         step3.StepType = WizardStepType.Finish;
1301                         wizard.WizardSteps.Add (step1);
1302                         wizard.WizardSteps.Add (step3);
1303                         wizard.ActiveStepIndex = 0;
1304                         CommandEventArgs e = new CommandEventArgs (Wizard.CancelCommandName, null);
1305                         bool result = wizard.DoBubbleEvent (null, e);
1306                         Assert.AreEqual (true, result, "CancelButtonBubbleEventCommand");
1307                         eventassert ("OnCancelButtonClick");
1308                 }
1309
1310                 [Test]
1311                 public void Wizard_BubbleEvent_MoveNext ()
1312                 {
1313                         PokerWizard wizard = new PokerWizard ();
1314                         wizard.NextButtonClick += new WizardNavigationEventHandler (wizard_handler);
1315                         WizardStep step1 = new WizardStep ();
1316                         step1.ID = "step1";
1317                         step1.StepType = WizardStepType.Start;
1318                         WizardStep step2 = new WizardStep ();
1319                         step2.ID = "step2";
1320                         step2.StepType = WizardStepType.Finish;
1321                         wizard.WizardSteps.Add (step1);
1322                         wizard.WizardSteps.Add (step2);
1323                         wizard.ActiveStepIndex = 0;
1324                         CommandEventArgs e = new CommandEventArgs (Wizard.MoveNextCommandName, null);
1325                         bool result = wizard.DoBubbleEvent (null, e);
1326                         Assert.AreEqual (true, result, "MoveNextBubbleEventCommand");
1327                         eventassert ("MoveNextBubbleEvent");
1328                         Assert.AreEqual (1, wizard.ActiveStepIndex, "ActiveStepIndexAfterBubble");
1329                 }
1330
1331                 [Test]
1332                 public void Wizard_BubbleEvent_MovePrevious ()
1333                 {
1334                         PokerWizard wizard = new PokerWizard ();
1335                         wizard.PreviousButtonClick += new WizardNavigationEventHandler (wizard_handler);
1336                         WizardStep step1 = new WizardStep ();
1337                         step1.ID = "step1";
1338                         step1.StepType = WizardStepType.Start;
1339                         WizardStep step2 = new WizardStep ();
1340                         step2.ID = "step2";
1341                         step2.StepType = WizardStepType.Finish;
1342                         wizard.WizardSteps.Add (step1);
1343                         wizard.WizardSteps.Add (step2);
1344                         wizard.ActiveStepIndex = 1;
1345                         CommandEventArgs e = new CommandEventArgs (Wizard.MovePreviousCommandName, null);
1346                         bool result = wizard.DoBubbleEvent (null, e);
1347                         Assert.AreEqual (true, result, "MovePreviousBubbleEventCommand");
1348                         eventassert ("MovePreviousBubbleEvent");
1349                 }
1350
1351                 [Test]
1352                 public void Wizard_BubbleEvent_MoveComplete ()
1353                 {
1354                         PokerWizard wizard = new PokerWizard ();
1355                         wizard.FinishButtonClick += new WizardNavigationEventHandler (wizard_handler);
1356                         WizardStep step1 = new WizardStep ();
1357                         step1.ID = "step1";
1358                         step1.StepType = WizardStepType.Start;
1359                         WizardStep step2 = new WizardStep ();
1360                         step2.ID = "step2";
1361                         step2.StepType = WizardStepType.Finish;
1362                         WizardStep step3 = new WizardStep ();
1363                         step3.ID = "step2";
1364                         step3.StepType = WizardStepType.Complete;
1365                         wizard.WizardSteps.Add (step1);
1366                         wizard.WizardSteps.Add (step2);
1367                         wizard.WizardSteps.Add (step3);
1368                         wizard.ActiveStepIndex = 1;
1369                         CommandEventArgs e = new CommandEventArgs (Wizard.MoveCompleteCommandName, null);
1370                         bool result = wizard.DoBubbleEvent (null, e);
1371                         Assert.AreEqual (true, result, "MoveCompleteEventCommand");
1372                         eventassert ("MoveCompleteBubbleEvent");
1373                 }
1374
1375                 [Test]
1376                 public void Wizard_BubbleEvent_MoveTo ()
1377                 {
1378                         PokerWizard wizard = new PokerWizard ();
1379                         WizardStep step1 = new WizardStep ();
1380                         step1.ID = "step1";
1381                         step1.StepType = WizardStepType.Start;
1382                         WizardStep step2 = new WizardStep ();
1383                         step2.ID = "step2";
1384                         step2.StepType = WizardStepType.Finish;
1385                         wizard.WizardSteps.Add (step1);
1386                         wizard.WizardSteps.Add (step2);
1387                         wizard.ActiveStepIndex = 0;
1388                         CommandEventArgs e = new CommandEventArgs (Wizard.MoveToCommandName, "1");
1389                         bool result = wizard.DoBubbleEvent (null, e);
1390                         Assert.AreEqual (true, result, "MoveToEventCommand");
1391                         Assert.AreEqual (1, wizard.ActiveStepIndex, "ActiveStepIndexAfterMoveToBubble");
1392                 }
1393
1394
1395
1396                 /// <summary>
1397                 /// Rendering
1398                 /// </summary>
1399
1400                 [Test]
1401                 [Category ("NunitWeb")]
1402                 public void Wizard_RenderTest ()
1403                 {
1404                         string html = new WebTest (PageInvoker.CreateOnPreInit (
1405                                 new PageDelegate (WizardPreInit))).Run ();
1406                         string origHtml = "<table cellspacing=\"0\" cellpadding=\"0\" style=\"border-collapse:collapse;\">\r\n\t<tr style=\"height:100%;\">\r\n\t\t<td>123</td>\r\n\t</tr><tr>\r\n\t\t<td align=\"right\"><table cellspacing=\"5\" cellpadding=\"5\">\r\n\t\t\t<tr>\r\n\t\t\t\t<td align=\"right\"><input type=\"submit\" name=\"ctl00$FinishNavigationTemplateContainerID$FinishButton\" value=\"Finish\" id=\"ctl00_FinishNavigationTemplateContainerID_FinishButton\" /></td>\r\n\t\t\t</tr>\r\n\t\t</table></td>\r\n\t</tr>\r\n</table>";
1407                         string renderedHtml = HtmlDiff.GetControlFromPageHtml (html);
1408                         HtmlDiff.AssertAreEqual (origHtml, renderedHtml, "BaseRender");
1409                 }
1410
1411                 public static void WizardPreInit (Page p)
1412                 {
1413                         LiteralControl lcb = new LiteralControl (HtmlDiff.BEGIN_TAG);
1414                         LiteralControl lce = new LiteralControl (HtmlDiff.END_TAG);
1415
1416                         Wizard w = new Wizard ();
1417                         WizardStep ws = new WizardStep ();
1418                         ws.Controls.Add (new LiteralControl ("123"));
1419                         try {
1420                                 w.SkipLinkText = "";
1421                         }
1422                         catch (Exception) { }
1423                         w.DisplaySideBar = false;
1424                         w.WizardSteps.Add (ws);
1425                         p.Controls.Add (lcb);
1426                         p.Controls.Add (w);
1427                         p.Controls.Add (lce);
1428                 }
1429
1430                 [Test]
1431                 [Category ("NunitWeb")]
1432                 public void Wizard_RenderTestStartItem ()
1433                 {
1434                         WebTest t = new WebTest (PageInvoker.CreateOnPreInit (_renderingWizard));
1435                         t.UserData = 0; // Active Index
1436                         string result = t.Run ();
1437                         if (result.IndexOf ("Start") < 0)
1438                                 Assert.Fail ("StartItemRendering");
1439                         if (result.IndexOf ("Next") < 0)
1440                                 Assert.Fail ("NextButtonNotCreated");
1441                         Assert.AreEqual (-1, result.IndexOf ("Previous"), "PreviousButtonCreatedOnFirstPage");
1442                 }
1443
1444                 [Test]
1445                 [Category ("NunitWeb")]
1446                 public void Wizard_RenderTestStepItem ()
1447                 {
1448                         WebTest t = new WebTest (PageInvoker.CreateOnPreInit (_renderingWizard));
1449                         t.UserData = 1; // Active Index
1450                         string result = t.Run ();
1451                         if (result.IndexOf ("Step") < 0)
1452                                 Assert.Fail ("StepItemRendering");
1453                         if (result.IndexOf ("Next") < 0)
1454                                 Assert.Fail ("NextButtonNotCreated");
1455                         if (result.IndexOf ("Previous") < 0)
1456                                 Assert.Fail ("PreviousButtonNotCreated");
1457                 }
1458
1459                 [Test]
1460                 [Category ("NunitWeb")]
1461                 public void Wizard_RenderTestAutoItem ()
1462                 {
1463                         WebTest t = new WebTest (PageInvoker.CreateOnPreInit (_renderingWizard));
1464                         t.UserData = 2; // Active Index
1465                         string result = t.Run ();
1466                         if (result.IndexOf ("Auto") < 0)
1467                                 Assert.Fail ("AutoItemRendering");
1468                         if (result.IndexOf ("Next") < 0)
1469                                 Assert.Fail ("NextButtonNotCreated");
1470                         if (result.IndexOf ("Previous") < 0)
1471                                 Assert.Fail ("PreviousButtonNotCreated");
1472                 }
1473
1474                 [Test]
1475                 [Category ("NunitWeb")]
1476                 public void Wizard_RenderTestFinishItem ()
1477                 {
1478                         WebTest t = new WebTest (PageInvoker.CreateOnPreInit (_renderingWizard));
1479                         t.UserData = 3; // Active Index
1480                         string result = t.Run ();
1481                         if (result.IndexOf ("FinishText") < 0)
1482                                 Assert.Fail ("FinishItemRendering");
1483                         if (result.IndexOf ("Previous") < 0)
1484                                 Assert.Fail ("NextButtonNotCreated");
1485                         if (result.IndexOf ("Finish") < 0)
1486                                 Assert.Fail ("FinishButtonNotCreated");
1487                         Assert.AreEqual (-1, result.IndexOf ("Next"), "NextButtonCreatedOnLastPage");
1488                 }
1489                 [Test]
1490                 public void Wizard_LayoutTemplate ()
1491                 {
1492                         var w = new Wizard ();
1493
1494                         Assert.IsNull (w.LayoutTemplate, "#A1");
1495                 }
1496
1497                 [Test]
1498                 public void Wizard_LayoutTemplate_Empty ()
1499                 {
1500                         WebTest t = new WebTest (PageInvoker.CreateOnInit (LayoutTemplateRender));
1501                         t.UserData = "Empty";
1502                         string result;
1503
1504                         AssertExtensions.Throws<InvalidOperationException> (() => {
1505                                 result = t.Run ();
1506                         }, "#A1");
1507                 }
1508
1509                 [Test]
1510                 public void Wizard_LayoutTemplate_OptionalSideBar ()
1511                 {
1512                         WebTest t = new WebTest (PageInvoker.CreateOnInit (LayoutTemplateRender));
1513                         t.UserData = "OptionalSideBar_NoSideBar";
1514                         string result = t.Run ();
1515                         string renderedHtml = HtmlDiff.GetControlFromPageHtml (result);
1516
1517                         Assert.AreEqual (String.Empty, renderedHtml, "#A1");
1518
1519                         t.UserData = "OptionalSideBar_WithSideBar";
1520                         AssertExtensions.Throws<InvalidOperationException> (() => {
1521                                 result = t.Run ();
1522                         }, "#A2");
1523                 }
1524
1525                 [Test]
1526                 public void Wizard_LayoutTemplate_RenderSideBar ()
1527                 {
1528                         WebTest t = new WebTest (PageInvoker.CreateOnInit (LayoutTemplateRender));
1529                         t.UserData = "RenderSideBar";
1530                         string result = t.Run ();
1531 #if DOT_NET
1532                         string origHtml = "<table id=\"MyWizard_SideBarList\" cellspacing=\"0\" style=\"border-collapse:collapse;\">\r\n\t<tr>\r\n\t\t<td style=\"font-weight:bold;\"><a id=\"MyWizard_SideBarList_SideBarButton_0\" href=\"javascript:__doPostBack(&#39;MyWizard$SideBarList$ctl00$SideBarButton&#39;,&#39;&#39;)\">step1</a></td>\r\n\t</tr>\r\n</table><table cellspacing=\"5\" cellpadding=\"5\">\r\n\t<tr>\r\n\t\t<td align=\"right\"><input type=\"submit\" name=\"MyWizard$StepNavigationTemplateContainerID$StepPreviousButton\" value=\"Previous\" id=\"MyWizard_StepNavigationTemplateContainerID_StepPreviousButton\" /></td><td align=\"right\"><input type=\"submit\" name=\"MyWizard$StepNavigationTemplateContainerID$StepNextButton\" value=\"Next\" id=\"MyWizard_StepNavigationTemplateContainerID_StepNextButton\" /></td>\r\n\t</tr>\r\n</table>Step";
1533 #else
1534                         string origHtml = "<table id=\"MyWizard_SideBarList\" cellspacing=\"0\" style=\"border-collapse:collapse;\">\r\n\t<tr>\r\n\t\t<td style=\"font-weight:bold;\"><a id=\"MyWizard_SideBarList_ctl00_SideBarButton_0\" href=\"javascript:__doPostBack(&#39;MyWizard$SideBarList$ctl00$SideBarButton&#39;,&#39;&#39;)\">step1</a></td>\n\t</tr>\n</table><table cellspacing=\"5\" cellpadding=\"5\">\r\n\t<tr>\r\n\t\t<td align=\"right\"><input type=\"submit\" name=\"MyWizard$StepNavigationTemplateContainerID$StepPreviousButton\" value=\"Previous\" id=\"MyWizard_StepNavigationTemplateContainerID_StepPreviousButton\" /></td><td align=\"right\"><input type=\"submit\" name=\"MyWizard$StepNavigationTemplateContainerID$StepNextButton\" value=\"Next\" id=\"MyWizard_StepNavigationTemplateContainerID_StepNextButton\" /></td>\n\t</tr>\n</table>Step";
1535 #endif
1536                         string renderedHtml = HtmlDiff.GetControlFromPageHtml (result);
1537                         Console.WriteLine (origHtml);
1538                         Console.WriteLine ("----------------------------");
1539                         Console.WriteLine (renderedHtml);
1540                         
1541                         Assert.AreEqual (origHtml.Replace ("\r", ""), renderedHtml.Replace ("\r", ""), "#A1");
1542                 }
1543
1544                 [Test]
1545                 public void Wizard_LayoutTemplate_OptionalHeader ()
1546                 {
1547                         WebTest t = new WebTest (PageInvoker.CreateOnInit (LayoutTemplateRender));
1548                         t.UserData = "OptionalHeader_NoHeaderTemplate";
1549                         string result = t.Run ();
1550                         string renderedHtml = HtmlDiff.GetControlFromPageHtml (result);
1551
1552                         Assert.AreEqual (String.Empty, renderedHtml, "#A1");
1553
1554                         t.UserData = "OptionalHeader_WithHeaderTemplate";
1555                         AssertExtensions.Throws<InvalidOperationException> (() => {
1556                                 result = t.Run ();
1557                         }, "#A2");
1558                 }
1559
1560                 [Test]
1561                 public void Wizard_LayoutTemplate_RenderHeader ()
1562                 {
1563                         WebTest t = new WebTest (PageInvoker.CreateOnInit (LayoutTemplateRender));
1564                         t.UserData = "RenderHeader";
1565                         string result = t.Run ();
1566                         string origHtml = "Header<table cellspacing=\"5\" cellpadding=\"5\">\r\n\t<tr>\r\n\t\t<td align=\"right\"><input type=\"submit\" name=\"MyWizard$StepNavigationTemplateContainerID$StepPreviousButton\" value=\"Previous\" id=\"MyWizard_StepNavigationTemplateContainerID_StepPreviousButton\" /></td><td align=\"right\"><input type=\"submit\" name=\"MyWizard$StepNavigationTemplateContainerID$StepNextButton\" value=\"Next\" id=\"MyWizard_StepNavigationTemplateContainerID_StepNextButton\" /></td>\n\t</tr>\n</table>Step";
1567                         string renderedHtml = HtmlDiff.GetControlFromPageHtml (result);
1568
1569                         Assert.AreEqual (origHtml.Replace ("\r", ""), renderedHtml.Replace ("\r", ""), "#A1");
1570
1571                         t.UserData = "RenderHeader_InSpan";
1572                         result = t.Run ();
1573                         origHtml = "Header<table cellspacing=\"5\" cellpadding=\"5\">\r\n\t<tr>\r\n\t\t<td align=\"right\"><input type=\"submit\" name=\"MyWizard$StepNavigationTemplateContainerID$StepPreviousButton\" value=\"Previous\" id=\"MyWizard_StepNavigationTemplateContainerID_StepPreviousButton\" /></td><td align=\"right\"><input type=\"submit\" name=\"MyWizard$StepNavigationTemplateContainerID$StepNextButton\" value=\"Next\" id=\"MyWizard_StepNavigationTemplateContainerID_StepNextButton\" /></td>\n\t</tr>\n</table>Step";
1574                         renderedHtml = HtmlDiff.GetControlFromPageHtml (result);
1575                         Assert.AreEqual (origHtml.Replace ("\r", ""), renderedHtml.Replace ("\r", ""), "#A2");
1576                 }
1577
1578                 [Test]
1579                 public void Wizard_LayoutTemplate_StepPlaceHolder ()
1580                 {
1581                         WebTest t = new WebTest (PageInvoker.CreateOnInit (LayoutTemplateRender));
1582                         t.UserData = "StepPlaceHolder";
1583                         AssertExtensions.Throws<InvalidOperationException> (() => {
1584                                 string result = t.Run ();
1585                         }, "#A1");
1586                 }
1587
1588                 [Test]
1589                 public void Wizard_LayoutTemplate_NavigationPlaceHolder ()
1590                 {
1591                         WebTest t = new WebTest (PageInvoker.CreateOnInit (LayoutTemplateRender));
1592                         t.UserData = "NavigationPlaceHolder";
1593                         AssertExtensions.Throws<InvalidOperationException> (() => {
1594                                 string result = t.Run ();
1595                         }, "#A1");
1596                 }
1597
1598                 public static void LayoutTemplateRender (Page p)
1599                 {
1600                         var w = new Wizard ();
1601                         w.ID = "MyWizard";
1602                         WebTest curTest = WebTest.CurrentTest;
1603                         string id = (string)curTest.UserData;
1604
1605                         switch (id) {
1606                                 case "Empty":
1607                                         w.LayoutTemplate = new TestLayoutTemplate ();
1608                                         break;
1609
1610                                 case "OptionalSideBar_NoSideBar":
1611                                         w.LayoutTemplate = new TestLayoutTemplate {
1612                                                 HasHeaderPlaceHolder = true,
1613                                                 HasNavigationPlaceHolder = true,
1614                                                 HasWizardStepPlaceHolder = true
1615                                         };
1616                                         w.DisplaySideBar = false;
1617                                         break;
1618
1619                                 case "OptionalSideBar_WithSideBar":
1620                                         w.LayoutTemplate = new TestLayoutTemplate {
1621                                                 HasHeaderPlaceHolder = true,
1622                                                 HasNavigationPlaceHolder = true,
1623                                                 HasWizardStepPlaceHolder = true
1624                                         };
1625                                         w.DisplaySideBar = true;
1626                                         break;
1627
1628                                 case "RenderSideBar":
1629                                         w.LayoutTemplate = new TestLayoutTemplate {
1630                                                 HasHeaderPlaceHolder = true,
1631                                                 HasNavigationPlaceHolder = true,
1632                                                 HasWizardStepPlaceHolder = true,
1633                                                 HasSideBarPlaceHolder = true
1634                                         };
1635                                         AddWizardStep (w, "Step", "step1");
1636                                         break;
1637
1638                                 case "OptionalHeader_NoHeaderTemplate":
1639                                         w.LayoutTemplate = new TestLayoutTemplate {
1640                                                 HasNavigationPlaceHolder = true,
1641                                                 HasWizardStepPlaceHolder = true
1642                                         };
1643                                         w.DisplaySideBar = false;
1644                                         break;
1645
1646                                 case "OptionalHeader_WithHeaderTemplate":
1647                                         w.LayoutTemplate = new TestLayoutTemplate {
1648                                                 HasNavigationPlaceHolder = true,
1649                                                 HasWizardStepPlaceHolder = true
1650                                         };
1651                                         w.HeaderTemplate = new TestHeaderTemplate ();
1652                                         w.DisplaySideBar = false;
1653                                         break;
1654
1655                                 case "RenderHeader":
1656                                         w.LayoutTemplate = new TestLayoutTemplate {
1657                                                 HasNavigationPlaceHolder = true,
1658                                                 HasWizardStepPlaceHolder = true,
1659                                                 HasHeaderPlaceHolder = true
1660                                         };
1661                                         w.HeaderTemplate = new TestHeaderTemplate ();
1662                                         w.DisplaySideBar = false;
1663                                         AddWizardStep (w, "Step", "step1");
1664                                         break;
1665
1666                                 case "RenderHeader_InSpan":
1667                                         w.LayoutTemplate = new TestLayoutTemplate {
1668                                                 HasNavigationPlaceHolder = true,
1669                                                 HasWizardStepPlaceHolder = true,
1670                                                 HasHeaderPlaceHolder = true,
1671                                                 HeaderPlaceHolderType = typeof (TestHeaderSpan)
1672                                         };
1673                                         w.HeaderTemplate = new TestHeaderTemplate ();
1674                                         w.DisplaySideBar = false;
1675                                         AddWizardStep (w, "Step", "step1");
1676                                         break;
1677
1678                                 case "StepPlaceHolder":
1679                                         w.LayoutTemplate = new TestLayoutTemplate {
1680                                                 HasNavigationPlaceHolder = true,
1681                                         };
1682                                         w.DisplaySideBar = false;
1683                                         break;
1684
1685                                 case "NavigationPlaceHolder":
1686                                         w.LayoutTemplate = new TestLayoutTemplate {
1687                                                 HasWizardStepPlaceHolder = true,
1688                                         };
1689                                         w.DisplaySideBar = false;
1690                                         break;
1691
1692                                 default:
1693                                         throw new InvalidOperationException ("Unknown id '" + id + "'");
1694                         }
1695
1696                         p.Form.Controls.Add (new LiteralControl (HtmlDiff.BEGIN_TAG));
1697                         p.Form.Controls.Add (w);
1698                         p.Form.Controls.Add (new LiteralControl (HtmlDiff.END_TAG));
1699                 }
1700
1701                 static void AddWizardStep (Wizard w, string stepText, string stepID, WizardStepType type = WizardStepType.Step)
1702                 {
1703                         var ws = new WizardStep ();
1704                         ws.ID = stepID;
1705                         ws.StepType = type;
1706                         ws.Controls.Add (new LiteralControl (stepText));
1707
1708                         w.WizardSteps.Add (ws);
1709                 }
1710                 [Test]
1711                 [Category ("NunitWeb")]
1712                 public void Wizard_RenderTestCompleteItem ()
1713                 {
1714                         WebTest t = new WebTest (PageInvoker.CreateOnPreInit (_renderingWizard));
1715                         t.UserData = 4; // Active Index
1716                         string result = t.Run ();
1717                         if (result.IndexOf ("Complete") < 0)
1718                                 Assert.Fail ("FinishItemRendering");
1719                         Assert.AreEqual (-1, result.IndexOf ("Previous"), "PreviousButtonCreatedOnLastPage");
1720                         Assert.AreEqual (-1, result.IndexOf ("Finish"), "FinishButtonCreatedOnLastPage");
1721                         Assert.AreEqual (-1, result.IndexOf ("Next"), "NextButtonCreatedOnLastPage");
1722                 }
1723
1724                 public static void _renderingWizard (Page p)
1725                 {
1726                         Wizard w = new Wizard ();
1727                         w.ID = "Wizard";
1728
1729                         WizardStep ws = new WizardStep ();
1730                         ws.ID = "step";
1731                         ws.StepType = WizardStepType.Start;
1732                         ws.Controls.Add (new LiteralControl ("Start"));
1733
1734                         WizardStep ws1 = new WizardStep ();
1735                         ws1.ID = "step1";
1736                         ws1.StepType = WizardStepType.Step;
1737                         ws1.Controls.Add (new LiteralControl ("Step"));
1738
1739                         WizardStep ws2 = new WizardStep ();
1740                         ws2.ID = "step2";
1741                         ws2.StepType = WizardStepType.Auto;
1742                         ws2.Controls.Add (new LiteralControl ("Auto"));
1743
1744                         WizardStep ws3 = new WizardStep ();
1745                         ws3.ID = "step3";
1746                         ws3.StepType = WizardStepType.Finish;
1747                         ws3.Controls.Add (new LiteralControl ("FinishText"));
1748
1749                         WizardStep ws4 = new WizardStep ();
1750                         ws4.ID = "step4";
1751                         ws4.StepType = WizardStepType.Complete;
1752                         ws4.Controls.Add (new LiteralControl ("Complete"));
1753
1754                         w.DisplaySideBar = false;
1755                         w.WizardSteps.Add (ws);
1756                         w.WizardSteps.Add (ws1);
1757                         w.WizardSteps.Add (ws2);
1758                         w.WizardSteps.Add (ws3);
1759                         w.WizardSteps.Add (ws4);
1760                         w.ActiveStepIndex = (int) WebTest.CurrentTest.UserData;
1761
1762                         p.Controls.Add (w);
1763                 }
1764
1765                 [Test]
1766                 [Category ("NunitWeb")]
1767                 public void Wizard_PostBackFireEvents_1 ()
1768                 {
1769                         WebTest t = new WebTest ();
1770                         PageDelegates pd = new PageDelegates ();
1771                         pd.PreInit = _postbackEvents;
1772                         t.Invoker = new PageInvoker (pd);
1773                         string html = t.Run ();
1774                         FormRequest fr = new FormRequest (t.Response, "form1");
1775
1776                         //Cancel
1777                         fr.Controls.Add ("__EVENTTARGET");
1778                         fr.Controls.Add ("__EVENTARGUMENT");
1779                         fr.Controls.Add ("Wizard1$StartNavigationTemplateContainerID$CancelButton");
1780                         fr.Controls ["__EVENTTARGET"].Value = "";
1781                         fr.Controls ["__EVENTARGUMENT"].Value = "";
1782                         fr.Controls ["Wizard1$StartNavigationTemplateContainerID$CancelButton"].Value = "Cancel";
1783
1784                         t.Request = fr;
1785                         html = t.Run ();
1786                         Assert.AreEqual ("CancelButtonClick", t.UserData.ToString (), "Cancel");
1787                         
1788                         // Next
1789                         fr.Controls.Add ("__EVENTTARGET");
1790                         fr.Controls.Add ("__EVENTARGUMENT");
1791                         fr.Controls.Add ("Wizard1$StartNavigationTemplateContainerID$StartNextButton");
1792                         fr.Controls["__EVENTTARGET"].Value = "";
1793                         fr.Controls["__EVENTARGUMENT"].Value = "";
1794                         fr.Controls["Wizard1$StartNavigationTemplateContainerID$StartNextButton"].Value = "Next";
1795
1796                         t.Request = fr;
1797                         html = t.Run ();
1798                         Assert.AreEqual ("NextButtonClick", t.UserData.ToString (), "Next");
1799
1800                         // Previous
1801                         fr = new FormRequest (t.Response, "form1");
1802                         fr.Controls.Add ("__EVENTTARGET");
1803                         fr.Controls.Add ("__EVENTARGUMENT");
1804                         fr.Controls.Add ("Wizard1$FinishNavigationTemplateContainerID$FinishPreviousButton");
1805
1806                         fr.Controls["__EVENTTARGET"].Value = "";
1807                         fr.Controls["__EVENTARGUMENT"].Value = "";
1808                         fr.Controls["Wizard1$FinishNavigationTemplateContainerID$FinishPreviousButton"].Value = "Previous";
1809
1810                         t.Request = fr;
1811                         html = t.Run ();
1812                         Assert.AreEqual ("PreviousButtonClick", t.UserData.ToString (), "Previous");
1813                         
1814                 }
1815
1816                 [Test]
1817                 [Category ("NunitWeb")]
1818                 public void Wizard_PostBackFireEvents_2 ()
1819                 {
1820                         WebTest t = new WebTest ();
1821                         PageDelegates pd = new PageDelegates ();
1822                         pd.PreInit = _postbackEvents;
1823                         t.Invoker = new PageInvoker (pd);
1824                         string html = t.Run ();
1825                         FormRequest fr = new FormRequest (t.Response, "form1");
1826
1827                         // Next
1828                         fr.Controls.Add ("__EVENTTARGET");
1829                         fr.Controls.Add ("__EVENTARGUMENT");
1830                         fr.Controls.Add ("Wizard1$StartNavigationTemplateContainerID$StartNextButton");
1831                         fr.Controls["__EVENTTARGET"].Value = "";
1832                         fr.Controls["__EVENTARGUMENT"].Value = "";
1833                         fr.Controls["Wizard1$StartNavigationTemplateContainerID$StartNextButton"].Value = "Next";
1834                         t.Request = fr;
1835                         html = t.Run ();
1836                         Assert.AreEqual ("NextButtonClick", t.UserData.ToString (), "Next");
1837
1838                         // Finish
1839                         fr = new FormRequest (t.Response, "form1");
1840                         fr.Controls.Add ("__EVENTTARGET");
1841                         fr.Controls.Add ("__EVENTARGUMENT");
1842                         fr.Controls.Add ("Wizard1$FinishNavigationTemplateContainerID$FinishButton");
1843                         fr.Controls["__EVENTTARGET"].Value = "";
1844                         fr.Controls["__EVENTARGUMENT"].Value = "";
1845                         fr.Controls["Wizard1$FinishNavigationTemplateContainerID$FinishButton"].Value = "Finish";
1846                         t.Request = fr;
1847                         t.Run ();
1848                         Assert.AreEqual ("FinishButtonClick", t.UserData.ToString (), "Finish");
1849
1850                 }
1851                 
1852                 [Test]
1853                 [Category ("NunitWeb")]
1854                 public void Wizard_PostBackFireEvents_3 ()
1855                 {
1856                         WebTest t = new WebTest ();
1857                         PageDelegates pd = new PageDelegates ();
1858                         pd.PreInit = _postbackEvents;
1859                         t.Invoker = new PageInvoker (pd);
1860                         string html = t.Run ();
1861                         FormRequest fr = new FormRequest (t.Response, "form1");
1862
1863                         //SideBarButton
1864                         fr = new FormRequest (t.Response, "form1");
1865                         fr.Controls.Add ("__EVENTTARGET");
1866                         fr.Controls.Add ("__EVENTARGUMENT");
1867
1868                         fr.Controls ["__EVENTTARGET"].Value = "Wizard1$SideBarContainer$SideBarList$ctl01$SideBarButton";
1869                         fr.Controls ["__EVENTARGUMENT"].Value = "";
1870                         t.Request = fr;
1871                         html = t.Run ();
1872                         Assert.AreEqual ("SideBarButtonClick", t.UserData.ToString (), "SideBarButton");
1873                 }
1874                 
1875                 public static void _postbackEvents (Page p)
1876                 {
1877                         p.EnableEventValidation = false;
1878                         Wizard w = new Wizard ();
1879                         w.DisplayCancelButton = true;
1880                         w.DisplaySideBar = true;
1881                         
1882                         w.CancelButtonClick += new EventHandler (w_CancelButtonClick);
1883                         w.FinishButtonClick += new WizardNavigationEventHandler (w_FinishButtonClick);
1884                         w.NextButtonClick += new WizardNavigationEventHandler (w_NextButtonClick);
1885                         w.PreviousButtonClick += new WizardNavigationEventHandler (w_PreviousButtonClick);
1886                         w.SideBarButtonClick += new WizardNavigationEventHandler (w_SideBarButtonClick);
1887                         w.ID = "Wizard1";
1888
1889                         WizardStep ws = new WizardStep ();
1890                         ws.ID = "step";
1891                         ws.StepType = WizardStepType.Start;
1892                         ws.Controls.Add (new LiteralControl ("StartType"));
1893
1894                         WizardStep ws2 = new WizardStep ();
1895                         ws2.ID = "step2";
1896                         ws2.StepType = WizardStepType.Finish;
1897                         ws2.Controls.Add (new LiteralControl ("FinishType"));
1898
1899                         WizardStep ws3 = new WizardStep ();
1900                         ws3.ID = "step3";
1901                         ws3.StepType = WizardStepType.Complete;
1902                         ws3.Controls.Add (new LiteralControl ("CompleteType"));
1903
1904                         w.DisplaySideBar = true;
1905                         w.WizardSteps.Add (ws);
1906                         w.WizardSteps.Add (ws2);
1907                         w.WizardSteps.Add (ws3);
1908                         p.Controls.Add (w);
1909                 }
1910
1911                 static void w_SideBarButtonClick (object sender, WizardNavigationEventArgs e)
1912                 {
1913                         WebTest.CurrentTest.UserData = "SideBarButtonClick";
1914                 }
1915
1916                 static void w_PreviousButtonClick (object sender, WizardNavigationEventArgs e)
1917                 {
1918                         WebTest.CurrentTest.UserData = "PreviousButtonClick";
1919                 }
1920
1921                 static void w_NextButtonClick (object sender, WizardNavigationEventArgs e)
1922                 {
1923                         WebTest.CurrentTest.UserData = "NextButtonClick";
1924                 }
1925
1926                 static void w_FinishButtonClick (object sender, WizardNavigationEventArgs e)
1927                 {
1928                         WebTest.CurrentTest.UserData = "FinishButtonClick";
1929                 }
1930
1931                 static void w_CancelButtonClick (object sender, EventArgs e)
1932                 {
1933                         WebTest.CurrentTest.UserData = "CancelButtonClick";
1934                 }
1935
1936                 [Test]
1937                 [Category ("NunitWeb")]
1938                 public void Wizard_PostBack()
1939                 {
1940                         WebTest t = new WebTest ();
1941                         PageDelegates pd = new PageDelegates ();
1942                         pd.PreInit = _postback;
1943                         pd.PreRenderComplete = _readControl;
1944                         t.Invoker = new PageInvoker (pd);
1945                         string result = t.Run ();
1946                         if (result.IndexOf ("Start") < 0)
1947                                 Assert.Fail ("Rendering fault");
1948
1949                         ArrayList list =  t.UserData as ArrayList;
1950                         Assert.IsNotNull (list, "PostBackDataNotCreated");
1951                         
1952                         FormRequest fr = new FormRequest (t.Response, "form1");
1953                         fr.Controls.Add ("__EVENTTARGET");
1954                         fr.Controls.Add ("__EVENTARGUMENT");
1955
1956                         fr.Controls["__EVENTTARGET"].Value = list[1].ToString();
1957                         fr.Controls["__EVENTARGUMENT"].Value = "";
1958                         
1959                         t.Request = fr;
1960                         result = t.Run ();
1961                         if (result.IndexOf ("StepType") < 0)
1962                                 Assert.Fail ("MovedToStep1");
1963
1964                         fr = new FormRequest (t.Response, "form1");
1965                         fr.Controls.Add ("__EVENTTARGET");
1966                         fr.Controls.Add ("__EVENTARGUMENT");
1967
1968                         fr.Controls["__EVENTTARGET"].Value = list[2].ToString ();
1969                         fr.Controls["__EVENTARGUMENT"].Value = "";
1970
1971                         t.Request = fr;
1972                         result = t.Run ();
1973                         if (result.IndexOf ("AutoType") < 0)
1974                                 Assert.Fail ("MovedToStep2");
1975
1976                         fr = new FormRequest (t.Response, "form1");
1977                         fr.Controls.Add ("__EVENTTARGET");
1978                         fr.Controls.Add ("__EVENTARGUMENT");
1979
1980                         fr.Controls["__EVENTTARGET"].Value = list[3].ToString ();
1981                         fr.Controls["__EVENTARGUMENT"].Value = "";
1982
1983                         t.Request = fr;
1984                         result = t.Run ();
1985                         if (result.IndexOf ("FinishType") < 0)
1986                                 Assert.Fail ("MovedToStep3");
1987
1988                         fr = new FormRequest (t.Response, "form1");
1989                         fr.Controls.Add ("__EVENTTARGET");
1990                         fr.Controls.Add ("__EVENTARGUMENT");
1991
1992                         fr.Controls["__EVENTTARGET"].Value = list[4].ToString ();
1993                         fr.Controls["__EVENTARGUMENT"].Value = "";
1994
1995                         t.Request = fr;
1996                         result = t.Run ();
1997                         if (result.IndexOf ("CompleteType") < 0)
1998                                 Assert.Fail ("MovedToStep4");
1999                 }
2000
2001                 public static void _postback (Page p)
2002                 {
2003                         p.EnableEventValidation = false;
2004                         Wizard w = new Wizard ();
2005                         w.ID = "Wizard";
2006                         
2007                         WizardStep ws = new WizardStep ();
2008                         ws.ID = "step";
2009                         ws.StepType = WizardStepType.Start;
2010                         ws.Controls.Add (new LiteralControl ("StartType"));
2011
2012                         WizardStep ws1 = new WizardStep ();
2013                         ws1.ID = "step1";
2014                         ws1.StepType = WizardStepType.Step;
2015                         ws1.Controls.Add (new LiteralControl ("StepType"));
2016
2017                         WizardStep ws2 = new WizardStep ();
2018                         ws2.ID = "step2";
2019                         ws2.StepType = WizardStepType.Auto;
2020                         ws2.Controls.Add (new LiteralControl ("AutoType"));
2021
2022                         WizardStep ws3 = new WizardStep ();
2023                         ws3.ID = "step3";
2024                         ws3.StepType = WizardStepType.Finish;
2025                         ws3.Controls.Add (new LiteralControl ("FinishType"));
2026
2027                         WizardStep ws4 = new WizardStep ();
2028                         ws4.ID = "step4";
2029                         ws4.StepType = WizardStepType.Complete;
2030                         ws4.Controls.Add (new LiteralControl ("CompleteType"));
2031
2032                         w.DisplaySideBar = true;
2033                         w.WizardSteps.Add (ws);
2034                         w.WizardSteps.Add (ws1);
2035                         w.WizardSteps.Add (ws2);
2036                         w.WizardSteps.Add (ws3);
2037                         w.WizardSteps.Add (ws4);
2038
2039                         p.Controls.Add (w);
2040                 }
2041
2042                 public static void _readControl (Page p)
2043                 {
2044                         ArrayList list = new ArrayList();
2045                         recurcivefind (list, typeof (LinkButton), p.FindControl ("Wizard"));
2046                         WebTest.CurrentTest.UserData = list;
2047                 }
2048
2049                 public static void recurcivefind (ArrayList list, Type t, Control control )
2050                 {
2051                         foreach (Control c in control.Controls)
2052                         {
2053                                 if (c == null)
2054                                         continue;
2055                                 if (t == c.GetType ()) {
2056                                         list.Add (c.UniqueID);
2057                                 }
2058                                 recurcivefind (list, t, c);
2059                         }
2060                 }
2061
2062
2063                 /// <summary>
2064                 /// Exceptions
2065                 /// </summary>
2066
2067                 [Test]
2068                 [ExpectedException (typeof (InvalidCastException))]
2069                 public void Wizard_ViewStateException ()
2070                 {
2071                         PokerWizard wizard = new PokerWizard ();
2072                         wizard.LoadState (new object ());
2073                 }
2074
2075                 [Test]
2076                 [ExpectedException (typeof (InvalidOperationException))]
2077                 public void Wizard_ActiveStepException1 ()
2078                 {
2079                         Wizard wizard = new Wizard ();
2080                         wizard.ActiveStepIndex = 1;
2081                         WizardStepBase step = wizard.ActiveStep;
2082                 }
2083
2084                 [Test]
2085                 [ExpectedException (typeof (ArgumentOutOfRangeException))]
2086                 public void Wizard_ActiveStepException2 ()
2087                 {
2088                         Wizard wizard = new Wizard ();
2089                         wizard.ActiveStepIndex = -2;
2090                         WizardStepBase step = wizard.ActiveStep;
2091                 }
2092
2093                 [TestFixtureTearDown]
2094                 public void TearDown ()
2095                 {
2096                         WebTest.Unload ();
2097                 }
2098
2099                 // A simple Template class to wrap an image.
2100                 public class ImageTemplate : ITemplate
2101                 {
2102                         private Template.Image myImage;
2103                         public Template.Image MyImage
2104                         {
2105                                 get
2106                                 {
2107                                         return myImage;
2108                                 }
2109                                 set
2110                                 {
2111                                         myImage = value;
2112                                 }
2113                         }
2114                         public void InstantiateIn (Control container)
2115                         {
2116                                 container.Controls.Add (MyImage);
2117                         }
2118                 }
2119
2120                 private bool _eventchecker;
2121                 private void eventassert (string message)
2122                 {
2123                         Assert.IsTrue (_eventchecker, message);
2124                         _eventchecker = false;
2125                 }
2126         }
2127 }