2 // Tests for System.Web.UI.WebControls.WizardTest.cs
5 // Vladimir Krasnov <vladimirk@mainsoft.com>
6 // Yoni Klein (yonik@mainsoft.com)
9 // Copyright (C) 2005 Novell, Inc (http://www.novell.com)
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:
19 // The above copyright notice and this permission notice shall be
20 // included in all copies or substantial portions of the Software.
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.
34 using System.Collections.Generic;
39 using System.Web.UI.WebControls;
40 using Template = System.Web.UI.WebControls;
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;
49 using MonoTests.Common;
52 namespace MonoTests.System.Web.UI.WebControls
55 class PokerWizard : Wizard
64 public object SaveState ()
66 return SaveViewState ();
69 public void LoadState (object o)
74 public StateBag StateBag
76 get { return base.ViewState; }
79 public static string PokerCancelButtonID
83 return PokerWizard.CancelButtonID;
87 public static string PokerCustomFinishButtonID
91 return PokerWizard.CustomFinishButtonID;
95 public static string PokerCustomNextButtonID
99 return PokerWizard.CustomNextButtonID;
103 public static string PokerCustomPreviousButtonID
107 return PokerWizard.CustomPreviousButtonID;
111 public static string PokerDataListID
115 return PokerWizard.DataListID;
119 public static string PokerFinishButtonID
123 return PokerWizard.FinishButtonID;
127 public static string PokerFinishPreviousButtonID
131 return PokerWizard.FinishPreviousButtonID;
135 public static string PokerSideBarButtonID
139 return PokerWizard.SideBarButtonID;
143 public static string PokerStartNextButtonID
147 return PokerWizard.StartNextButtonID;
151 public static string PokerStepNextButtonID
155 return PokerWizard.StepNextButtonID;
159 public static string PokerStepPreviousButtonID
163 return PokerWizard.StepPreviousButtonID;
167 public HtmlTextWriterTag PokerTagKey
175 public object PokerSaveControlState ()
177 return base.SaveControlState ();
180 public void PokerLoadControlState (object state)
182 base.LoadControlState (state);
185 public bool PokerAllowNavigationToStep (int index)
187 return base.AllowNavigationToStep (index);
190 public void PokerCreateChildControls ()
192 base.CreateChildControls ();
195 public ControlCollection PokerCreateControlCollection ()
197 return base.CreateControlCollection ();
200 public Style PokerCreateControlStyle ()
202 return base.CreateControlStyle ();
205 public void DoOnActiveStepChanged (object source, EventArgs e)
207 base.OnActiveStepChanged (source, e);
210 public void DoOnCancelButtonClick (EventArgs e)
212 base.OnCancelButtonClick (e);
215 public void DoOnDataBinding (EventArgs e)
217 base.OnDataBinding (e);
220 public void DoOnFinishButtonClick (WizardNavigationEventArgs e)
222 base.OnFinishButtonClick (e);
225 public void DoOnInit (EventArgs e)
230 public void DoOnLoad (EventArgs e)
235 public void DoOnNextButtonClick (WizardNavigationEventArgs e)
237 base.OnNextButtonClick (e);
240 public void DoOnPreRender (EventArgs e)
242 base.OnPreRender (e);
245 public void DoOnPreviousButtonClick (WizardNavigationEventArgs e)
247 base.OnPreviousButtonClick (e);
250 public void DoOnSideBarButtonClick (WizardNavigationEventArgs e)
252 base.OnSideBarButtonClick (e);
257 get { return base.TagName; }
260 public string Render ()
262 StringWriter sw = new StringWriter ();
264 HtmlTextWriter writer = new HtmlTextWriter (sw);
265 base.Render (writer);
266 return writer.InnerWriter.ToString ();
269 public Style GetStyle ()
271 return base.CreateControlStyle ();
274 public void TrackState ()
281 private bool onBubble;
282 public bool OnBubbleEventCalled
284 get { return onBubble; }
285 set { onBubble = value; }
287 protected override bool OnBubbleEvent (object source, EventArgs e)
290 return base.OnBubbleEvent (source, e);
293 public bool DoBubbleEvent (object source, EventArgs e)
295 return base.OnBubbleEvent (source, e);
298 public void DoEnsureChildControls ()
300 base.EnsureChildControls ();
303 class TestHeaderSpan : WebControl
305 public TestHeaderSpan ()
306 : base (HtmlTextWriterTag.Span)
309 class TestHeaderTemplate : ITemplate
311 public void InstantiateIn (Control container)
313 container.Controls.Add (new LiteralControl ("Header"));
317 class TestLayoutTemplate : ITemplate
319 public bool HasHeaderPlaceHolder { get; set; }
320 public bool HasNavigationPlaceHolder { get; set; }
321 public bool HasSideBarPlaceHolder { get; set; }
322 public bool HasWizardStepPlaceHolder { get; set; }
324 public Type HeaderPlaceHolderType { get; set; }
325 public Type NavigationPlaceHolderType { get; set; }
326 public Type SideBarPlaceHolderType { get; set; }
327 public Type WizardStepPlaceHolderType { get; set; }
329 public TestLayoutTemplate ()
331 HeaderPlaceHolderType = typeof (PlaceHolder);
332 NavigationPlaceHolderType = typeof (PlaceHolder);
333 SideBarPlaceHolderType = typeof (PlaceHolder);
334 WizardStepPlaceHolderType = typeof (PlaceHolder);
337 public void InstantiateIn (Control container)
339 if (HasHeaderPlaceHolder)
340 container.Controls.Add (MakePlaceHolder (HeaderPlaceHolderType, Wizard.HeaderPlaceholderId));
342 if (HasSideBarPlaceHolder)
343 container.Controls.Add (MakePlaceHolder (SideBarPlaceHolderType, Wizard.SideBarPlaceholderId));
345 if (HasNavigationPlaceHolder)
346 container.Controls.Add (MakePlaceHolder (NavigationPlaceHolderType, Wizard.NavigationPlaceholderId));
348 if (HasWizardStepPlaceHolder)
349 container.Controls.Add (MakePlaceHolder (WizardStepPlaceHolderType, Wizard.WizardStepPlaceholderId));
352 Control MakePlaceHolder (Type type, string id)
354 Control ctl = Activator.CreateInstance (type) as Control;
356 throw new InvalidOperationException ("Placeholder must descend from the Control type.");
363 public class WizardTest
366 public void Wizard_DefaultProperty ()
368 PokerWizard wizard = new PokerWizard ();
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");
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");
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");
439 public void Wizard_DefaultPropertyNotWorking ()
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");
449 public void Wizard_StateBag ()
451 PokerWizard w = new PokerWizard ();
452 Assert.AreEqual (0, w.Attributes.Count, "Attributes.Count");
453 Assert.AreEqual (0, w.StateBag.Count, "ViewState.Count");
455 w.CancelButtonImageUrl = "value";
456 Assert.AreEqual ("value", w.CancelButtonImageUrl, "CancelButtonImageUrl");
457 Assert.AreEqual (1, w.StateBag.Count, "ViewState.Count-1");
459 w.CancelDestinationPageUrl = "value";
460 Assert.AreEqual ("value", w.CancelDestinationPageUrl, "CancelDestinationPageUrl");
461 Assert.AreEqual (2, w.StateBag.Count, "ViewState.Count-2");
463 w.FinishCompleteButtonImageUrl = "value";
464 Assert.AreEqual ("value", w.FinishCompleteButtonImageUrl, "FinishCompleteButtonImageUrl");
465 Assert.AreEqual (3, w.StateBag.Count, "ViewState.Count-3");
467 w.FinishDestinationPageUrl = "value";
468 Assert.AreEqual ("value", w.FinishDestinationPageUrl, "FinishDestinationPageUrl");
469 Assert.AreEqual (4, w.StateBag.Count, "ViewState.Count-4");
471 w.FinishPreviousButtonImageUrl = "value";
472 Assert.AreEqual ("value", w.FinishPreviousButtonImageUrl, "FinishPreviousButtonImageUrl");
473 Assert.AreEqual (5, w.StateBag.Count, "ViewState.Count-5");
475 w.StartNextButtonImageUrl = "value";
476 Assert.AreEqual ("value", w.StartNextButtonImageUrl, "StartNextButtonImageUrl");
477 Assert.AreEqual (6, w.StateBag.Count, "ViewState.Count-6");
479 w.StepNextButtonImageUrl = "value";
480 Assert.AreEqual ("value", w.StepNextButtonImageUrl, "StepNextButtonImageUrl");
481 Assert.AreEqual (7, w.StateBag.Count, "ViewState.Count-7");
483 w.StepPreviousButtonImageUrl = "value";
484 Assert.AreEqual ("value", w.StepPreviousButtonImageUrl, "StepPreviousButtonImageUrl");
485 Assert.AreEqual (8, w.StateBag.Count, "ViewState.Count-8");
487 w.CancelButtonText = "value";
488 Assert.AreEqual ("value", w.CancelButtonText, "CancelButtonText");
489 Assert.AreEqual (9, w.StateBag.Count, "ViewState.Count-9");
491 w.FinishCompleteButtonText = "value";
492 Assert.AreEqual ("value", w.FinishCompleteButtonText, "FinishCompleteButtonText");
493 Assert.AreEqual (10, w.StateBag.Count, "ViewState.Count-10");
495 w.StartNextButtonText = "value";
496 Assert.AreEqual ("value", w.StartNextButtonText, "StartNextButtonText");
497 Assert.AreEqual (11, w.StateBag.Count, "ViewState.Count-11");
499 w.StepNextButtonText = "value";
500 Assert.AreEqual ("value", w.StepNextButtonText, "StepNextButtonText");
501 Assert.AreEqual (12, w.StateBag.Count, "ViewState.Count-12");
503 w.StepPreviousButtonText = "value";
504 Assert.AreEqual ("value", w.StepPreviousButtonText, "StepPreviousButtonText");
505 Assert.AreEqual (13, w.StateBag.Count, "ViewState.Count-13");
507 w.CancelButtonType = ButtonType.Button;
508 Assert.AreEqual (ButtonType.Button, w.CancelButtonType, "CancelButtonType");
509 Assert.AreEqual (14, w.StateBag.Count, "ViewState.Count-14");
511 w.FinishCompleteButtonType = ButtonType.Button;
512 Assert.AreEqual (ButtonType.Button, w.FinishCompleteButtonType, "FinishCompleteButtonType");
513 Assert.AreEqual (15, w.StateBag.Count, "ViewState.Count-15");
515 w.FinishPreviousButtonType = ButtonType.Button;
516 Assert.AreEqual (ButtonType.Button, w.FinishPreviousButtonType, "FinishPreviousButtonType");
517 Assert.AreEqual (16, w.StateBag.Count, "ViewState.Count-16");
519 w.StartNextButtonType = ButtonType.Button;
520 Assert.AreEqual (ButtonType.Button, w.StartNextButtonType, "StartNextButtonType");
521 Assert.AreEqual (17, w.StateBag.Count, "ViewState.Count-17");
523 w.StepNextButtonType = ButtonType.Button;
524 Assert.AreEqual (ButtonType.Button, w.StepNextButtonType, "StepNextButtonType");
525 Assert.AreEqual (18, w.StateBag.Count, "ViewState.Count-18");
527 w.StepPreviousButtonType = ButtonType.Button;
528 Assert.AreEqual (ButtonType.Button, w.StepPreviousButtonType, "StepPreviousButtonType");
529 Assert.AreEqual (19, w.StateBag.Count, "ViewState.Count-19");
533 [Category ("NunitWeb")]
534 public void Wizard_CancelButtonPropertyRendering ()
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");
543 public static void _CancelButtonPropertyRendering (Page p)
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;
555 WizardStep ws1 = new WizardStep ();
557 ws1.StepType = WizardStepType.Start;
558 ws1.Controls.Add (new LiteralControl ("Start"));
560 WizardStep ws2 = new WizardStep ();
562 ws2.StepType = WizardStepType.Finish;
563 ws2.Controls.Add (new LiteralControl ("Finish"));
565 w.DisplaySideBar = false;
566 w.WizardSteps.Add (ws1);
567 w.WizardSteps.Add (ws2);
570 p.Controls.Add (lce);
574 [Category ("NunitWeb")]
575 public void Wizard_FinishButtonPropertyRendering ()
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('ctl00$FinishNavigationTemplateContainerID$FinishLinkButton','')\" 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");
585 public static void _FinishButtonPropertyRendering (Page p)
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;
600 WizardStep ws0 = new WizardStep ();
602 ws0.StepType = WizardStepType.Start;
603 ws0.Controls.Add (new LiteralControl ("Finish"));
605 WizardStep ws1 = new WizardStep ();
607 ws1.StepType = WizardStepType.Finish;
608 ws1.Controls.Add (new LiteralControl ("Finish"));
610 w.DisplaySideBar = false;
611 w.WizardSteps.Add (ws0);
612 w.WizardSteps.Add (ws1);
614 p.Controls.Add (lcb);
616 p.Controls.Add (lce);
620 [Category ("NunitWeb")]
621 public void Wizard_HeaderRendering ()
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");
630 public static void _HeaderRendering (Page p)
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";
639 WizardStep ws0 = new WizardStep ();
641 ws0.StepType = WizardStepType.Start;
642 ws0.Controls.Add (new LiteralControl ("Start"));
644 WizardStep ws1 = new WizardStep ();
646 ws1.StepType = WizardStepType.Finish;
647 ws1.Controls.Add (new LiteralControl ("Finish"));
649 w.DisplaySideBar = false;
650 w.WizardSteps.Add (ws0);
651 w.WizardSteps.Add (ws1);
653 p.Controls.Add (lcb);
655 p.Controls.Add (lce);
658 private static void _BuildHeader (Control container)
661 ctrl = new TextBox ();
662 ctrl.ID = "TextBox1";
663 container.Controls.Add (ctrl);
667 [Category ("NunitWeb")]
668 public void Wizard_SideBarRendering ()
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&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('ctl00$SideBarContainer$SideBarList$ctl00$SideBarButton','')\" 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('ctl00$SideBarContainer$SideBarList$ctl01$SideBarButton','')\" 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");
677 public static void _SideBarRendering (Page p)
679 LiteralControl lcb = new LiteralControl (HtmlDiff.BEGIN_TAG);
680 LiteralControl lce = new LiteralControl (HtmlDiff.END_TAG);
681 PokerWizard w = new PokerWizard ();
683 w.SideBarButtonStyle.BackColor = Color.Red;
684 w.SideBarStyle.BackColor = Color.Red;
685 w.SideBarTemplate = new CompiledTemplateBuilder (_SideBarTemplate);
687 WizardStep ws1 = new WizardStep ();
689 ws1.StepType = WizardStepType.Auto;
690 ws1.Controls.Add (new LiteralControl ("Step 1"));
692 WizardStep ws2 = new WizardStep ();
694 ws2.StepType = WizardStepType.Auto;
695 ws2.Controls.Add (new LiteralControl ("Step 2"));
697 w.WizardSteps.Add (ws1);
698 w.WizardSteps.Add (ws2);
699 p.Controls.Add (lcb);
701 p.Controls.Add (lce);
704 private static void _SideBarTemplate (Control container)
706 DataList list = new DataList ();
707 list.ItemTemplate = new CompiledTemplateBuilder (_ItemTemplate);
708 list.ID = "SideBarList";
709 container.Controls.Add (list);
712 private static void _ItemTemplate (Control container)
714 Button button = new Button();
715 button.ID = "SideBarButton";
716 container.Controls.Add (button);
720 [Category ("NunitWeb")]
721 public void Wizard_NavigationRendering ()
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&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('ctl00$SideBarContainer$SideBarList$ctl00$SideBarButton','')\">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('ctl00$SideBarContainer$SideBarList$ctl01$SideBarButton','')\">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");
730 public static void _NavigationRendering (Page p)
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 ();
739 ws1.StepType = WizardStepType.Start;
740 ws1.Controls.Add (new LiteralControl ("Start"));
743 ws2.StepType = WizardStepType.Start;
744 ws2.Controls.Add (new LiteralControl ("Finish"));
746 w.NavigationButtonStyle.BackColor = Color.Red;
747 w.NavigationStyle.BackColor = Color.Yellow;
749 w.WizardSteps.Add (ws1);
750 w.WizardSteps.Add (ws2);
751 p.Controls.Add (lcb);
753 p.Controls.Add (lce);
757 [Category ("NunitWeb")]
758 public void Wizard_StartTypeRendering ()
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&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('ctl00$SideBarContainer$SideBarList$ctl00$SideBarButton','')\">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('ctl00$SideBarContainer$SideBarList$ctl01$SideBarButton','')\">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");
767 public static void _StartTypeRendering (Page p)
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 ();
776 ws1.StepType = WizardStepType.Start;
777 ws1.Controls.Add (new LiteralControl ("Start"));
780 ws2.StepType = WizardStepType.Finish;
781 ws2.Controls.Add (new LiteralControl ("Finish"));
783 w.StartNextButtonImageUrl = "StartNextButtonImageUrl";
784 w.StartNextButtonStyle.BackColor = Color.Red;
785 w.StartNextButtonText = "StartNextButtonText";
786 w.StartNextButtonType = ButtonType.Button;
788 w.WizardSteps.Add (ws1);
789 w.WizardSteps.Add (ws2);
790 p.Controls.Add (lcb);
792 p.Controls.Add (lce);
796 [Category ("NunitWeb")]
797 public void Wizard_StartTemplateRendering ()
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&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('ctl00$SideBarContainer$SideBarList$ctl00$SideBarButton','')\">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");
806 public static void _StartTemplateRendering (Page p)
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 ();
814 ws1.StepType = WizardStepType.Start;
815 ws1.Controls.Add (new LiteralControl ("Start"));
817 w.StartNavigationTemplate = new CompiledTemplateBuilder (_StartTemplate);
819 w.WizardSteps.Add (ws1);
820 p.Controls.Add (lcb);
822 p.Controls.Add (lce);
825 private static void _StartTemplate (Control container)
827 Button button = new Button();
828 button.ID = "SideBarButton";
829 button.BackColor = Color.Red;
830 container.Controls.Add (button);
834 [Category ("NunitWeb")]
835 public void Wizard_StepTypeRendering ()
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&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('ctl00$SideBarContainer$SideBarList$ctl00$SideBarButton','')\">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('ctl00$SideBarContainer$SideBarList$ctl01$SideBarButton','')\">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('ctl00$SideBarContainer$SideBarList$ctl02$SideBarButton','')\">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('ctl00$StepNavigationTemplateContainerID$StepPreviousLinkButton','')\" 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");
844 public static void _StepTypeRendering (Page p)
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 ();
854 ws1.StepType = WizardStepType.Start;
855 ws1.Controls.Add (new LiteralControl ("Step1"));
858 ws2.StepType = WizardStepType.Step;
859 ws2.Controls.Add (new LiteralControl ("Step2"));
862 ws3.StepType = WizardStepType.Finish;
863 ws3.Controls.Add (new LiteralControl ("Step3"));
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;
875 w.WizardSteps.Add (ws1);
876 w.WizardSteps.Add (ws2);
877 w.WizardSteps.Add (ws3);
880 p.Controls.Add (lcb);
882 p.Controls.Add (lce);
886 [Category ("NunitWeb")]
887 public void Wizard_StepNavigationTemplateRendering ()
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&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('ctl00$SideBarContainer$SideBarList$ctl00$SideBarButton','')\">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('ctl00$SideBarContainer$SideBarList$ctl01$SideBarButton','')\">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");
896 public static void _StepNavigationTemplate (Page p)
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 ();
905 ws1.StepType = WizardStepType.Step;
906 ws1.Controls.Add (new LiteralControl ("Step1"));
909 ws2.StepType = WizardStepType.Step;
910 ws2.Controls.Add (new LiteralControl ("Step2"));
912 w.StepNavigationTemplate = new CompiledTemplateBuilder (_StepNavigationTemplateCreator);
914 w.WizardSteps.Add (ws1);
915 w.WizardSteps.Add (ws2);
916 p.Controls.Add (lcb);
918 p.Controls.Add (lce);
922 private static void _StepNavigationTemplateCreator (Control container)
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);
937 public void Wizard_AssignProperty ()
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");
1033 public void Wizard_GetHistory ()
1035 PokerWizard wizard = new PokerWizard ();
1036 WizardStep step1 = new WizardStep ();
1038 step1.StepType = WizardStepType.Start;
1039 WizardStep step2 = new WizardStep ();
1041 step2.StepType = WizardStepType.Step;
1042 WizardStep step3 = new WizardStep ();
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");
1063 public void Wizard_GetStepType ()
1065 PokerWizard wizard = new PokerWizard ();
1066 WizardStep step1 = new WizardStep ();
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");
1076 public void Wizard_MoveTo ()
1078 PokerWizard wizard = new PokerWizard ();
1079 WizardStep step1 = new WizardStep ();
1081 step1.StepType = WizardStepType.Start;
1082 WizardStep step2 = new WizardStep ();
1084 step2.StepType = WizardStepType.Step;
1085 WizardStep step3 = new WizardStep ();
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");
1102 public void Wizard_AllowNavigationToStep ()
1104 PokerWizard wizard = new PokerWizard ();
1105 WizardStep step1 = new WizardStep ();
1107 step1.StepType = WizardStepType.Start;
1108 WizardStep step2 = new WizardStep ();
1110 step2.StepType = WizardStepType.Step;
1111 WizardStep step3 = new WizardStep ();
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");
1129 public void Wizard_AllowNavigationToStep_NoIndexCheck ()
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");
1138 public void Wizard_CreateControlCollection ()
1140 PokerWizard wizard = new PokerWizard ();
1141 ControlCollection collection = wizard.PokerCreateControlCollection ();
1142 Assert.IsNotNull (collection, "CreateControlCollection");
1143 Assert.AreEqual (0, collection.Count, "CreateControlCollection#1");
1147 public void Wizard_CreateControlStyle ()
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");
1157 public void Wizard_ControlState ()
1159 PokerWizard wizard = new PokerWizard ();
1160 WizardStep step1 = new WizardStep ();
1162 step1.StepType = WizardStepType.Start;
1163 WizardStep step3 = new WizardStep ();
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");
1182 public void Wizard_ViewState ()
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");
1214 public void Wizard_Steps ()
1216 PokerWizard w = new PokerWizard ();
1217 Assert.AreEqual (-1, w.ActiveStepIndex, "ActiveStepIndex on no steps");
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");
1229 public void Wizard_ActiveStepChanged ()
1231 PokerWizard wizard = new PokerWizard ();
1232 wizard.ActiveStepChanged += new EventHandler (wizard_handler);
1233 wizard.DoOnActiveStepChanged (this, new EventArgs ());
1234 eventassert ("ActiveStepChanged");
1238 public void Wizard_CancelButtonClick ()
1240 PokerWizard wizard = new PokerWizard ();
1241 wizard.CancelButtonClick += new EventHandler (wizard_handler);
1242 wizard.DoOnCancelButtonClick (new EventArgs ());
1243 eventassert ("CancelButtonClick");
1247 public void Wizard_FinishButtonClick ()
1249 PokerWizard wizard = new PokerWizard ();
1250 wizard.FinishButtonClick += new WizardNavigationEventHandler (wizard_handler);
1251 wizard.DoOnFinishButtonClick (new WizardNavigationEventArgs (0, 0));
1252 eventassert ("FinishButtonClick");
1256 public void Wizard_NextButtonClick ()
1258 PokerWizard wizard = new PokerWizard ();
1259 wizard.NextButtonClick += new WizardNavigationEventHandler (wizard_handler);
1260 wizard.DoOnNextButtonClick (new WizardNavigationEventArgs (0, 1));
1261 eventassert ("NextButtonClick");
1265 public void Wizard_PreviousButtonClick ()
1267 PokerWizard wizard = new PokerWizard ();
1268 wizard.PreviousButtonClick += new WizardNavigationEventHandler (wizard_handler);
1269 wizard.DoOnPreviousButtonClick (new WizardNavigationEventArgs (0, 1));
1270 eventassert ("PreviousButtonClick");
1274 public void Wizard_SideBarButtonClick ()
1276 PokerWizard wizard = new PokerWizard ();
1277 wizard.SideBarButtonClick += new WizardNavigationEventHandler (wizard_handler);
1278 wizard.DoOnSideBarButtonClick (new WizardNavigationEventArgs (0, 1));
1279 eventassert ("SideBarButtonClick");
1282 public void wizard_handler (object o, EventArgs e)
1284 _eventchecker = true;
1291 public void Wizard_BubbleEvent_CancelEvent ()
1293 PokerWizard wizard = new PokerWizard ();
1294 wizard.CancelButtonClick += new EventHandler (wizard_handler);
1295 WizardStep step1 = new WizardStep ();
1297 step1.StepType = WizardStepType.Start;
1298 WizardStep step3 = new WizardStep ();
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");
1311 public void Wizard_BubbleEvent_MoveNext ()
1313 PokerWizard wizard = new PokerWizard ();
1314 wizard.NextButtonClick += new WizardNavigationEventHandler (wizard_handler);
1315 WizardStep step1 = new WizardStep ();
1317 step1.StepType = WizardStepType.Start;
1318 WizardStep step2 = new WizardStep ();
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");
1332 public void Wizard_BubbleEvent_MovePrevious ()
1334 PokerWizard wizard = new PokerWizard ();
1335 wizard.PreviousButtonClick += new WizardNavigationEventHandler (wizard_handler);
1336 WizardStep step1 = new WizardStep ();
1338 step1.StepType = WizardStepType.Start;
1339 WizardStep step2 = new WizardStep ();
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");
1352 public void Wizard_BubbleEvent_MoveComplete ()
1354 PokerWizard wizard = new PokerWizard ();
1355 wizard.FinishButtonClick += new WizardNavigationEventHandler (wizard_handler);
1356 WizardStep step1 = new WizardStep ();
1358 step1.StepType = WizardStepType.Start;
1359 WizardStep step2 = new WizardStep ();
1361 step2.StepType = WizardStepType.Finish;
1362 WizardStep step3 = new WizardStep ();
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");
1376 public void Wizard_BubbleEvent_MoveTo ()
1378 PokerWizard wizard = new PokerWizard ();
1379 WizardStep step1 = new WizardStep ();
1381 step1.StepType = WizardStepType.Start;
1382 WizardStep step2 = new WizardStep ();
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");
1401 [Category ("NunitWeb")]
1402 public void Wizard_RenderTest ()
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");
1411 public static void WizardPreInit (Page p)
1413 LiteralControl lcb = new LiteralControl (HtmlDiff.BEGIN_TAG);
1414 LiteralControl lce = new LiteralControl (HtmlDiff.END_TAG);
1416 Wizard w = new Wizard ();
1417 WizardStep ws = new WizardStep ();
1418 ws.Controls.Add (new LiteralControl ("123"));
1420 w.SkipLinkText = "";
1422 catch (Exception) { }
1423 w.DisplaySideBar = false;
1424 w.WizardSteps.Add (ws);
1425 p.Controls.Add (lcb);
1427 p.Controls.Add (lce);
1431 [Category ("NunitWeb")]
1432 public void Wizard_RenderTestStartItem ()
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");
1445 [Category ("NunitWeb")]
1446 public void Wizard_RenderTestStepItem ()
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");
1460 [Category ("NunitWeb")]
1461 public void Wizard_RenderTestAutoItem ()
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");
1475 [Category ("NunitWeb")]
1476 public void Wizard_RenderTestFinishItem ()
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");
1490 public void Wizard_LayoutTemplate ()
1492 var w = new Wizard ();
1494 Assert.IsNull (w.LayoutTemplate, "#A1");
1498 public void Wizard_LayoutTemplate_Empty ()
1500 WebTest t = new WebTest (PageInvoker.CreateOnInit (LayoutTemplateRender));
1501 t.UserData = "Empty";
1504 AssertExtensions.Throws<InvalidOperationException> (() => {
1510 public void Wizard_LayoutTemplate_OptionalSideBar ()
1512 WebTest t = new WebTest (PageInvoker.CreateOnInit (LayoutTemplateRender));
1513 t.UserData = "OptionalSideBar_NoSideBar";
1514 string result = t.Run ();
1515 string renderedHtml = HtmlDiff.GetControlFromPageHtml (result);
1517 Assert.AreEqual (String.Empty, renderedHtml, "#A1");
1519 t.UserData = "OptionalSideBar_WithSideBar";
1520 AssertExtensions.Throws<InvalidOperationException> (() => {
1526 public void Wizard_LayoutTemplate_RenderSideBar ()
1528 WebTest t = new WebTest (PageInvoker.CreateOnInit (LayoutTemplateRender));
1529 t.UserData = "RenderSideBar";
1530 string result = t.Run ();
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('MyWizard$SideBarList$ctl00$SideBarButton','')\">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";
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('MyWizard$SideBarList$ctl00$SideBarButton','')\">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";
1536 string renderedHtml = HtmlDiff.GetControlFromPageHtml (result);
1537 Console.WriteLine (origHtml);
1538 Console.WriteLine ("----------------------------");
1539 Console.WriteLine (renderedHtml);
1541 Assert.AreEqual (origHtml, renderedHtml, "#A1");
1545 public void Wizard_LayoutTemplate_OptionalHeader ()
1547 WebTest t = new WebTest (PageInvoker.CreateOnInit (LayoutTemplateRender));
1548 t.UserData = "OptionalHeader_NoHeaderTemplate";
1549 string result = t.Run ();
1550 string renderedHtml = HtmlDiff.GetControlFromPageHtml (result);
1552 Assert.AreEqual (String.Empty, renderedHtml, "#A1");
1554 t.UserData = "OptionalHeader_WithHeaderTemplate";
1555 AssertExtensions.Throws<InvalidOperationException> (() => {
1561 public void Wizard_LayoutTemplate_RenderHeader ()
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);
1569 Assert.AreEqual (origHtml, renderedHtml, "#A1");
1571 t.UserData = "RenderHeader_InSpan";
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, renderedHtml, "#A2");
1579 public void Wizard_LayoutTemplate_StepPlaceHolder ()
1581 WebTest t = new WebTest (PageInvoker.CreateOnInit (LayoutTemplateRender));
1582 t.UserData = "StepPlaceHolder";
1583 AssertExtensions.Throws<InvalidOperationException> (() => {
1584 string result = t.Run ();
1589 public void Wizard_LayoutTemplate_NavigationPlaceHolder ()
1591 WebTest t = new WebTest (PageInvoker.CreateOnInit (LayoutTemplateRender));
1592 t.UserData = "NavigationPlaceHolder";
1593 AssertExtensions.Throws<InvalidOperationException> (() => {
1594 string result = t.Run ();
1598 public static void LayoutTemplateRender (Page p)
1600 var w = new Wizard ();
1602 WebTest curTest = WebTest.CurrentTest;
1603 string id = (string)curTest.UserData;
1607 w.LayoutTemplate = new TestLayoutTemplate ();
1610 case "OptionalSideBar_NoSideBar":
1611 w.LayoutTemplate = new TestLayoutTemplate {
1612 HasHeaderPlaceHolder = true,
1613 HasNavigationPlaceHolder = true,
1614 HasWizardStepPlaceHolder = true
1616 w.DisplaySideBar = false;
1619 case "OptionalSideBar_WithSideBar":
1620 w.LayoutTemplate = new TestLayoutTemplate {
1621 HasHeaderPlaceHolder = true,
1622 HasNavigationPlaceHolder = true,
1623 HasWizardStepPlaceHolder = true
1625 w.DisplaySideBar = true;
1628 case "RenderSideBar":
1629 w.LayoutTemplate = new TestLayoutTemplate {
1630 HasHeaderPlaceHolder = true,
1631 HasNavigationPlaceHolder = true,
1632 HasWizardStepPlaceHolder = true,
1633 HasSideBarPlaceHolder = true
1635 AddWizardStep (w, "Step", "step1");
1638 case "OptionalHeader_NoHeaderTemplate":
1639 w.LayoutTemplate = new TestLayoutTemplate {
1640 HasNavigationPlaceHolder = true,
1641 HasWizardStepPlaceHolder = true
1643 w.DisplaySideBar = false;
1646 case "OptionalHeader_WithHeaderTemplate":
1647 w.LayoutTemplate = new TestLayoutTemplate {
1648 HasNavigationPlaceHolder = true,
1649 HasWizardStepPlaceHolder = true
1651 w.HeaderTemplate = new TestHeaderTemplate ();
1652 w.DisplaySideBar = false;
1655 case "RenderHeader":
1656 w.LayoutTemplate = new TestLayoutTemplate {
1657 HasNavigationPlaceHolder = true,
1658 HasWizardStepPlaceHolder = true,
1659 HasHeaderPlaceHolder = true
1661 w.HeaderTemplate = new TestHeaderTemplate ();
1662 w.DisplaySideBar = false;
1663 AddWizardStep (w, "Step", "step1");
1666 case "RenderHeader_InSpan":
1667 w.LayoutTemplate = new TestLayoutTemplate {
1668 HasNavigationPlaceHolder = true,
1669 HasWizardStepPlaceHolder = true,
1670 HasHeaderPlaceHolder = true,
1671 HeaderPlaceHolderType = typeof (TestHeaderSpan)
1673 w.HeaderTemplate = new TestHeaderTemplate ();
1674 w.DisplaySideBar = false;
1675 AddWizardStep (w, "Step", "step1");
1678 case "StepPlaceHolder":
1679 w.LayoutTemplate = new TestLayoutTemplate {
1680 HasNavigationPlaceHolder = true,
1682 w.DisplaySideBar = false;
1685 case "NavigationPlaceHolder":
1686 w.LayoutTemplate = new TestLayoutTemplate {
1687 HasWizardStepPlaceHolder = true,
1689 w.DisplaySideBar = false;
1693 throw new InvalidOperationException ("Unknown id '" + id + "'");
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));
1701 static void AddWizardStep (Wizard w, string stepText, string stepID, WizardStepType type = WizardStepType.Step)
1703 var ws = new WizardStep ();
1706 ws.Controls.Add (new LiteralControl (stepText));
1708 w.WizardSteps.Add (ws);
1711 [Category ("NunitWeb")]
1712 public void Wizard_RenderTestCompleteItem ()
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");
1724 public static void _renderingWizard (Page p)
1726 Wizard w = new Wizard ();
1729 WizardStep ws = new WizardStep ();
1731 ws.StepType = WizardStepType.Start;
1732 ws.Controls.Add (new LiteralControl ("Start"));
1734 WizardStep ws1 = new WizardStep ();
1736 ws1.StepType = WizardStepType.Step;
1737 ws1.Controls.Add (new LiteralControl ("Step"));
1739 WizardStep ws2 = new WizardStep ();
1741 ws2.StepType = WizardStepType.Auto;
1742 ws2.Controls.Add (new LiteralControl ("Auto"));
1744 WizardStep ws3 = new WizardStep ();
1746 ws3.StepType = WizardStepType.Finish;
1747 ws3.Controls.Add (new LiteralControl ("FinishText"));
1749 WizardStep ws4 = new WizardStep ();
1751 ws4.StepType = WizardStepType.Complete;
1752 ws4.Controls.Add (new LiteralControl ("Complete"));
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;
1766 [Category ("NunitWeb")]
1767 public void Wizard_PostBackFireEvents_1 ()
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");
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";
1786 Assert.AreEqual ("CancelButtonClick", t.UserData.ToString (), "Cancel");
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";
1798 Assert.AreEqual ("NextButtonClick", t.UserData.ToString (), "Next");
1801 fr = new FormRequest (t.Response, "form1");
1802 fr.Controls.Add ("__EVENTTARGET");
1803 fr.Controls.Add ("__EVENTARGUMENT");
1804 fr.Controls.Add ("Wizard1$FinishNavigationTemplateContainerID$FinishPreviousButton");
1806 fr.Controls["__EVENTTARGET"].Value = "";
1807 fr.Controls["__EVENTARGUMENT"].Value = "";
1808 fr.Controls["Wizard1$FinishNavigationTemplateContainerID$FinishPreviousButton"].Value = "Previous";
1812 Assert.AreEqual ("PreviousButtonClick", t.UserData.ToString (), "Previous");
1817 [Category ("NunitWeb")]
1818 public void Wizard_PostBackFireEvents_2 ()
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");
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";
1836 Assert.AreEqual ("NextButtonClick", t.UserData.ToString (), "Next");
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";
1848 Assert.AreEqual ("FinishButtonClick", t.UserData.ToString (), "Finish");
1853 [Category ("NunitWeb")]
1854 public void Wizard_PostBackFireEvents_3 ()
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");
1864 fr = new FormRequest (t.Response, "form1");
1865 fr.Controls.Add ("__EVENTTARGET");
1866 fr.Controls.Add ("__EVENTARGUMENT");
1868 fr.Controls ["__EVENTTARGET"].Value = "Wizard1$SideBarContainer$SideBarList$ctl01$SideBarButton";
1869 fr.Controls ["__EVENTARGUMENT"].Value = "";
1872 Assert.AreEqual ("SideBarButtonClick", t.UserData.ToString (), "SideBarButton");
1875 public static void _postbackEvents (Page p)
1877 p.EnableEventValidation = false;
1878 Wizard w = new Wizard ();
1879 w.DisplayCancelButton = true;
1880 w.DisplaySideBar = true;
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);
1889 WizardStep ws = new WizardStep ();
1891 ws.StepType = WizardStepType.Start;
1892 ws.Controls.Add (new LiteralControl ("StartType"));
1894 WizardStep ws2 = new WizardStep ();
1896 ws2.StepType = WizardStepType.Finish;
1897 ws2.Controls.Add (new LiteralControl ("FinishType"));
1899 WizardStep ws3 = new WizardStep ();
1901 ws3.StepType = WizardStepType.Complete;
1902 ws3.Controls.Add (new LiteralControl ("CompleteType"));
1904 w.DisplaySideBar = true;
1905 w.WizardSteps.Add (ws);
1906 w.WizardSteps.Add (ws2);
1907 w.WizardSteps.Add (ws3);
1911 static void w_SideBarButtonClick (object sender, WizardNavigationEventArgs e)
1913 WebTest.CurrentTest.UserData = "SideBarButtonClick";
1916 static void w_PreviousButtonClick (object sender, WizardNavigationEventArgs e)
1918 WebTest.CurrentTest.UserData = "PreviousButtonClick";
1921 static void w_NextButtonClick (object sender, WizardNavigationEventArgs e)
1923 WebTest.CurrentTest.UserData = "NextButtonClick";
1926 static void w_FinishButtonClick (object sender, WizardNavigationEventArgs e)
1928 WebTest.CurrentTest.UserData = "FinishButtonClick";
1931 static void w_CancelButtonClick (object sender, EventArgs e)
1933 WebTest.CurrentTest.UserData = "CancelButtonClick";
1937 [Category ("NunitWeb")]
1938 public void Wizard_PostBack()
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");
1949 ArrayList list = t.UserData as ArrayList;
1950 Assert.IsNotNull (list, "PostBackDataNotCreated");
1952 FormRequest fr = new FormRequest (t.Response, "form1");
1953 fr.Controls.Add ("__EVENTTARGET");
1954 fr.Controls.Add ("__EVENTARGUMENT");
1956 fr.Controls["__EVENTTARGET"].Value = list[1].ToString();
1957 fr.Controls["__EVENTARGUMENT"].Value = "";
1961 if (result.IndexOf ("StepType") < 0)
1962 Assert.Fail ("MovedToStep1");
1964 fr = new FormRequest (t.Response, "form1");
1965 fr.Controls.Add ("__EVENTTARGET");
1966 fr.Controls.Add ("__EVENTARGUMENT");
1968 fr.Controls["__EVENTTARGET"].Value = list[2].ToString ();
1969 fr.Controls["__EVENTARGUMENT"].Value = "";
1973 if (result.IndexOf ("AutoType") < 0)
1974 Assert.Fail ("MovedToStep2");
1976 fr = new FormRequest (t.Response, "form1");
1977 fr.Controls.Add ("__EVENTTARGET");
1978 fr.Controls.Add ("__EVENTARGUMENT");
1980 fr.Controls["__EVENTTARGET"].Value = list[3].ToString ();
1981 fr.Controls["__EVENTARGUMENT"].Value = "";
1985 if (result.IndexOf ("FinishType") < 0)
1986 Assert.Fail ("MovedToStep3");
1988 fr = new FormRequest (t.Response, "form1");
1989 fr.Controls.Add ("__EVENTTARGET");
1990 fr.Controls.Add ("__EVENTARGUMENT");
1992 fr.Controls["__EVENTTARGET"].Value = list[4].ToString ();
1993 fr.Controls["__EVENTARGUMENT"].Value = "";
1997 if (result.IndexOf ("CompleteType") < 0)
1998 Assert.Fail ("MovedToStep4");
2001 public static void _postback (Page p)
2003 p.EnableEventValidation = false;
2004 Wizard w = new Wizard ();
2007 WizardStep ws = new WizardStep ();
2009 ws.StepType = WizardStepType.Start;
2010 ws.Controls.Add (new LiteralControl ("StartType"));
2012 WizardStep ws1 = new WizardStep ();
2014 ws1.StepType = WizardStepType.Step;
2015 ws1.Controls.Add (new LiteralControl ("StepType"));
2017 WizardStep ws2 = new WizardStep ();
2019 ws2.StepType = WizardStepType.Auto;
2020 ws2.Controls.Add (new LiteralControl ("AutoType"));
2022 WizardStep ws3 = new WizardStep ();
2024 ws3.StepType = WizardStepType.Finish;
2025 ws3.Controls.Add (new LiteralControl ("FinishType"));
2027 WizardStep ws4 = new WizardStep ();
2029 ws4.StepType = WizardStepType.Complete;
2030 ws4.Controls.Add (new LiteralControl ("CompleteType"));
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);
2042 public static void _readControl (Page p)
2044 ArrayList list = new ArrayList();
2045 recurcivefind (list, typeof (LinkButton), p.FindControl ("Wizard"));
2046 WebTest.CurrentTest.UserData = list;
2049 public static void recurcivefind (ArrayList list, Type t, Control control )
2051 foreach (Control c in control.Controls)
2055 if (t == c.GetType ()) {
2056 list.Add (c.UniqueID);
2058 recurcivefind (list, t, c);
2068 [ExpectedException (typeof (InvalidCastException))]
2069 public void Wizard_ViewStateException ()
2071 PokerWizard wizard = new PokerWizard ();
2072 wizard.LoadState (new object ());
2076 [ExpectedException (typeof (InvalidOperationException))]
2077 public void Wizard_ActiveStepException1 ()
2079 Wizard wizard = new Wizard ();
2080 wizard.ActiveStepIndex = 1;
2081 WizardStepBase step = wizard.ActiveStep;
2085 [ExpectedException (typeof (ArgumentOutOfRangeException))]
2086 public void Wizard_ActiveStepException2 ()
2088 Wizard wizard = new Wizard ();
2089 wizard.ActiveStepIndex = -2;
2090 WizardStepBase step = wizard.ActiveStep;
2093 [TestFixtureTearDown]
2094 public void TearDown ()
2099 // A simple Template class to wrap an image.
2100 public class ImageTemplate : ITemplate
2102 private Template.Image myImage;
2103 public Template.Image MyImage
2114 public void InstantiateIn (Control container)
2116 container.Controls.Add (MyImage);
2120 private bool _eventchecker;
2121 private void eventassert (string message)
2123 Assert.IsTrue (_eventchecker, message);
2124 _eventchecker = false;