fixed unit tests

This commit is contained in:
Charlie Kindel
2022-11-05 11:46:22 -06:00
parent 9c06eb2547
commit 8a73ade5b2
2 changed files with 8 additions and 7 deletions

View File

@@ -1279,6 +1279,9 @@ namespace Terminal.Gui {
// Run() will eventually cause Application.Top to be set, via Begin() and SetCurrentAsTop()
Run (top, errorHandler);
} else {
if (!_initialized && driver == null) {
throw new ArgumentException ("Init has not been called; a valid driver and mainloop must be provided");
}
// Note in this case, we don't verify the type of the Toplevel created by new T().
Init (() => new T (), Driver == null ? driver : Driver, Driver == null ? mainLoopDriver : null, resetState: false);
Run (Top, errorHandler);

View File

@@ -257,7 +257,7 @@ namespace Terminal.Gui.Core {
Application.RequestStop ();
};
// Run<TestToplevel> when already initialized with a Driver will work
// Init has been called and we're passing no driver to Run<TestTopLevel>. This is ok.
Application.Run<TestToplevel> (errorHandler: null);
Shutdown ();
@@ -268,15 +268,14 @@ namespace Terminal.Gui.Core {
}
[Fact]
public void Run_T_NoInit_ThrowsInDefaultDriver ()
public void Run_T_NoInit_Throws ()
{
Application.Iteration = () => {
Application.RequestStop ();
};
// Note that Init has NOT been called and we're passing no driver
// The platform-default driver will be selected and it will barf
Assert.ThrowsAny<Exception> (() => Application.Run<TestToplevel> (errorHandler: null, driver: null, mainLoopDriver: null));
// Init has NOT been called and we're passing no driver to Run<TestToplevel>. This is an error.
Assert.Throws<ArgumentException> (() => Application.Run<TestToplevel> (errorHandler: null, driver: null, mainLoopDriver: null));
Shutdown ();
@@ -292,8 +291,7 @@ namespace Terminal.Gui.Core {
Application.RequestStop ();
};
// Note that Init has NOT been called and we're passing no driver
// The platform-default driver will be selected and it will barf
// Init has NOT been called and we're passing a valid driver to Run<TestTopLevel>. This is ok.
Application.Run<TestToplevel> (errorHandler: null, new FakeDriver (), new FakeMainLoop (() => FakeConsole.ReadKey (true)));
Shutdown ();