浏览代码

Fixed HexView nav unit test

Tig 10 月之前
父节点
当前提交
44259cce46

+ 2 - 2
UnitTests/Application/ApplicationTests.cs

@@ -156,7 +156,7 @@ public class ApplicationTests
     }
 
     [Fact]
-    [AutoInitShutdown]
+    [AutoInitShutdown (VerifyShutdown: true)]
     public void Begin_Sets_Application_Top_To_Console_Size ()
     {
         Assert.Null (Application.Top);
@@ -521,7 +521,7 @@ public class ApplicationTests
     }
 
     [Fact]
-    [AutoInitShutdown]
+    [AutoInitShutdown (VerifyShutdown: true)]
     public void Internal_Properties_Correct ()
     {
         Assert.True (Application.IsInitialized);

+ 10 - 1
UnitTests/TestHelpers.cs

@@ -42,13 +42,15 @@ public class AutoInitShutdownAttribute : BeforeAfterTestAttribute
     ///     <see cref="ConsoleDriver"/> == <see cref="FakeDriver"/> and <paramref name="autoInit"/> is true.
     /// </param>
     /// <param name="configLocation">Determines what config file locations <see cref="ConfigurationManager"/> will load from.</param>
+    /// <param name="VerifyShutdown">If true and <see cref="Application.IsInitialized"/> is true, the test will fail.</param>
     public AutoInitShutdownAttribute (
         bool autoInit = true,
         Type consoleDriverType = null,
         bool useFakeClipboard = true,
         bool fakeClipboardAlwaysThrowsNotSupportedException = false,
         bool fakeClipboardIsSupportedAlwaysTrue = false,
-        ConfigLocations configLocation = ConfigLocations.None
+        ConfigLocations configLocation = ConfigLocations.None,
+        bool VerifyShutdown = false
     )
     {
         AutoInit = autoInit;
@@ -60,8 +62,10 @@ public class AutoInitShutdownAttribute : BeforeAfterTestAttribute
             fakeClipboardAlwaysThrowsNotSupportedException;
         FakeDriver.FakeBehaviors.FakeClipboardIsSupportedAlwaysFalse = fakeClipboardIsSupportedAlwaysTrue;
         Locations = configLocation;
+        _verifyShutdown = VerifyShutdown;
     }
 
+    private bool _verifyShutdown;
     private readonly Type _driverType;
 
     public override void After (MethodInfo methodUnderTest)
@@ -75,6 +79,11 @@ public class AutoInitShutdownAttribute : BeforeAfterTestAttribute
         {
             // try
             {
+                if (!_verifyShutdown)
+                {
+                    Application.ResetState (ignoreDisposed: true);
+                }
+
                 Application.Shutdown ();
 #if DEBUG_IDISPOSABLE
                 if (Responder.Instances.Count == 0)

+ 6 - 0
UnitTests/View/Navigation/NavigationTests.cs

@@ -61,6 +61,12 @@ public class NavigationTests (ITestOutputHelper _output) : TestsAllViews
                 case TabBehavior.TabGroup:
                     Application.OnKeyDown (key);
 
+                    if (view.HasFocus)
+                    {
+                        // Try once more (HexView)
+                        Application.OnKeyDown (key);
+                    }
+
                     break;
                 default:
                     Application.OnKeyDown (Key.Tab);

+ 1 - 1
UnitTests/Views/TimeFieldTests.cs

@@ -36,7 +36,7 @@ public class TimeFieldTests
     }
 
     [Fact]
-    [AutoInitShutdown (useFakeClipboard:true)]
+    [AutoInitShutdown (useFakeClipboard: true)]
     public void Copy_Paste ()
     {
         var tf1 = new TimeField { Time = TimeSpan.Parse ("12:12:19") };