Quellcode durchsuchen

Fixed some unit tests. Prepared for Issue #3368

Tig vor 1 Jahr
Ursprung
Commit
327957a060

+ 6 - 0
UnitTests/TestHelpers.cs

@@ -122,6 +122,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
@@ -130,6 +132,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
@@ -139,6 +142,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
 {
@@ -156,6 +160,7 @@ public class SetupFakeDriverAttribute : BeforeAfterTestAttribute
         View.Diagnostics = ViewDiagnosticFlags.Off;
 
         Application.Driver = null;
+        base.After (methodUnderTest);
     }
 
     public override void Before (MethodInfo methodUnderTest)
@@ -163,6 +168,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);
     }
 }
 

+ 1 - 0
UnitTests/View/Layout/DimTests.cs

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

+ 3 - 0
UnitTests/View/ViewTests.cs

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

+ 2 - 0
UnitTests/Views/ButtonTests.cs

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