WizardTests.cs 23 KB

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