|
@@ -2,21 +2,16 @@
|
|
|
|
|
|
namespace Terminal.Gui.DialogTests;
|
|
namespace Terminal.Gui.DialogTests;
|
|
|
|
|
|
-public class WizardTests
|
|
|
|
|
|
+public class WizardTests (ITestOutputHelper output)
|
|
{
|
|
{
|
|
- private readonly ITestOutputHelper _output;
|
|
|
|
- public WizardTests (ITestOutputHelper output) { _output = output; }
|
|
|
|
-
|
|
|
|
// =========== Wizard Tests
|
|
// =========== Wizard Tests
|
|
[Fact]
|
|
[Fact]
|
|
- [AutoInitShutdown]
|
|
|
|
public void DefaultConstructor_SizedProperly ()
|
|
public void DefaultConstructor_SizedProperly ()
|
|
{
|
|
{
|
|
- var d = (FakeDriver)Application.Driver;
|
|
|
|
-
|
|
|
|
var wizard = new Wizard ();
|
|
var wizard = new Wizard ();
|
|
Assert.NotEqual (0, wizard.Width);
|
|
Assert.NotEqual (0, wizard.Width);
|
|
Assert.NotEqual (0, wizard.Height);
|
|
Assert.NotEqual (0, wizard.Height);
|
|
|
|
+ wizard.Dispose ();
|
|
}
|
|
}
|
|
|
|
|
|
[Fact]
|
|
[Fact]
|
|
@@ -47,9 +42,9 @@ public class WizardTests
|
|
wizard.Dispose ();
|
|
wizard.Dispose ();
|
|
|
|
|
|
// Same test, but with two steps
|
|
// Same test, but with two steps
|
|
- wizard = new Wizard ();
|
|
|
|
|
|
+ wizard = new ();
|
|
firstIteration = false;
|
|
firstIteration = false;
|
|
- step1 = new WizardStep { Title = "step1" };
|
|
|
|
|
|
+ step1 = new() { Title = "step1" };
|
|
wizard.AddStep (step1);
|
|
wizard.AddStep (step1);
|
|
var step2 = new WizardStep { Title = "step2" };
|
|
var step2 = new WizardStep { Title = "step2" };
|
|
wizard.AddStep (step2);
|
|
wizard.AddStep (step2);
|
|
@@ -80,11 +75,11 @@ public class WizardTests
|
|
wizard.Dispose ();
|
|
wizard.Dispose ();
|
|
|
|
|
|
// Same test, but with two steps but the 1st one disabled
|
|
// Same test, but with two steps but the 1st one disabled
|
|
- wizard = new Wizard ();
|
|
|
|
|
|
+ wizard = new ();
|
|
firstIteration = false;
|
|
firstIteration = false;
|
|
- step1 = new WizardStep { Title = "step1" };
|
|
|
|
|
|
+ step1 = new() { Title = "step1" };
|
|
wizard.AddStep (step1);
|
|
wizard.AddStep (step1);
|
|
- step2 = new WizardStep { Title = "step2" };
|
|
|
|
|
|
+ step2 = new() { Title = "step2" };
|
|
wizard.AddStep (step2);
|
|
wizard.AddStep (step2);
|
|
step1.Enabled = false;
|
|
step1.Enabled = false;
|
|
|
|
|
|
@@ -103,10 +98,10 @@ public class WizardTests
|
|
Application.End (runstate);
|
|
Application.End (runstate);
|
|
Assert.True (finishedFired);
|
|
Assert.True (finishedFired);
|
|
Assert.True (closedFired);
|
|
Assert.True (closedFired);
|
|
|
|
+ wizard.Dispose ();
|
|
}
|
|
}
|
|
|
|
|
|
[Fact]
|
|
[Fact]
|
|
- [AutoInitShutdown]
|
|
|
|
public void Navigate_GetFirstStep_Works ()
|
|
public void Navigate_GetFirstStep_Works ()
|
|
{
|
|
{
|
|
var wizard = new Wizard ();
|
|
var wizard = new Wizard ();
|
|
@@ -134,10 +129,10 @@ public class WizardTests
|
|
step1.Enabled = false;
|
|
step1.Enabled = false;
|
|
step2.Enabled = false;
|
|
step2.Enabled = false;
|
|
Assert.Equal (step3.Title, wizard.GetFirstStep ().Title);
|
|
Assert.Equal (step3.Title, wizard.GetFirstStep ().Title);
|
|
|
|
+ wizard.Dispose ();
|
|
}
|
|
}
|
|
|
|
|
|
[Fact]
|
|
[Fact]
|
|
- [AutoInitShutdown]
|
|
|
|
public void Navigate_GetLastStep_Works ()
|
|
public void Navigate_GetLastStep_Works ()
|
|
{
|
|
{
|
|
var wizard = new Wizard ();
|
|
var wizard = new Wizard ();
|
|
@@ -165,6 +160,7 @@ public class WizardTests
|
|
step3.Enabled = false;
|
|
step3.Enabled = false;
|
|
step2.Enabled = false;
|
|
step2.Enabled = false;
|
|
Assert.Equal (step1.Title, wizard.GetLastStep ().Title);
|
|
Assert.Equal (step1.Title, wizard.GetLastStep ().Title);
|
|
|
|
+ wizard.Dispose ();
|
|
}
|
|
}
|
|
|
|
|
|
[Fact]
|
|
[Fact]
|
|
@@ -263,6 +259,7 @@ public class WizardTests
|
|
step2.Enabled = false;
|
|
step2.Enabled = false;
|
|
step3.Enabled = false;
|
|
step3.Enabled = false;
|
|
Assert.Equal (step1.Title, wizard.GetNextStep ().Title);
|
|
Assert.Equal (step1.Title, wizard.GetNextStep ().Title);
|
|
|
|
+ wizard.Dispose ();
|
|
}
|
|
}
|
|
|
|
|
|
[Fact]
|
|
[Fact]
|
|
@@ -356,10 +353,10 @@ public class WizardTests
|
|
step2.Enabled = false;
|
|
step2.Enabled = false;
|
|
step3.Enabled = false;
|
|
step3.Enabled = false;
|
|
Assert.Equal (step1.Title, wizard.GetPreviousStep ().Title);
|
|
Assert.Equal (step1.Title, wizard.GetPreviousStep ().Title);
|
|
|
|
+ wizard.Dispose ();
|
|
}
|
|
}
|
|
|
|
|
|
[Fact]
|
|
[Fact]
|
|
- [AutoInitShutdown]
|
|
|
|
public void Navigate_GoBack_Works ()
|
|
public void Navigate_GoBack_Works ()
|
|
{
|
|
{
|
|
// If zero steps do nothing
|
|
// If zero steps do nothing
|
|
@@ -374,7 +371,6 @@ public class WizardTests
|
|
}
|
|
}
|
|
|
|
|
|
[Fact]
|
|
[Fact]
|
|
- [AutoInitShutdown]
|
|
|
|
public void Navigate_GoNext_Works ()
|
|
public void Navigate_GoNext_Works ()
|
|
{
|
|
{
|
|
// If zero steps do nothing
|
|
// If zero steps do nothing
|
|
@@ -429,16 +425,16 @@ public class WizardTests
|
|
} - {
|
|
} - {
|
|
stepTitle
|
|
stepTitle
|
|
}╞{
|
|
}╞{
|
|
- new string (CM.Glyphs.HLineDbl.ToString () [0], width - title.Length - stepTitle.Length - 7)
|
|
|
|
|
|
+ new (CM.Glyphs.HLineDbl.ToString () [0], width - title.Length - stepTitle.Length - 7)
|
|
}{
|
|
}{
|
|
CM.Glyphs.URCornerDbl
|
|
CM.Glyphs.URCornerDbl
|
|
}";
|
|
}";
|
|
- var row2 = $"{CM.Glyphs.VLineDbl}{new string (' ', width - 2)}{CM.Glyphs.VLineDbl}";
|
|
|
|
|
|
+ var row2 = $"{CM.Glyphs.VLineDbl}{new (' ', width - 2)}{CM.Glyphs.VLineDbl}";
|
|
string row3 = row2;
|
|
string row3 = row2;
|
|
string row4 = row3;
|
|
string row4 = row3;
|
|
|
|
|
|
var separatorRow =
|
|
var separatorRow =
|
|
- $"{CM.Glyphs.VLineDbl}{new string (CM.Glyphs.HLine.ToString () [0], width - 2)}{CM.Glyphs.VLineDbl}";
|
|
|
|
|
|
+ $"{CM.Glyphs.VLineDbl}{new (CM.Glyphs.HLine.ToString () [0], width - 2)}{CM.Glyphs.VLineDbl}";
|
|
|
|
|
|
var buttonRow =
|
|
var buttonRow =
|
|
$"{
|
|
$"{
|
|
@@ -446,7 +442,7 @@ public class WizardTests
|
|
}{
|
|
}{
|
|
btnBack
|
|
btnBack
|
|
}{
|
|
}{
|
|
- new string (' ', width - btnBack.Length - btnNext.Length - 2)
|
|
|
|
|
|
+ new (' ', width - btnBack.Length - btnNext.Length - 2)
|
|
}{
|
|
}{
|
|
btnNext
|
|
btnNext
|
|
}{
|
|
}{
|
|
@@ -457,13 +453,13 @@ public class WizardTests
|
|
$"{
|
|
$"{
|
|
CM.Glyphs.LLCornerDbl
|
|
CM.Glyphs.LLCornerDbl
|
|
}{
|
|
}{
|
|
- new string (CM.Glyphs.HLineDbl.ToString () [0], width - 2)
|
|
|
|
|
|
+ new (CM.Glyphs.HLineDbl.ToString () [0], width - 2)
|
|
}{
|
|
}{
|
|
CM.Glyphs.LRCornerDbl
|
|
CM.Glyphs.LRCornerDbl
|
|
}";
|
|
}";
|
|
|
|
|
|
var wizard = new Wizard { Title = title, Width = width, Height = height };
|
|
var wizard = new Wizard { Title = title, Width = width, Height = height };
|
|
- wizard.AddStep (new WizardStep { Title = stepTitle });
|
|
|
|
|
|
+ wizard.AddStep (new() { Title = stepTitle });
|
|
|
|
|
|
//wizard.LayoutSubviews ();
|
|
//wizard.LayoutSubviews ();
|
|
var firstIteration = false;
|
|
var firstIteration = false;
|
|
@@ -476,6 +472,7 @@ public class WizardTests
|
|
// _output
|
|
// _output
|
|
// );
|
|
// );
|
|
Application.End (runstate);
|
|
Application.End (runstate);
|
|
|
|
+ wizard.Dispose ();
|
|
}
|
|
}
|
|
|
|
|
|
[Fact]
|
|
[Fact]
|
|
@@ -516,36 +513,36 @@ public class WizardTests
|
|
}{
|
|
}{
|
|
stepTitle
|
|
stepTitle
|
|
}╞{
|
|
}╞{
|
|
- new string (CM.Glyphs.HLineDbl.ToString () [0], width - title.Length - stepTitle.Length - 4)
|
|
|
|
|
|
+ new (CM.Glyphs.HLineDbl.ToString () [0], width - title.Length - stepTitle.Length - 4)
|
|
}{
|
|
}{
|
|
CM.Glyphs.URCornerDbl
|
|
CM.Glyphs.URCornerDbl
|
|
}";
|
|
}";
|
|
|
|
|
|
var separatorRow =
|
|
var separatorRow =
|
|
- $"{CM.Glyphs.VLineDbl}{new string (CM.Glyphs.HLine.ToString () [0], width - 2)}{CM.Glyphs.VLineDbl}";
|
|
|
|
|
|
+ $"{CM.Glyphs.VLineDbl}{new (CM.Glyphs.HLine.ToString () [0], width - 2)}{CM.Glyphs.VLineDbl}";
|
|
|
|
|
|
// Once this is fixed, revert to commented out line: https://github.com/gui-cs/Terminal.Gui/issues/1791
|
|
// Once this is fixed, revert to commented out line: https://github.com/gui-cs/Terminal.Gui/issues/1791
|
|
var buttonRow =
|
|
var buttonRow =
|
|
- $"{CM.Glyphs.VLineDbl}{new string (' ', width - btnNext.Length - 2)}{btnNext}{CM.Glyphs.VLineDbl}";
|
|
|
|
|
|
+ $"{CM.Glyphs.VLineDbl}{new (' ', width - btnNext.Length - 2)}{btnNext}{CM.Glyphs.VLineDbl}";
|
|
|
|
|
|
//var buttonRow = $"{CM.Glyphs.VDLine}{new String (' ', width - btnNext.Length - 2)}{btnNext}{CM.Glyphs.VDLine}";
|
|
//var buttonRow = $"{CM.Glyphs.VDLine}{new String (' ', width - btnNext.Length - 2)}{btnNext}{CM.Glyphs.VDLine}";
|
|
var bottomRow =
|
|
var bottomRow =
|
|
$"{
|
|
$"{
|
|
CM.Glyphs.LLCornerDbl
|
|
CM.Glyphs.LLCornerDbl
|
|
}{
|
|
}{
|
|
- new string (CM.Glyphs.HLineDbl.ToString () [0], width - 2)
|
|
|
|
|
|
+ new (CM.Glyphs.HLineDbl.ToString () [0], width - 2)
|
|
}{
|
|
}{
|
|
CM.Glyphs.LRCornerDbl
|
|
CM.Glyphs.LRCornerDbl
|
|
}";
|
|
}";
|
|
|
|
|
|
var wizard = new Wizard { Title = title, Width = width, Height = height };
|
|
var wizard = new Wizard { Title = title, Width = width, Height = height };
|
|
- wizard.AddStep (new WizardStep { Title = "ABCD" });
|
|
|
|
|
|
+ wizard.AddStep (new() { Title = "ABCD" });
|
|
|
|
|
|
Application.End (Application.Begin (wizard));
|
|
Application.End (Application.Begin (wizard));
|
|
|
|
+ wizard.Dispose ();
|
|
}
|
|
}
|
|
|
|
|
|
[Fact]
|
|
[Fact]
|
|
- [AutoInitShutdown]
|
|
|
|
|
|
|
|
// This test verifies that the 2nd step in a wizard with more than 2 steps
|
|
// This test verifies that the 2nd step in a wizard with more than 2 steps
|
|
// shows the correct buttons on all steps
|
|
// shows the correct buttons on all steps
|
|
@@ -564,7 +561,6 @@ public class WizardTests
|
|
}
|
|
}
|
|
|
|
|
|
[Fact]
|
|
[Fact]
|
|
- [AutoInitShutdown]
|
|
|
|
|
|
|
|
// This test verifies that the 2nd step in a wizard with 2 steps
|
|
// This test verifies that the 2nd step in a wizard with 2 steps
|
|
// shows the correct buttons on both steps
|
|
// shows the correct buttons on both steps
|
|
@@ -585,7 +581,6 @@ public class WizardTests
|
|
// =========== WizardStep Tests
|
|
// =========== WizardStep Tests
|
|
|
|
|
|
[Fact]
|
|
[Fact]
|
|
- [AutoInitShutdown]
|
|
|
|
public void WizardStep_ButtonText ()
|
|
public void WizardStep_ButtonText ()
|
|
{
|
|
{
|
|
// Verify default button text
|
|
// Verify default button text
|
|
@@ -684,15 +679,15 @@ public class WizardTests
|
|
}{
|
|
}{
|
|
stepTitle
|
|
stepTitle
|
|
}╞{
|
|
}╞{
|
|
- new string (CM.Glyphs.HLineDbl.ToString () [0], width - title.Length - stepTitle.Length - 4)
|
|
|
|
|
|
+ new (CM.Glyphs.HLineDbl.ToString () [0], width - title.Length - stepTitle.Length - 4)
|
|
}{
|
|
}{
|
|
CM.Glyphs.URCornerDbl
|
|
CM.Glyphs.URCornerDbl
|
|
}";
|
|
}";
|
|
- var row2 = $"{CM.Glyphs.VLineDbl}{new string (' ', width - 2)}{CM.Glyphs.VLineDbl}";
|
|
|
|
|
|
+ var row2 = $"{CM.Glyphs.VLineDbl}{new (' ', width - 2)}{CM.Glyphs.VLineDbl}";
|
|
string row3 = row2;
|
|
string row3 = row2;
|
|
|
|
|
|
var separatorRow =
|
|
var separatorRow =
|
|
- $"{CM.Glyphs.VLineDbl}{new string (CM.Glyphs.HLine.ToString () [0], width - 2)}{CM.Glyphs.VLineDbl}";
|
|
|
|
|
|
+ $"{CM.Glyphs.VLineDbl}{new (CM.Glyphs.HLine.ToString () [0], width - 2)}{CM.Glyphs.VLineDbl}";
|
|
|
|
|
|
var buttonRow =
|
|
var buttonRow =
|
|
$"{
|
|
$"{
|
|
@@ -700,7 +695,7 @@ public class WizardTests
|
|
}{
|
|
}{
|
|
btnBack
|
|
btnBack
|
|
}{
|
|
}{
|
|
- new string (' ', width - btnBack.Length - btnNext.Length - 2)
|
|
|
|
|
|
+ new (' ', width - btnBack.Length - btnNext.Length - 2)
|
|
}{
|
|
}{
|
|
btnNext
|
|
btnNext
|
|
}{
|
|
}{
|
|
@@ -711,24 +706,20 @@ public class WizardTests
|
|
$"{
|
|
$"{
|
|
CM.Glyphs.LLCornerDbl
|
|
CM.Glyphs.LLCornerDbl
|
|
}{
|
|
}{
|
|
- new string (CM.Glyphs.HLineDbl.ToString () [0], width - 2)
|
|
|
|
|
|
+ new (CM.Glyphs.HLineDbl.ToString () [0], width - 2)
|
|
}{
|
|
}{
|
|
CM.Glyphs.LRCornerDbl
|
|
CM.Glyphs.LRCornerDbl
|
|
}";
|
|
}";
|
|
|
|
|
|
var wizard = new Wizard { Title = title, Width = width, Height = height };
|
|
var wizard = new Wizard { Title = title, Width = width, Height = height };
|
|
RunState runstate = Application.Begin (wizard);
|
|
RunState runstate = Application.Begin (wizard);
|
|
|
|
+
|
|
// TODO: Disabled until Dim.Auto is used in Dialog
|
|
// TODO: Disabled until Dim.Auto is used in Dialog
|
|
//TestHelpers.AssertDriverContentsWithFrameAre (
|
|
//TestHelpers.AssertDriverContentsWithFrameAre (
|
|
// $"{topRow}\n{row2}\n{row3}\n{separatorRow}\n{buttonRow}\n{bottomRow}",
|
|
// $"{topRow}\n{row2}\n{row3}\n{separatorRow}\n{buttonRow}\n{bottomRow}",
|
|
// _output
|
|
// _output
|
|
// );
|
|
// );
|
|
Application.End (runstate);
|
|
Application.End (runstate);
|
|
- }
|
|
|
|
-
|
|
|
|
- private void RunButtonTestWizard (string title, int width, int height)
|
|
|
|
- {
|
|
|
|
- var wizard = new Wizard { Title = title, Width = width, Height = height };
|
|
|
|
- Application.End (Application.Begin (wizard));
|
|
|
|
|
|
+ wizard.Dispose ();
|
|
}
|
|
}
|
|
}
|
|
}
|