diff --git a/TerminalGuiFluentTesting/With.cs b/TerminalGuiFluentTesting/With.cs index 963eb8bfc..b65d83238 100644 --- a/TerminalGuiFluentTesting/With.cs +++ b/TerminalGuiFluentTesting/With.cs @@ -14,7 +14,7 @@ public static class With /// /// Which v2 v2TestDriver to use for the test /// - public static GuiTestContext A (int width, int height, V2TestDriver v2TestDriver = V2TestDriver.V2Win) where T : Toplevel, new () + public static GuiTestContext A (int width, int height, V2TestDriver v2TestDriver) where T : Toplevel, new () { return new (() => new T (), width, height,v2TestDriver); } diff --git a/Tests/IntegrationTests/FluentTests/BasicFluentAssertionTests.cs b/Tests/IntegrationTests/FluentTests/BasicFluentAssertionTests.cs index 95af2afba..d5cfcb1d2 100644 --- a/Tests/IntegrationTests/FluentTests/BasicFluentAssertionTests.cs +++ b/Tests/IntegrationTests/FluentTests/BasicFluentAssertionTests.cs @@ -22,30 +22,33 @@ public class BasicFluentAssertionTests public BasicFluentAssertionTests (ITestOutputHelper outputHelper) { _out = new TestOutputWriter (outputHelper); } - [Fact] - public void GuiTestContext_StartsAndStopsWithoutError () + [Theory] + [ClassData (typeof (V2TestDrivers))] + public void GuiTestContext_StartsAndStopsWithoutError (V2TestDriver d) { - using GuiTestContext context = With.A (40, 10); + using GuiTestContext context = With.A (40, 10,d); // No actual assertions are needed — if no exceptions are thrown, it's working context.Stop (); } - [Fact] - public void GuiTestContext_ForgotToStop () + [Theory] + [ClassData (typeof (V2TestDrivers))] + public void GuiTestContext_ForgotToStop (V2TestDriver d) { - using GuiTestContext context = With.A (40, 10); + using GuiTestContext context = With.A (40, 10, d); } - [Fact] - public void TestWindowsResize () + [Theory] + [ClassData (typeof (V2TestDrivers))] + public void TestWindowsResize (V2TestDriver d) { var lbl = new Label { Width = Dim.Fill () }; - using GuiTestContext c = With.A (40, 10) + using GuiTestContext c = With.A (40, 10, d) .Add (lbl) .Then (() => Assert.Equal (lbl.Frame.Width, 38)) // Window has 2 border .ResizeConsole (20, 20) @@ -53,8 +56,9 @@ public class BasicFluentAssertionTests .Stop (); } - [Fact] - public void ContextMenu_CrashesOnRight () + [Theory] + [ClassData (typeof (V2TestDrivers))] + public void ContextMenu_CrashesOnRight (V2TestDriver d) { var clicked = false; @@ -66,7 +70,7 @@ public class BasicFluentAssertionTests ] ); - using GuiTestContext c = With.A (40, 10) + using GuiTestContext c = With.A (40, 10, d) .WithContextMenu (ctx, menuItems) .ScreenShot ("Before open menu", _out) @@ -80,9 +84,8 @@ public class BasicFluentAssertionTests } [Theory] - [InlineData(V2TestDriver.V2Win)] - [InlineData (V2TestDriver.V2Net)] - public void ContextMenu_OpenSubmenu (V2TestDriver v2TestDriver) + [ClassData (typeof (V2TestDrivers))] + public void ContextMenu_OpenSubmenu (V2TestDriver d) { var clicked = false; @@ -112,7 +115,7 @@ public class BasicFluentAssertionTests ] ); - using GuiTestContext c = With.A (40, 10,v2TestDriver) + using GuiTestContext c = With.A (40, 10,d) .WithContextMenu (ctx, menuItems) .ScreenShot ("Before open menu", _out) diff --git a/Tests/IntegrationTests/FluentTests/V2TestDrivers.cs b/Tests/IntegrationTests/FluentTests/V2TestDrivers.cs new file mode 100644 index 000000000..00509815c --- /dev/null +++ b/Tests/IntegrationTests/FluentTests/V2TestDrivers.cs @@ -0,0 +1,15 @@ +using System.Collections; +using TerminalGuiFluentTesting; + +namespace IntegrationTests.FluentTests; + +public class V2TestDrivers : IEnumerable +{ + public IEnumerator GetEnumerator () + { + yield return new object [] { V2TestDriver.V2Win }; + yield return new object [] { V2TestDriver.V2Net }; + } + + IEnumerator IEnumerable.GetEnumerator () => GetEnumerator (); +}