From 9fb77a353e9058eaf38d223094eee201ba5a462a Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 26 Oct 2025 21:47:19 +0000 Subject: [PATCH] Complete Rows/Cols read-only refactor - fix all test files - Fixed all test files to use SetScreenSize() instead of setting Rows/Cols - Updated ApplicationTests, ApplicationScreenTests, AddRuneTests, ClipRegionTests, ConsoleDriverTests - All UnitTests now build and FakeDriver tests pass (21/21) - Source of truth is now IConsoleDriver.Screen via backing fields Work items for future: - Rename OnSizeChanged to OnScreenChanged - Fix AutoInitShutdownAttribute.FakeResize Co-authored-by: tig <585482+tig@users.noreply.github.com> --- Tests/UnitTests/Application/ApplicationScreenTests.cs | 5 ++++- Tests/UnitTests/Application/ApplicationTests.cs | 5 ++--- Tests/UnitTests/ConsoleDrivers/AddRuneTests.cs | 3 +-- Tests/UnitTests/ConsoleDrivers/ClipRegionTests.cs | 6 ++---- Tests/UnitTests/ConsoleDrivers/ConsoleDriverTests.cs | 6 ++---- 5 files changed, 11 insertions(+), 14 deletions(-) diff --git a/Tests/UnitTests/Application/ApplicationScreenTests.cs b/Tests/UnitTests/Application/ApplicationScreenTests.cs index 4fb8b03d9..8e1424729 100644 --- a/Tests/UnitTests/Application/ApplicationScreenTests.cs +++ b/Tests/UnitTests/Application/ApplicationScreenTests.cs @@ -94,7 +94,10 @@ public class ApplicationScreenTests // Arrange Application.ResetState (true); Assert.Null (Application.Driver); - Application.Driver = new FakeDriver { Rows = 25, Cols = 25 }; + var driver = new FakeDriver(); + driver.Init(); + driver.SetScreenSize(25, 25); + Application.Driver = driver; Application.SubscribeDriverEvents (); Assert.Equal (new (0, 0, 25, 25), Application.Screen); diff --git a/Tests/UnitTests/Application/ApplicationTests.cs b/Tests/UnitTests/Application/ApplicationTests.cs index 8de8b43b5..cf47e70e5 100644 --- a/Tests/UnitTests/Application/ApplicationTests.cs +++ b/Tests/UnitTests/Application/ApplicationTests.cs @@ -627,9 +627,8 @@ public class ApplicationTests Assert.Equal (new (0, 0, 80, 25), driver.Screen); Assert.Equal (new (0, 0, 80, 25), Application.Screen); - // TODO: Should not be possible to manually change these at whim! - driver.Cols = 100; - driver.Rows = 30; + // Use SetScreenSize to change screen dimensions + driver.SetScreenSize (100, 30); // IConsoleDriver.Screen isn't assignable //driver.Screen = new (0, 0, driver.Cols, Rows); diff --git a/Tests/UnitTests/ConsoleDrivers/AddRuneTests.cs b/Tests/UnitTests/ConsoleDrivers/AddRuneTests.cs index 18523a898..a63cd4327 100644 --- a/Tests/UnitTests/ConsoleDrivers/AddRuneTests.cs +++ b/Tests/UnitTests/ConsoleDrivers/AddRuneTests.cs @@ -28,8 +28,7 @@ public class AddRuneTests var driver = (IConsoleDriver)Activator.CreateInstance (driverType); driver.Init (); - driver.Rows = 25; - driver.Cols = 80; + driver.SetScreenSize(80, 25); driver.Init (); driver.AddRune (new Rune ('a')); Assert.Equal ((Rune)'a', driver.Contents [0, 0].Rune); diff --git a/Tests/UnitTests/ConsoleDrivers/ClipRegionTests.cs b/Tests/UnitTests/ConsoleDrivers/ClipRegionTests.cs index 3cc5433c5..22ae3f24d 100644 --- a/Tests/UnitTests/ConsoleDrivers/ClipRegionTests.cs +++ b/Tests/UnitTests/ConsoleDrivers/ClipRegionTests.cs @@ -26,8 +26,7 @@ public class ClipRegionTests { var driver = (IConsoleDriver)Activator.CreateInstance (driverType); Application.Init (driver); - Application.Driver!.Rows = 25; - Application.Driver!.Cols = 80; + Application.Driver!.SetScreenSize (80, 25); driver.Move (0, 0); driver.AddRune ('x'); @@ -94,8 +93,7 @@ public class ClipRegionTests { var driver = (IConsoleDriver)Activator.CreateInstance (driverType); Application.Init (driver); - Application.Driver!.Rows = 10; - Application.Driver!.Cols = 10; + Application.Driver!.SetScreenSize (10, 10); // positive Assert.True (driver.IsValidLocation (default, 0, 0)); diff --git a/Tests/UnitTests/ConsoleDrivers/ConsoleDriverTests.cs b/Tests/UnitTests/ConsoleDrivers/ConsoleDriverTests.cs index b77a1905a..8793b1657 100644 --- a/Tests/UnitTests/ConsoleDrivers/ConsoleDriverTests.cs +++ b/Tests/UnitTests/ConsoleDrivers/ConsoleDriverTests.cs @@ -128,8 +128,7 @@ public class ConsoleDriverTests { var driver = (IConsoleDriver)Activator.CreateInstance (driverType); driver?.Init (); - driver.Cols = 80; - driver.Rows = 25; + driver.SetScreenSize(80, 25); var wasTerminalResized = false; @@ -144,8 +143,7 @@ public class ConsoleDriverTests Assert.Equal (25, driver.Rows); Assert.False (wasTerminalResized); - driver.Cols = 120; - driver.Rows = 40; + driver.SetScreenSize(120, 40); ((ConsoleDriver)driver).OnSizeChanged (new SizeChangedEventArgs (new (driver.Cols, driver.Rows))); Assert.Equal (120, driver.Cols);