|
@@ -194,16 +194,19 @@ public class ApplicationImplBeginEndTests
|
|
|
SessionToken token2 = app.Begin (toplevel2);
|
|
SessionToken token2 = app.Begin (toplevel2);
|
|
|
|
|
|
|
|
// Trying to end token1 when token2 is on top should throw
|
|
// Trying to end token1 when token2 is on top should throw
|
|
|
|
|
+ // NOTE: This throws but has the side effect of popping token2 from the stack
|
|
|
Assert.Throws<ArgumentException> (() => app.End (token1));
|
|
Assert.Throws<ArgumentException> (() => app.End (token1));
|
|
|
|
|
|
|
|
- // Cleanup
|
|
|
|
|
- app.End (token2);
|
|
|
|
|
- app.End (token1);
|
|
|
|
|
|
|
+ // Don't try to clean up with more End calls - the state is now inconsistent
|
|
|
|
|
+ // Let Shutdown/ResetState handle cleanup
|
|
|
}
|
|
}
|
|
|
finally
|
|
finally
|
|
|
{
|
|
{
|
|
|
|
|
+ // Dispose toplevels BEFORE Shutdown to satisfy DEBUG_IDISPOSABLE assertions
|
|
|
toplevel1?.Dispose ();
|
|
toplevel1?.Dispose ();
|
|
|
toplevel2?.Dispose ();
|
|
toplevel2?.Dispose ();
|
|
|
|
|
+
|
|
|
|
|
+ // Shutdown will call ResetState which clears any remaining state
|
|
|
app.Shutdown ();
|
|
app.Shutdown ();
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -357,18 +360,20 @@ public class ApplicationImplBeginEndTests
|
|
|
|
|
|
|
|
Assert.Equal (2, app.SessionStack.Count);
|
|
Assert.Equal (2, app.SessionStack.Count);
|
|
|
Assert.NotNull (app.Current);
|
|
Assert.NotNull (app.Current);
|
|
|
-
|
|
|
|
|
- app.ResetState ();
|
|
|
|
|
-
|
|
|
|
|
- Assert.Empty (app.SessionStack);
|
|
|
|
|
- Assert.Null (app.Current);
|
|
|
|
|
- Assert.Null (app.CachedSessionTokenToplevel);
|
|
|
|
|
}
|
|
}
|
|
|
finally
|
|
finally
|
|
|
{
|
|
{
|
|
|
|
|
+ // Dispose toplevels BEFORE Shutdown to satisfy DEBUG_IDISPOSABLE assertions
|
|
|
toplevel1?.Dispose ();
|
|
toplevel1?.Dispose ();
|
|
|
toplevel2?.Dispose ();
|
|
toplevel2?.Dispose ();
|
|
|
|
|
+
|
|
|
|
|
+ // Shutdown calls ResetState, which will clear SessionStack and set Current to null
|
|
|
app.Shutdown ();
|
|
app.Shutdown ();
|
|
|
|
|
+
|
|
|
|
|
+ // Verify cleanup happened
|
|
|
|
|
+ Assert.Empty (app.SessionStack);
|
|
|
|
|
+ Assert.Null (app.Current);
|
|
|
|
|
+ Assert.Null (app.CachedSessionTokenToplevel);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -389,17 +394,19 @@ public class ApplicationImplBeginEndTests
|
|
|
|
|
|
|
|
Assert.True (toplevel1.Running);
|
|
Assert.True (toplevel1.Running);
|
|
|
Assert.True (toplevel2.Running);
|
|
Assert.True (toplevel2.Running);
|
|
|
-
|
|
|
|
|
- app.ResetState ();
|
|
|
|
|
-
|
|
|
|
|
- Assert.False (toplevel1.Running);
|
|
|
|
|
- Assert.False (toplevel2.Running);
|
|
|
|
|
}
|
|
}
|
|
|
finally
|
|
finally
|
|
|
{
|
|
{
|
|
|
|
|
+ // Dispose toplevels BEFORE Shutdown to satisfy DEBUG_IDISPOSABLE assertions
|
|
|
toplevel1?.Dispose ();
|
|
toplevel1?.Dispose ();
|
|
|
toplevel2?.Dispose ();
|
|
toplevel2?.Dispose ();
|
|
|
|
|
+
|
|
|
|
|
+ // Shutdown calls ResetState, which will stop all running toplevels
|
|
|
app.Shutdown ();
|
|
app.Shutdown ();
|
|
|
|
|
+
|
|
|
|
|
+ // Verify toplevels were stopped
|
|
|
|
|
+ Assert.False (toplevel1!.Running);
|
|
|
|
|
+ Assert.False (toplevel2!.Running);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|