All unit test pass for reals?

This commit is contained in:
Tig
2024-10-06 18:24:20 -06:00
parent 39bf84472d
commit c4e8ec4a56
4 changed files with 21 additions and 21 deletions

View File

@@ -1,4 +1,5 @@
#nullable enable
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Reflection;
@@ -80,6 +81,16 @@ public static partial class Application // Initialization (Init/Shutdown)
if (driver is { })
{
Driver = driver;
if (driver is FakeDriver)
{
// We're running unit tests. Disable loading config files other than default
if (Locations == ConfigLocations.All)
{
Locations = ConfigLocations.DefaultOnly;
Reset ();
}
}
}
// Start the process of configuration management.

View File

@@ -65,7 +65,7 @@ public class AutoInitShutdownAttribute : BeforeAfterTestAttribute
_verifyShutdown = verifyShutdown;
}
private bool _verifyShutdown;
private readonly bool _verifyShutdown;
private readonly Type _driverType;
public override void After (MethodInfo methodUnderTest)
@@ -114,7 +114,7 @@ public class AutoInitShutdownAttribute : BeforeAfterTestAttribute
Reset();
// Enable subsequent tests that call Init to get all config files (the default).
Locations = ConfigLocations.All;
//Locations = ConfigLocations.All;
}
public override void Before (MethodInfo methodUnderTest)
@@ -161,9 +161,6 @@ public class TestRespondersDisposed : BeforeAfterTestAttribute
Debug.WriteLine ($"After: {methodUnderTest.Name}");
base.After (methodUnderTest);
// Reset the to default All
Locations = ConfigLocations.All;
#if DEBUG_IDISPOSABLE
Assert.Empty (Responder.Instances);
#endif
@@ -173,10 +170,6 @@ public class TestRespondersDisposed : BeforeAfterTestAttribute
{
Debug.WriteLine ($"Before: {methodUnderTest.Name}");
// Force the use of the default config file
Locations = ConfigLocations.DefaultOnly;
Reset ();
base.Before (methodUnderTest);
#if DEBUG_IDISPOSABLE
@@ -208,19 +201,12 @@ public class SetupFakeDriverAttribute : BeforeAfterTestAttribute
Application.Driver = null;
base.After (methodUnderTest);
// Reset the to default All
Locations = ConfigLocations.All;
}
public override void Before (MethodInfo methodUnderTest)
{
Debug.WriteLine ($"Before: {methodUnderTest.Name}");
// Force the use of the default config file
Locations = ConfigLocations.DefaultOnly;
Reset ();
Application.ResetState (true);
Assert.Null (Application.Driver);
Application.Driver = new FakeDriver { Rows = 25, Cols = 25 };

View File

@@ -1318,6 +1318,9 @@ public class TabViewTests (ITestOutputHelper output)
private void InitFakeDriver ()
{
ConfigurationManager.Locations = ConfigurationManager.ConfigLocations.DefaultOnly;
ConfigurationManager.Reset ();
var driver = new FakeDriver ();
Application.Init (driver);
driver.Init ();

View File

@@ -54,7 +54,7 @@ public class TableViewTests (ITestOutputHelper output)
}
[Fact]
[AutoInitShutdown]
[AutoInitShutdown (configLocation: ConfigurationManager.ConfigLocations.DefaultOnly)]
public void CellEventsBackgroundFill ()
{
var tv = new TableView { Width = 20, Height = 4 };
@@ -412,7 +412,7 @@ public class TableViewTests (ITestOutputHelper output)
}
[Fact]
[AutoInitShutdown]
[AutoInitShutdown (configLocation: ConfigurationManager.ConfigLocations.DefaultOnly)]
public void LongColumnTest ()
{
var tableView = new TableView ();
@@ -602,7 +602,7 @@ public class TableViewTests (ITestOutputHelper output)
top.Dispose ();
}
[AutoInitShutdown]
[AutoInitShutdown (configLocation: ConfigurationManager.ConfigLocations.DefaultOnly)]
[Fact]
public void PageDown_ExcludesHeaders ()
{
@@ -1000,7 +1000,7 @@ public class TableViewTests (ITestOutputHelper output)
}
[Fact]
[AutoInitShutdown]
[AutoInitShutdown (configLocation: ConfigurationManager.ConfigLocations.DefaultOnly)]
public void TableView_Activate ()
{
string activatedValue = null;
@@ -1566,7 +1566,7 @@ public class TableViewTests (ITestOutputHelper output)
}
[Fact]
[AutoInitShutdown]
[AutoInitShutdown (configLocation: ConfigurationManager.ConfigLocations.DefaultOnly)]
public void Test_CollectionNavigator ()
{
var tv = new TableView ();