Browse Source

Step 3: Port SetupFakeDriverAttribute to use built-in FakeDriver

Co-authored-by: tig <[email protected]>
copilot-swe-agent[bot] 1 month ago
parent
commit
359e6a5d7e

+ 4 - 4
Tests/UnitTests/ConsoleDrivers/FakeDriverTests.cs

@@ -180,12 +180,12 @@ public class FakeDriverTests (ITestOutputHelper output)
 
 
     [Fact]
     [Fact]
     [SetupFakeDriver]
     [SetupFakeDriver]
-    public void SetupFakeDriver_Driver_Is_FakeConsoleDriver ()
+    public void SetupFakeDriver_Driver_Is_FakeDriver ()
     {
     {
         Assert.NotNull (Application.Driver);
         Assert.NotNull (Application.Driver);
         
         
-        // Should be IFakeConsoleDriver
-        Assert.IsAssignableFrom<IFakeConsoleDriver> (Application.Driver);
+        // Should be FakeDriver
+        Assert.IsAssignableFrom<FakeDriver> (Application.Driver);
         
         
         _output.WriteLine ($"Driver type: {Application.Driver.GetType().Name}");
         _output.WriteLine ($"Driver type: {Application.Driver.GetType().Name}");
     }
     }
@@ -194,7 +194,7 @@ public class FakeDriverTests (ITestOutputHelper output)
     [SetupFakeDriver]
     [SetupFakeDriver]
     public void SetupFakeDriver_Can_Set_Buffer_Size ()
     public void SetupFakeDriver_Can_Set_Buffer_Size ()
     {
     {
-        var fakeDriver = Application.Driver as IFakeConsoleDriver;
+        var fakeDriver = Application.Driver as FakeDriver;
         Assert.NotNull (fakeDriver);
         Assert.NotNull (fakeDriver);
 
 
         fakeDriver!.SetBufferSize (100, 50);
         fakeDriver!.SetBufferSize (100, 50);

+ 5 - 6
Tests/UnitTests/SetupFakeDriverAttribute.cs

@@ -1,6 +1,5 @@
 using System.Diagnostics;
 using System.Diagnostics;
 using System.Reflection;
 using System.Reflection;
-using TerminalGuiFluentTesting;
 using Xunit.Sdk;
 using Xunit.Sdk;
 
 
 namespace UnitTests;
 namespace UnitTests;
@@ -10,8 +9,7 @@ namespace UnitTests;
 ///     FakeDriver(). The driver is set up with 25 rows and columns.
 ///     FakeDriver(). The driver is set up with 25 rows and columns.
 /// </summary>
 /// </summary>
 /// <remarks>
 /// <remarks>
-///     On Before, sets Configuration.Locations to ConfigLocations.DefaultOnly.
-///     On After, sets Configuration.Locations to ConfigLocations.All.
+///     This attribute uses the built-in FakeDriver from Terminal.Gui.Drivers namespace.
 /// </remarks>
 /// </remarks>
 [AttributeUsage (AttributeTargets.Class | AttributeTargets.Method)]
 [AttributeUsage (AttributeTargets.Class | AttributeTargets.Method)]
 public class SetupFakeDriverAttribute : BeforeAfterTestAttribute
 public class SetupFakeDriverAttribute : BeforeAfterTestAttribute
@@ -36,9 +34,10 @@ public class SetupFakeDriverAttribute : BeforeAfterTestAttribute
         Application.ResetState (true);
         Application.ResetState (true);
         Assert.Null (Application.Driver);
         Assert.Null (Application.Driver);
 
 
-        var ff = new FakeDriverFactory ();
-        var driver = ff.Create ();
-
+        // Use the built-in FakeDriver from the library
+        var driver = new FakeDriver ();
+        driver.Init ();
+        
         Application.Driver = driver;
         Application.Driver = driver;
         driver.SetBufferSize (25, 25);
         driver.SetBufferSize (25, 25);