mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2025-12-27 00:07:58 +01:00
fixed unit tests
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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 ();
|
||||
|
||||
Reference in New Issue
Block a user