From d6f9e0a832989c9e63dee9dcd3eead2b9ab4dd74 Mon Sep 17 00:00:00 2001 From: BDisp Date: Fri, 17 Jul 2020 03:53:22 +0100 Subject: [PATCH] Fixed more unit tests. --- Terminal.Gui/Core/Application.cs | 2 +- UnitTests/ConsoleDriverTests.cs | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Terminal.Gui/Core/Application.cs b/Terminal.Gui/Core/Application.cs index a24e9c79d..35b4a91a7 100644 --- a/Terminal.Gui/Core/Application.cs +++ b/Terminal.Gui/Core/Application.cs @@ -166,7 +166,7 @@ namespace Terminal.Gui { /// static void Init (Func topLevelFactory, ConsoleDriver driver = null, IMainLoopDriver mainLoopDriver = null) { - if (_initialized) return; + if (_initialized && driver == null) return; // This supports Unit Tests and the passing of a mock driver/loopdriver if (driver != null) { diff --git a/UnitTests/ConsoleDriverTests.cs b/UnitTests/ConsoleDriverTests.cs index d551d2fc3..05d94bab5 100644 --- a/UnitTests/ConsoleDriverTests.cs +++ b/UnitTests/ConsoleDriverTests.cs @@ -11,6 +11,7 @@ namespace Terminal.Gui { public void Init_Inits () { var driver = new FakeDriver (); + Application.Init (driver, new NetMainLoop (() => FakeConsole.ReadKey (true))); driver.Init (() => { }); Assert.Equal (80, Console.BufferWidth); @@ -26,6 +27,7 @@ namespace Terminal.Gui { public void End_Cleans_Up () { var driver = new FakeDriver (); + Application.Init (driver, new NetMainLoop (() => FakeConsole.ReadKey (true))); driver.Init (() => { }); FakeConsole.ForegroundColor = ConsoleColor.Red; @@ -48,6 +50,7 @@ namespace Terminal.Gui { public void SetColors_Changes_Colors () { var driver = new FakeDriver (); + Application.Init (driver, new NetMainLoop (() => FakeConsole.ReadKey (true))); driver.Init (() => { }); Assert.Equal (ConsoleColor.Gray, Console.ForegroundColor); Assert.Equal (ConsoleColor.Black, Console.BackgroundColor);