mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2026-01-01 16:59:35 +01:00
* Fixes #2923. Ensures only clear Instances if they really was disposed and fix unit tests. * Add Ubuntu-20.04. * xunit nuget package update.
This commit is contained in:
@@ -62,10 +62,13 @@ public class AutoInitShutdownAttribute : Xunit.Sdk.BeforeAfterTestAttribute {
|
||||
{
|
||||
Debug.WriteLine ($"Before: {methodUnderTest.Name}");
|
||||
if (AutoInit) {
|
||||
#if DEBUG_IDISPOSABLE && FORCE_RESPONDER_DISPOSE
|
||||
#if DEBUG_IDISPOSABLE
|
||||
// Clear out any lingering Responder instances from previous tests
|
||||
Responder.Instances.Clear ();
|
||||
Assert.Equal (0, Responder.Instances.Count);
|
||||
if (Responder.Instances.Count == 0) {
|
||||
Assert.Empty (Responder.Instances);
|
||||
} else {
|
||||
Responder.Instances.Clear ();
|
||||
}
|
||||
#endif
|
||||
Application.Init ((ConsoleDriver)Activator.CreateInstance (_driverType));
|
||||
}
|
||||
@@ -76,8 +79,12 @@ public class AutoInitShutdownAttribute : Xunit.Sdk.BeforeAfterTestAttribute {
|
||||
Debug.WriteLine ($"After: {methodUnderTest.Name}");
|
||||
if (AutoInit) {
|
||||
Application.Shutdown ();
|
||||
#if DEBUG_IDISPOSABLE && FORCE_RESPONDER_DISPOSE
|
||||
Assert.Equal (0, Responder.Instances.Count);
|
||||
#if DEBUG_IDISPOSABLE
|
||||
if (Responder.Instances.Count == 0) {
|
||||
Assert.Empty (Responder.Instances);
|
||||
} else {
|
||||
Responder.Instances.Clear ();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -104,9 +111,7 @@ public class TestRespondersDisposed : Xunit.Sdk.BeforeAfterTestAttribute {
|
||||
{
|
||||
Debug.WriteLine ($"After: {methodUnderTest.Name}");
|
||||
#if DEBUG_IDISPOSABLE
|
||||
#pragma warning disable xUnit2013 // Do not use equality check to check for collection size.
|
||||
Assert.Equal (0, Responder.Instances.Count);
|
||||
#pragma warning restore xUnit2013 // Do not use equality check to check for collection size.
|
||||
Assert.Empty (Responder.Instances);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user