Fixed some unit tests. Prepared for Issue #3368

This commit is contained in:
Tig
2024-04-01 11:22:27 -06:00
parent ca5df086ad
commit cf97b5b708
4 changed files with 12 additions and 0 deletions

View File

@@ -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);
}
}

View File

@@ -68,6 +68,7 @@ public class DimTests
top.Add (win);
Application.Run (top);
top.Dispose ();
Assert.Equal (20, count);
}

View File

@@ -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]

View File

@@ -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>