WizardTests.cs 19 KB

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