WizardTest.cs 75 KB

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