PageRenderTime 43ms CodeModel.GetById 4ms RepoModel.GetById 0ms app.codeStats 0ms

/mcs/class/System.Web/Test/System.Web.UI.WebControls/WizardTest.cs

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