WizardTests.cs 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Data;
  4. using System.Linq;
  5. using System.Threading.Tasks;
  6. using Terminal.Gui;
  7. using Xunit;
  8. using System.Globalization;
  9. using Xunit.Abstractions;
  10. using System.Text;
  11. using static Terminal.Gui.Application;
  12. namespace Terminal.Gui.DialogTests {
  13. public class WizardTests {
  14. readonly ITestOutputHelper output;
  15. public WizardTests (ITestOutputHelper output)
  16. {
  17. this.output = output;
  18. }
  19. private void RunButtonTestWizard (string title, int width, int height)
  20. {
  21. var wizard = new Wizard () { Title = title, Width = width, Height = height };
  22. Application.End (Application.Begin (wizard));
  23. }
  24. // =========== WizardStep Tests
  25. [Fact, AutoInitShutdown]
  26. public void WizardStep_ButtonText ()
  27. {
  28. // Verify default button text
  29. // Verify set actually changes property
  30. // Verify set actually changes buttons for the current step
  31. }
  32. [Fact]
  33. public void WizardStep_Set_Title_Fires_TitleChanging ()
  34. {
  35. var r = new Window ();
  36. Assert.Equal (string.Empty, r.Title);
  37. string expectedAfter = string.Empty;
  38. string expectedDuring = string.Empty;
  39. bool cancel = false;
  40. r.TitleChanging += (s,args) => {
  41. Assert.Equal (expectedDuring, args.NewTitle);
  42. args.Cancel = cancel;
  43. };
  44. r.Title = expectedDuring = expectedAfter = "title";
  45. Assert.Equal (expectedAfter, r.Title);
  46. r.Title = expectedDuring = expectedAfter = "a different title";
  47. Assert.Equal (expectedAfter, r.Title);
  48. // Now setup cancelling the change and change it back to "title"
  49. cancel = true;
  50. r.Title = expectedDuring = "title";
  51. Assert.Equal (expectedAfter, r.Title);
  52. r.Dispose ();
  53. }
  54. [Fact]
  55. public void WizardStep_Set_Title_Fires_TitleChanged ()
  56. {
  57. var r = new Window ();
  58. Assert.Equal (string.Empty, r.Title);
  59. string expected = string.Empty;
  60. r.TitleChanged += (s,args) => {
  61. Assert.Equal (r.Title, args.NewTitle);
  62. };
  63. expected = "title";
  64. r.Title = expected;
  65. Assert.Equal (expected, r.Title);
  66. expected = "another title";
  67. r.Title = expected;
  68. Assert.Equal (expected, r.Title);
  69. r.Dispose ();
  70. }
  71. // =========== Wizard Tests
  72. [Fact, AutoInitShutdown]
  73. public void DefaultConstructor_SizedProperly ()
  74. {
  75. var d = (FakeDriver)Application.Driver;
  76. var wizard = new Wizard ();
  77. Assert.NotEqual (0, wizard.Width);
  78. Assert.NotEqual (0, wizard.Height);
  79. }
  80. [Fact, AutoInitShutdown]
  81. // Verify a zero-step wizard doesn't crash and shows a blank wizard
  82. // and that the title is correct
  83. public void ZeroStepWizard_Shows ()
  84. {
  85. var d = (FakeDriver)Application.Driver;
  86. var title = "1234";
  87. var stepTitle = "";
  88. int width = 30;
  89. int height = 6;
  90. d.SetBufferSize (width, height);
  91. var btnBackText = "Back";
  92. var btnBack = $"{CM.Glyphs.LeftBracket} {btnBackText} {CM.Glyphs.RightBracket}";
  93. var btnNextText = "Finish";
  94. var btnNext = $"{CM.Glyphs.LeftBracket}{CM.Glyphs.LeftDefaultIndicator} {btnNextText} {CM.Glyphs.RightDefaultIndicator}{CM.Glyphs.RightBracket}";
  95. var topRow = $"{CM.Glyphs.ULCornerDbl}╡{title}{stepTitle}╞{new string (CM.Glyphs.HLineDbl.ToString () [0], width - title.Length - stepTitle.Length - 4)}{CM.Glyphs.URCornerDbl}";
  96. var row2 = $"{CM.Glyphs.VLineDbl}{new string (' ', width - 2)}{CM.Glyphs.VLineDbl}";
  97. var row3 = row2;
  98. var separatorRow = $"{CM.Glyphs.VLineDbl}{new string (CM.Glyphs.HLine.ToString () [0], width - 2)}{CM.Glyphs.VLineDbl}";
  99. var buttonRow = $"{CM.Glyphs.VLineDbl}{btnBack}{new string (' ', width - btnBack.Length - btnNext.Length - 2)}{btnNext}{CM.Glyphs.VLineDbl}";
  100. var bottomRow = $"{CM.Glyphs.LLCornerDbl}{new string (CM.Glyphs.HLineDbl.ToString () [0], width - 2)}{CM.Glyphs.LRCornerDbl}";
  101. var wizard = new Wizard () { Title = title, Width = width, Height = height };
  102. var runstate = Application.Begin (wizard);
  103. TestHelpers.AssertDriverContentsWithFrameAre ($"{topRow}\n{row2}\n{row3}\n{separatorRow}\n{buttonRow}\n{bottomRow}", output);
  104. Application.End (runstate);
  105. }
  106. [Fact, AutoInitShutdown]
  107. // This test verifies that a single step wizard shows the correct buttons
  108. // and that the title is correct
  109. public void OneStepWizard_Shows ()
  110. {
  111. var d = (FakeDriver)Application.Driver;
  112. var title = "1234";
  113. var stepTitle = "ABCD";
  114. int width = 30;
  115. int height = 7;
  116. d.SetBufferSize (width, height);
  117. // var btnBackText = "Back";
  118. var btnBack = string.Empty; // $"{CM.Glyphs.LeftBracket} {btnBackText} {CM.Glyphs.RightBracket}";
  119. var btnNextText = "Finish"; // "Next";
  120. var btnNext = $"{CM.Glyphs.LeftBracket}{CM.Glyphs.LeftDefaultIndicator} {btnNextText} {CM.Glyphs.RightDefaultIndicator}{CM.Glyphs.RightBracket}";
  121. var topRow = $"{CM.Glyphs.ULCornerDbl}╡{title} - {stepTitle}╞{new string (CM.Glyphs.HLineDbl.ToString () [0], width - title.Length - stepTitle.Length - 7)}{CM.Glyphs.URCornerDbl}";
  122. var row2 = $"{CM.Glyphs.VLineDbl}{new string (' ', width - 2)}{CM.Glyphs.VLineDbl}";
  123. var row3 = row2;
  124. var row4 = row3;
  125. var separatorRow = $"{CM.Glyphs.VLineDbl}{new string (CM.Glyphs.HLine.ToString () [0], width - 2)}{CM.Glyphs.VLineDbl}";
  126. var buttonRow = $"{CM.Glyphs.VLineDbl}{btnBack}{new string (' ', width - btnBack.Length - btnNext.Length - 2)}{btnNext}{CM.Glyphs.VLineDbl}";
  127. var bottomRow = $"{CM.Glyphs.LLCornerDbl}{new string (CM.Glyphs.HLineDbl.ToString () [0], width - 2)}{CM.Glyphs.LRCornerDbl}";
  128. var wizard = new Wizard () { Title = title, Width = width, Height = height };
  129. wizard.AddStep (new WizardStep () { Title = stepTitle });
  130. //wizard.LayoutSubviews ();
  131. var firstIteration = false;
  132. var runstate = Application.Begin (wizard);
  133. Application.RunIteration (ref runstate, ref firstIteration);
  134. TestHelpers.AssertDriverContentsWithFrameAre ($"{topRow}\n{row2}\n{row3}\n{row4}\n{separatorRow}\n{buttonRow}\n{bottomRow}", output);
  135. Application.End (runstate);
  136. }
  137. [Fact, AutoInitShutdown]
  138. // This test verifies that the 2nd step in a wizard with 2 steps
  139. // shows the correct buttons on both steps
  140. // and that the title is correct
  141. public void TwoStepWizard_Next_Shows_SecondStep ()
  142. {
  143. // verify step one
  144. // Next
  145. // verify step two
  146. // Back
  147. // verify step one again
  148. }
  149. [Fact, AutoInitShutdown]
  150. // This test verifies that the 2nd step in a wizard with more than 2 steps
  151. // shows the correct buttons on all steps
  152. // and that the title is correct
  153. public void ThreeStepWizard_Next_Shows_Steps ()
  154. {
  155. // verify step one
  156. // Next
  157. // verify step two
  158. // Back
  159. // verify step one again
  160. }
  161. [Fact, AutoInitShutdown]
  162. // this test is needed because Wizard overrides Dialog's title behavior ("Title - StepTitle")
  163. public void Setting_Title_Works ()
  164. {
  165. var d = (FakeDriver)Application.Driver;
  166. var title = "1234";
  167. var stepTitle = " - ABCD";
  168. int width = 40;
  169. int height = 4;
  170. d.SetBufferSize (width, height);
  171. var btnNextText = "Finish";
  172. var btnNext = $"{CM.Glyphs.LeftBracket}{CM.Glyphs.LeftDefaultIndicator} {btnNextText} {CM.Glyphs.RightDefaultIndicator}{CM.Glyphs.RightBracket}";
  173. var topRow = $"{CM.Glyphs.ULCornerDbl}╡{title}{stepTitle}╞{new string (CM.Glyphs.HLineDbl.ToString () [0], width - title.Length - stepTitle.Length - 4)}{CM.Glyphs.URCornerDbl}";
  174. var separatorRow = $"{CM.Glyphs.VLineDbl}{new string (CM.Glyphs.HLine.ToString () [0], width - 2)}{CM.Glyphs.VLineDbl}";
  175. // Once this is fixed, revert to commented out line: https://github.com/gui-cs/Terminal.Gui/issues/1791
  176. var buttonRow = $"{CM.Glyphs.VLineDbl}{new string (' ', width - btnNext.Length - 2)}{btnNext}{CM.Glyphs.VLineDbl}";
  177. //var buttonRow = $"{CM.Glyphs.VDLine}{new String (' ', width - btnNext.Length - 2)}{btnNext}{CM.Glyphs.VDLine}";
  178. var bottomRow = $"{CM.Glyphs.LLCornerDbl}{new string (CM.Glyphs.HLineDbl.ToString () [0], width - 2)}{CM.Glyphs.LRCornerDbl}";
  179. var wizard = new Wizard () { Title = title, Width = width, Height = height };
  180. wizard.AddStep (new WizardStep () { Title = "ABCD" });
  181. Application.End (Application.Begin (wizard));
  182. TestHelpers.AssertDriverContentsWithFrameAre ($"{topRow}\n{separatorRow}\n{buttonRow}\n{bottomRow}", output);
  183. }
  184. [Fact, AutoInitShutdown]
  185. public void Navigate_GetPreviousStep_Correct ()
  186. {
  187. var wizard = new Wizard ();
  188. // If no steps should be null
  189. Assert.Null (wizard.GetPreviousStep ());
  190. var step1 = new WizardStep () { Title = "step1" };
  191. wizard.AddStep (step1);
  192. // If no current step, should be last step
  193. Assert.Equal (step1.Title, wizard.GetPreviousStep ().Title);
  194. wizard.CurrentStep = step1;
  195. // If there is 1 step it's current step should be null
  196. Assert.Null (wizard.GetPreviousStep ());
  197. // If one disabled step should be null
  198. step1.Enabled = false;
  199. Assert.Null (wizard.GetPreviousStep ());
  200. // If two steps and at 2 and step 1 is `Enabled = true`should be step1
  201. var step2 = new WizardStep () { Title = "step2" };
  202. wizard.AddStep (step2);
  203. wizard.CurrentStep = step2;
  204. step1.Enabled = true;
  205. Assert.Equal (step1.Title, wizard.GetPreviousStep ().Title);
  206. // If two steps and at 2 and step 1 is `Enabled = false` should be null
  207. step1.Enabled = false;
  208. Assert.Null (wizard.GetPreviousStep ());
  209. // If three steps with Step2.Enabled = true
  210. // At step 1 should be null
  211. // At step 2 should be step 1
  212. // At step 3 should be step 2
  213. var step3 = new WizardStep () { Title = "step3" };
  214. wizard.AddStep (step3);
  215. step1.Enabled = true;
  216. wizard.CurrentStep = step1;
  217. step2.Enabled = true;
  218. step3.Enabled = true;
  219. Assert.Null (wizard.GetPreviousStep ());
  220. wizard.CurrentStep = step2;
  221. Assert.Equal (step1.Title, wizard.GetPreviousStep ().Title);
  222. wizard.CurrentStep = step3;
  223. Assert.Equal (step2.Title, wizard.GetPreviousStep ().Title);
  224. // If three steps with Step2.Enabled = false
  225. // At step 1 should be null
  226. // At step 3 should be step1
  227. step1.Enabled = true;
  228. step2.Enabled = false;
  229. step3.Enabled = true;
  230. wizard.CurrentStep = step1;
  231. Assert.Null (wizard.GetPreviousStep ());
  232. wizard.CurrentStep = step3;
  233. Assert.Equal (step1.Title, wizard.GetPreviousStep ().Title);
  234. // If three steps with Step1.Enabled = false & Step2.Enabled = false
  235. // At step 3 should be null
  236. // If no current step, GetPreviousStep provides equivalent to GetLastStep
  237. wizard.CurrentStep = null;
  238. step1.Enabled = true;
  239. step2.Enabled = true;
  240. step3.Enabled = true;
  241. Assert.Equal (step3.Title, wizard.GetPreviousStep ().Title);
  242. step1.Enabled = false;
  243. step2.Enabled = true;
  244. step3.Enabled = true;
  245. Assert.Equal (step3.Title, wizard.GetPreviousStep ().Title);
  246. step1.Enabled = false;
  247. step2.Enabled = false;
  248. step3.Enabled = true;
  249. Assert.Equal (step3.Title, wizard.GetPreviousStep ().Title);
  250. step1.Enabled = false;
  251. step2.Enabled = true;
  252. step3.Enabled = false;
  253. Assert.Equal (step2.Title, wizard.GetPreviousStep ().Title);
  254. step1.Enabled = true;
  255. step2.Enabled = false;
  256. step3.Enabled = false;
  257. Assert.Equal (step1.Title, wizard.GetPreviousStep ().Title);
  258. }
  259. [Fact, AutoInitShutdown]
  260. public void Navigate_GetNextStep_Correct ()
  261. {
  262. var wizard = new Wizard ();
  263. // If no steps should be null
  264. Assert.Null (wizard.GetNextStep ());
  265. var step1 = new WizardStep () { Title = "step1" };
  266. wizard.AddStep (step1);
  267. // If no current step, should be first step
  268. Assert.Equal (step1.Title, wizard.GetNextStep ().Title);
  269. wizard.CurrentStep = step1;
  270. // If there is 1 step it's current step should be null
  271. Assert.Null (wizard.GetNextStep ());
  272. // If one disabled step should be null
  273. step1.Enabled = false;
  274. Assert.Null (wizard.GetNextStep ());
  275. // If two steps and at 1 and step 2 is `Enabled = true`should be step 2
  276. var step2 = new WizardStep () { Title = "step2" };
  277. wizard.AddStep (step2);
  278. Assert.Equal (step2.Title, wizard.GetNextStep ().Title);
  279. // If two steps and at 1 and step 2 is `Enabled = false` should be null
  280. step1.Enabled = true;
  281. wizard.CurrentStep = step1;
  282. step2.Enabled = false;
  283. Assert.Null (wizard.GetNextStep ());
  284. // If three steps with Step2.Enabled = true
  285. // At step 1 should be step 2
  286. // At step 2 should be step 3
  287. // At step 3 should be null
  288. var step3 = new WizardStep () { Title = "step3" };
  289. wizard.AddStep (step3);
  290. step1.Enabled = true;
  291. wizard.CurrentStep = step1;
  292. step2.Enabled = true;
  293. step3.Enabled = true;
  294. Assert.Equal (step2.Title, wizard.GetNextStep ().Title);
  295. wizard.CurrentStep = step2;
  296. Assert.Equal (step3.Title, wizard.GetNextStep ().Title);
  297. wizard.CurrentStep = step3;
  298. Assert.Null (wizard.GetNextStep ());
  299. // If three steps with Step2.Enabled = false
  300. // At step 1 should be step 3
  301. // At step 3 should be null
  302. step1.Enabled = true;
  303. wizard.CurrentStep = step1;
  304. step2.Enabled = false;
  305. step3.Enabled = true;
  306. Assert.Equal (step3.Title, wizard.GetNextStep ().Title);
  307. wizard.CurrentStep = step3;
  308. Assert.Null (wizard.GetNextStep ());
  309. // If three steps with Step2.Enabled = false & Step3.Enabled = false
  310. // At step 1 should be null
  311. step1.Enabled = true;
  312. wizard.CurrentStep = step1;
  313. step2.Enabled = false;
  314. step3.Enabled = false;
  315. Assert.Null (wizard.GetNextStep ());
  316. // If no current step, GetNextStep provides equivalent to GetFirstStep
  317. wizard.CurrentStep = null;
  318. step1.Enabled = true;
  319. step2.Enabled = true;
  320. step3.Enabled = true;
  321. Assert.Equal (step1.Title, wizard.GetNextStep ().Title);
  322. step1.Enabled = false;
  323. step2.Enabled = true;
  324. step3.Enabled = true;
  325. Assert.Equal (step2.Title, wizard.GetNextStep ().Title);
  326. step1.Enabled = false;
  327. step2.Enabled = false;
  328. step3.Enabled = true;
  329. Assert.Equal (step3.Title, wizard.GetNextStep ().Title);
  330. step1.Enabled = false;
  331. step2.Enabled = true;
  332. step3.Enabled = false;
  333. Assert.Equal (step2.Title, wizard.GetNextStep ().Title);
  334. step1.Enabled = true;
  335. step2.Enabled = false;
  336. step3.Enabled = false;
  337. Assert.Equal (step1.Title, wizard.GetNextStep ().Title);
  338. }
  339. [Fact, AutoInitShutdown]
  340. public void Navigate_GoNext_Works ()
  341. {
  342. // If zero steps do nothing
  343. // If one step do nothing (enabled or disabled)
  344. // If two steps
  345. // If current is 1
  346. // If 2 is enabled 2 becomes current
  347. // If 2 is disabled 1 stays current
  348. // If current is 2 does nothing
  349. }
  350. [Fact, AutoInitShutdown]
  351. public void Navigate_GoBack_Works ()
  352. {
  353. // If zero steps do nothing
  354. // If one step do nothing (enabled or disabled)
  355. // If two steps
  356. // If current is 1 does nothing
  357. // If current is 2 does nothing
  358. // If 1 is enabled 2 becomes current
  359. // If 1 is disabled 1 stays current
  360. }
  361. [Fact, AutoInitShutdown]
  362. public void Navigate_GetFirstStep_Works ()
  363. {
  364. var wizard = new Wizard ();
  365. Assert.Null (wizard.GetFirstStep ());
  366. var step1 = new WizardStep () { Title = "step1" };
  367. wizard.AddStep (step1);
  368. Assert.Equal (step1.Title, wizard.GetFirstStep ().Title);
  369. var step2 = new WizardStep () { Title = "step2" };
  370. wizard.AddStep (step2);
  371. Assert.Equal (step1.Title, wizard.GetFirstStep ().Title);
  372. var step3 = new WizardStep () { Title = "step3" };
  373. wizard.AddStep (step3);
  374. Assert.Equal (step1.Title, wizard.GetFirstStep ().Title);
  375. step1.Enabled = false;
  376. Assert.Equal (step2.Title, wizard.GetFirstStep ().Title);
  377. step1.Enabled = true;
  378. Assert.Equal (step1.Title, wizard.GetFirstStep ().Title);
  379. step1.Enabled = false;
  380. step2.Enabled = false;
  381. Assert.Equal (step3.Title, wizard.GetFirstStep ().Title);
  382. }
  383. [Fact, AutoInitShutdown]
  384. public void Navigate_GetLastStep_Works ()
  385. {
  386. var wizard = new Wizard ();
  387. Assert.Null (wizard.GetLastStep ());
  388. var step1 = new WizardStep () { Title = "step1" };
  389. wizard.AddStep (step1);
  390. Assert.Equal (step1.Title, wizard.GetLastStep ().Title);
  391. var step2 = new WizardStep () { Title = "step2" };
  392. wizard.AddStep (step2);
  393. Assert.Equal (step2.Title, wizard.GetLastStep ().Title);
  394. var step3 = new WizardStep () { Title = "step3" };
  395. wizard.AddStep (step3);
  396. Assert.Equal (step3.Title, wizard.GetLastStep ().Title);
  397. step3.Enabled = false;
  398. Assert.Equal (step2.Title, wizard.GetLastStep ().Title);
  399. step3.Enabled = true;
  400. Assert.Equal (step3.Title, wizard.GetLastStep ().Title);
  401. step3.Enabled = false;
  402. step2.Enabled = false;
  403. Assert.Equal (step1.Title, wizard.GetLastStep ().Title);
  404. }
  405. [Fact, AutoInitShutdown]
  406. public void Finish_Button_Closes ()
  407. {
  408. // https://github.com/gui-cs/Terminal.Gui/issues/1833
  409. var wizard = new Wizard ();
  410. var step1 = new WizardStep () { Title = "step1" };
  411. wizard.AddStep (step1);
  412. var finishedFired = false;
  413. wizard.Finished += (s, args) => {
  414. finishedFired = true;
  415. };
  416. var closedFired = false;
  417. wizard.Closed += (s, e) => {
  418. closedFired = true;
  419. };
  420. var runstate = Application.Begin (wizard);
  421. var firstIteration = true;
  422. Application.RunIteration (ref runstate, ref firstIteration);
  423. wizard.NextFinishButton.OnClicked ();
  424. Application.RunIteration (ref runstate, ref firstIteration);
  425. Application.End (runstate);
  426. Assert.True (finishedFired);
  427. Assert.True (closedFired);
  428. step1.Dispose ();
  429. wizard.Dispose ();
  430. // Same test, but with two steps
  431. wizard = new Wizard ();
  432. firstIteration = false;
  433. step1 = new WizardStep () { Title = "step1" };
  434. wizard.AddStep (step1);
  435. var step2 = new WizardStep () { Title = "step2" };
  436. wizard.AddStep (step2);
  437. finishedFired = false;
  438. wizard.Finished += (s, args) => {
  439. finishedFired = true;
  440. };
  441. closedFired = false;
  442. wizard.Closed += (s,e) => {
  443. closedFired = true;
  444. };
  445. runstate = Application.Begin (wizard);
  446. Application.RunIteration (ref runstate, ref firstIteration);
  447. Assert.Equal (step1.Title, wizard.CurrentStep.Title);
  448. wizard.NextFinishButton.OnClicked ();
  449. Assert.False (finishedFired);
  450. Assert.False (closedFired);
  451. Assert.Equal (step2.Title, wizard.CurrentStep.Title);
  452. Assert.Equal (wizard.GetLastStep ().Title, wizard.CurrentStep.Title);
  453. wizard.NextFinishButton.OnClicked ();
  454. Application.End (runstate);
  455. Assert.True (finishedFired);
  456. Assert.True (closedFired);
  457. step1.Dispose ();
  458. step2.Dispose ();
  459. wizard.Dispose ();
  460. // Same test, but with two steps but the 1st one disabled
  461. wizard = new Wizard ();
  462. firstIteration = false;
  463. step1 = new WizardStep () { Title = "step1" };
  464. wizard.AddStep (step1);
  465. step2 = new WizardStep () { Title = "step2" };
  466. wizard.AddStep (step2);
  467. step1.Enabled = false;
  468. finishedFired = false;
  469. wizard.Finished += (s, args) => {
  470. finishedFired = true;
  471. };
  472. closedFired = false;
  473. wizard.Closed += (s,e) => {
  474. closedFired = true;
  475. };
  476. runstate = Application.Begin (wizard);
  477. Application.RunIteration (ref runstate, ref firstIteration);
  478. Assert.Equal (step2.Title, wizard.CurrentStep.Title);
  479. Assert.Equal (wizard.GetLastStep ().Title, wizard.CurrentStep.Title);
  480. wizard.NextFinishButton.OnClicked ();
  481. Application.End (runstate);
  482. Assert.True (finishedFired);
  483. Assert.True (closedFired);
  484. }
  485. }
  486. }