mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2026-01-01 16:59:35 +01:00
Fixed some unit tests. Prepared for Issue #3368
This commit is contained in:
@@ -123,6 +123,8 @@ public class TestRespondersDisposed : BeforeAfterTestAttribute
|
||||
public override void After (MethodInfo methodUnderTest)
|
||||
{
|
||||
Debug.WriteLine ($"After: {methodUnderTest.Name}");
|
||||
base.After (methodUnderTest);
|
||||
|
||||
#if DEBUG_IDISPOSABLE
|
||||
Assert.Empty (Responder.Instances);
|
||||
#endif
|
||||
@@ -131,6 +133,7 @@ public class TestRespondersDisposed : BeforeAfterTestAttribute
|
||||
public override void Before (MethodInfo methodUnderTest)
|
||||
{
|
||||
Debug.WriteLine ($"Before: {methodUnderTest.Name}");
|
||||
base.Before (methodUnderTest);
|
||||
#if DEBUG_IDISPOSABLE
|
||||
|
||||
// Clear out any lingering Responder instances from previous tests
|
||||
@@ -140,6 +143,7 @@ public class TestRespondersDisposed : BeforeAfterTestAttribute
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Make this inherit from TestRespondersDisposed so that all tests that don't dispose Views correctly can be identified and fixed
|
||||
[AttributeUsage (AttributeTargets.Class | AttributeTargets.Method)]
|
||||
public class SetupFakeDriverAttribute : BeforeAfterTestAttribute
|
||||
{
|
||||
@@ -157,6 +161,7 @@ public class SetupFakeDriverAttribute : BeforeAfterTestAttribute
|
||||
View.Diagnostics = ViewDiagnosticFlags.Off;
|
||||
|
||||
Application.Driver = null;
|
||||
base.After (methodUnderTest);
|
||||
}
|
||||
|
||||
public override void Before (MethodInfo methodUnderTest)
|
||||
@@ -164,6 +169,7 @@ public class SetupFakeDriverAttribute : BeforeAfterTestAttribute
|
||||
Debug.WriteLine ($"Before: {methodUnderTest.Name}");
|
||||
Assert.Null (Application.Driver);
|
||||
Application.Driver = new FakeDriver { Rows = 25, Cols = 25 };
|
||||
base.Before (methodUnderTest);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -68,6 +68,7 @@ public class DimTests
|
||||
top.Add (win);
|
||||
|
||||
Application.Run (top);
|
||||
top.Dispose ();
|
||||
|
||||
Assert.Equal (20, count);
|
||||
}
|
||||
|
||||
@@ -70,6 +70,7 @@ public class ViewTests
|
||||
";
|
||||
|
||||
pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, _output);
|
||||
top.Dispose ();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -133,6 +134,8 @@ public class ViewTests
|
||||
";
|
||||
|
||||
pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, _output);
|
||||
|
||||
top.Dispose ();
|
||||
}
|
||||
|
||||
[Theory]
|
||||
|
||||
@@ -172,6 +172,7 @@ public class ButtonTests
|
||||
";
|
||||
|
||||
TestHelpers.AssertDriverContentsWithFrameAre (expected, _output);
|
||||
top.Dispose ();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -547,6 +548,7 @@ public class ButtonTests
|
||||
btn.HotKey = KeyCode.E;
|
||||
Assert.True (btn.NewKeyDownEvent (Key.E.WithAlt));
|
||||
Assert.True (clicked);
|
||||
top.Dispose ();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user