mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2025-12-30 09:47:58 +01:00
Refactor tests to decouple from global Application state
Commented out `driver ??= Application.Driver` assignments in `DriverAssert` to prevent automatic global driver assignment. Removed `Application.ResetState(true)` calls and commented out state validation assertions in `GlobalTestSetup` to reduce dependency on global state. Reintroduced `ApplicationForceDriverTests` and `ApplicationModelFencingTests` to validate `ForceDriver` behavior and ensure proper handling of legacy and modern Application models. Skipped certain `ToAnsiTests` that rely on `Application`. Removed direct `Application.Driver` assignments in `ViewDrawingClippingTests` and `ViewDrawingFlowTests`. Performed general cleanup of redundant code and unused imports to simplify the codebase.
This commit is contained in:
@@ -65,23 +65,18 @@ public class ViewDrawingClippingTests () : FakeDriverBase
|
||||
|
||||
Assert.Equal (original, previous);
|
||||
Assert.NotEqual (original, driver.Clip);
|
||||
|
||||
Application.ResetState (true);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SetClipToScreen_SetsClipToScreen ()
|
||||
{
|
||||
IDriver driver = CreateFakeDriver (80, 25);
|
||||
Application.Driver = driver;
|
||||
View view = new () { Driver = driver };
|
||||
|
||||
view.SetClipToScreen ();
|
||||
|
||||
Assert.NotNull (driver.Clip);
|
||||
Assert.Equal (driver.Screen, driver.Clip.GetBounds ());
|
||||
|
||||
Application.ResetState (true);
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -94,8 +89,6 @@ public class ViewDrawingClippingTests () : FakeDriverBase
|
||||
View view = new () { Driver = null };
|
||||
var exception = Record.Exception (() => view.ExcludeFromClip (new Rectangle (5, 5, 10, 10)));
|
||||
Assert.Null (exception);
|
||||
|
||||
Application.ResetState (true);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -103,7 +96,6 @@ public class ViewDrawingClippingTests () : FakeDriverBase
|
||||
{
|
||||
IDriver driver = CreateFakeDriver (80, 25);
|
||||
driver.Clip = new Region (new Rectangle (0, 0, 80, 25));
|
||||
Application.Driver = driver;
|
||||
View view = new () { Driver = driver };
|
||||
|
||||
var toExclude = new Rectangle (10, 10, 20, 20);
|
||||
@@ -112,8 +104,6 @@ public class ViewDrawingClippingTests () : FakeDriverBase
|
||||
// Verify the region was excluded
|
||||
Assert.NotNull (driver.Clip);
|
||||
Assert.False (driver.Clip.Contains (15, 15));
|
||||
|
||||
Application.ResetState (true);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -123,8 +113,6 @@ public class ViewDrawingClippingTests () : FakeDriverBase
|
||||
|
||||
var exception = Record.Exception (() => view.ExcludeFromClip (new Region (new Rectangle (5, 5, 10, 10))));
|
||||
Assert.Null (exception);
|
||||
|
||||
Application.ResetState (true);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -141,8 +129,6 @@ public class ViewDrawingClippingTests () : FakeDriverBase
|
||||
// Verify the region was excluded
|
||||
Assert.NotNull (driver.Clip);
|
||||
Assert.False (driver.Clip.Contains (15, 15));
|
||||
|
||||
Application.ResetState (true);
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -538,7 +524,6 @@ public class ViewDrawingClippingTests () : FakeDriverBase
|
||||
{
|
||||
IDriver driver = CreateFakeDriver (80, 25);
|
||||
driver.Clip = new Region (driver.Screen);
|
||||
Application.Driver = driver;
|
||||
|
||||
var view = new View
|
||||
{
|
||||
@@ -558,7 +543,6 @@ public class ViewDrawingClippingTests () : FakeDriverBase
|
||||
Assert.NotNull (driver.Clip);
|
||||
Assert.False (driver.Clip.Contains (20, 20)); // Point inside excluded rect should not be in clip
|
||||
|
||||
Application.ResetState (true);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -566,7 +550,6 @@ public class ViewDrawingClippingTests () : FakeDriverBase
|
||||
{
|
||||
IDriver driver = CreateFakeDriver (80, 25);
|
||||
driver.Clip = null!;
|
||||
Application.Driver = driver;
|
||||
|
||||
var view = new View
|
||||
{
|
||||
@@ -581,7 +564,6 @@ public class ViewDrawingClippingTests () : FakeDriverBase
|
||||
|
||||
Assert.Null (exception);
|
||||
|
||||
Application.ResetState (true);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -613,7 +613,6 @@ public class ViewDrawingFlowTests () : FakeDriverBase
|
||||
IDriver driver = CreateFakeDriver (80, 25);
|
||||
var initialClip = new Region (driver.Screen);
|
||||
driver.Clip = initialClip;
|
||||
Application.Driver = driver;
|
||||
|
||||
var view = new View
|
||||
{
|
||||
@@ -636,8 +635,6 @@ public class ViewDrawingFlowTests () : FakeDriverBase
|
||||
// Points inside the view should be excluded
|
||||
// Note: This test depends on the DrawContext tracking, which may not exclude if nothing was actually drawn
|
||||
// We're verifying the mechanism exists, not that it necessarily excludes in this specific case
|
||||
|
||||
Application.ResetState (true);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
Reference in New Issue
Block a user