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