diff --git a/UnitTests/ApplicationTests.cs b/UnitTests/Application/ApplicationTests.cs similarity index 99% rename from UnitTests/ApplicationTests.cs rename to UnitTests/Application/ApplicationTests.cs index b9bc4101cf..b7ef1d8dbd 100644 --- a/UnitTests/ApplicationTests.cs +++ b/UnitTests/Application/ApplicationTests.cs @@ -9,7 +9,7 @@ // Alias Console to MockConsole so we don't accidentally use Console using Console = Terminal.Gui.FakeConsole; -namespace Terminal.Gui.Core { +namespace Terminal.Gui.ApplicationTests { public class ApplicationTests { public ApplicationTests () { diff --git a/UnitTests/MainLoopTests.cs b/UnitTests/Application/MainLoopTests.cs similarity index 92% rename from UnitTests/MainLoopTests.cs rename to UnitTests/Application/MainLoopTests.cs index b66497b9eb..46a0a9b329 100644 --- a/UnitTests/MainLoopTests.cs +++ b/UnitTests/Application/MainLoopTests.cs @@ -13,7 +13,7 @@ // Alias Console to MockConsole so we don't accidentally use Console using Console = Terminal.Gui.FakeConsole; -namespace Terminal.Gui.Core { +namespace Terminal.Gui.ApplicationTests { /// /// Tests MainLoop using the FakeMainLoop. /// @@ -171,9 +171,7 @@ public void False_Idle_Stops_It_Being_Called_Again () var functionCalled = 0; Func fn1 = () => { functionCalled++; - if (functionCalled == 10) { - return false; - } + if (functionCalled == 10) return false; return true; }; @@ -181,9 +179,7 @@ public void False_Idle_Stops_It_Being_Called_Again () var stopCount = 0; Func fnStop = () => { stopCount++; - if (stopCount == 20) { - ml.Stop (); - } + if (stopCount == 20) ml.Stop (); return true; }; @@ -212,9 +208,7 @@ public void AddIdle_Twice_Returns_False_Called_Twice () var stopCount = 0; Func fnStop = () => { stopCount++; - if (stopCount == 10) { - ml.Stop (); - } + if (stopCount == 10) ml.Stop (); return true; }; @@ -237,9 +231,7 @@ public void Run_Runs_Idle_Stop_Stops_Idle () var functionCalled = 0; Func fn = () => { functionCalled++; - if (functionCalled == 10) { - ml.Stop (); - } + if (functionCalled == 10) ml.Stop (); return true; }; @@ -258,7 +250,7 @@ public void AddTimer_Adds_Removes_NoFaults () var ms = 100; var callbackCount = 0; - Func callback = (MainLoop loop) => { + Func callback = (loop) => { callbackCount++; return true; }; @@ -279,7 +271,7 @@ public void AddTimer_Run_Called () var ms = 100; var callbackCount = 0; - Func callback = (MainLoop loop) => { + Func callback = (loop) => { callbackCount++; ml.Stop (); return true; @@ -300,11 +292,9 @@ public async Task AddTimer_Duplicate_Keys_Not_Allowed () object token1 = null, token2 = null; var callbackCount = 0; - Func callback = (MainLoop loop) => { + Func callback = (loop) => { callbackCount++; - if (callbackCount == 2) { - ml.Stop (); - } + if (callbackCount == 2) ml.Stop (); return true; }; @@ -332,11 +322,9 @@ public void AddTimer_In_Parallel_Wont_Throw () object token1 = null, token2 = null; var callbackCount = 0; - Func callback = (MainLoop loop) => { + Func callback = (loop) => { callbackCount++; - if (callbackCount == 2) { - ml.Stop (); - } + if (callbackCount == 2) ml.Stop (); return true; }; @@ -369,7 +357,7 @@ public void AddTimer_Run_CalledAtApproximatelyRightTime () var watch = new System.Diagnostics.Stopwatch (); var callbackCount = 0; - Func callback = (MainLoop loop) => { + Func callback = (loop) => { watch.Stop (); callbackCount++; ml.Stop (); @@ -381,7 +369,7 @@ public void AddTimer_Run_CalledAtApproximatelyRightTime () ml.Run (); // +/- 100ms should be good enuf // https://github.com/xunit/assert.xunit/pull/25 - Assert.Equal (ms * callbackCount, watch.Elapsed, new MillisecondTolerance (100)); + Assert.Equal (ms * callbackCount, watch.Elapsed, new MillisecondTolerance (100)); Assert.True (ml.RemoveTimeout (token)); Assert.Equal (1, callbackCount); @@ -395,7 +383,7 @@ public void AddTimer_Run_CalledTwiceApproximatelyRightTime () var watch = new System.Diagnostics.Stopwatch (); var callbackCount = 0; - Func callback = (MainLoop loop) => { + Func callback = (loop) => { callbackCount++; if (callbackCount == 2) { watch.Stop (); @@ -409,7 +397,7 @@ public void AddTimer_Run_CalledTwiceApproximatelyRightTime () ml.Run (); // +/- 100ms should be good enuf // https://github.com/xunit/assert.xunit/pull/25 - Assert.Equal (ms * callbackCount, watch.Elapsed, new MillisecondTolerance (100)); + Assert.Equal (ms * callbackCount, watch.Elapsed, new MillisecondTolerance (100)); Assert.True (ml.RemoveTimeout (token)); Assert.Equal (2, callbackCount); @@ -425,15 +413,13 @@ public void AddTimer_Remove_NotCalled () var stopCount = 0; Func fnStop = () => { stopCount++; - if (stopCount == 10) { - ml.Stop (); - } + if (stopCount == 10) ml.Stop (); return true; }; ml.AddIdle (fnStop); var callbackCount = 0; - Func callback = (MainLoop loop) => { + Func callback = (loop) => { callbackCount++; return true; }; @@ -455,15 +441,13 @@ public void AddTimer_ReturnFalse_StopsBeingCalled () Func fnStop = () => { Thread.Sleep (10); // Sleep to enable timer to fire stopCount++; - if (stopCount == 10) { - ml.Stop (); - } + if (stopCount == 10) ml.Stop (); return true; }; ml.AddIdle (fnStop); var callbackCount = 0; - Func callback = (MainLoop loop) => { + Func callback = (loop) => { callbackCount++; return false; }; @@ -541,10 +525,8 @@ private static void Launch (Random r, TextField tf, int target) Application.MainLoop.Invoke (() => { tf.Text = $"index{r.Next ()}"; Interlocked.Increment (ref tbCounter); - if (target == tbCounter) { - // On last increment wake up the check + if (target == tbCounter) // On last increment wake up the check _wakeUp.Set (); - } }); }); } @@ -554,9 +536,7 @@ private static void RunTest (Random r, TextField tf, int numPasses, int numIncre for (int j = 0; j < numPasses; j++) { _wakeUp.Reset (); - for (var i = 0; i < numIncrements; i++) { - Launch (r, tf, (j + 1) * numIncrements); - } + for (var i = 0; i < numIncrements; i++) Launch (r, tf, (j + 1) * numIncrements); while (tbCounter != (j + 1) * numIncrements) // Wait for tbCounter to reach expected value @@ -594,7 +574,7 @@ public async Task InvokeLeakTest () await task; // Propagate exception if any occurred - Assert.Equal ((numIncrements * numPasses), tbCounter); + Assert.Equal (numIncrements * numPasses, tbCounter); } private static int total; @@ -652,9 +632,7 @@ public void Mainloop_Invoke_Or_AddIdle_Can_Be_Used_For_Events_Or_Actions (Action Assert.True (btn.ProcessKey (new KeyEvent (Key.Enter, null))); Assert.Equal (cancel, btn.Text); Assert.Equal (one, total); - } else if (taskCompleted) { - Application.RequestStop (); - } + } else if (taskCompleted) Application.RequestStop (); }; Application.Run (); diff --git a/UnitTests/RunStateTests.cs b/UnitTests/Application/RunStateTests.cs similarity index 94% rename from UnitTests/RunStateTests.cs rename to UnitTests/Application/RunStateTests.cs index 501525ecd7..ffae6abba5 100644 --- a/UnitTests/RunStateTests.cs +++ b/UnitTests/Application/RunStateTests.cs @@ -3,12 +3,13 @@ using System.Linq; using System.Threading; using System.Threading.Tasks; +using Terminal.Gui; using Xunit; // Alias Console to MockConsole so we don't accidentally use Console using Console = Terminal.Gui.FakeConsole; -namespace Terminal.Gui.Core { +namespace Terminal.Gui.ApplicationTests { /// /// These tests focus on Application.RunState and the various ways it can be changed. /// @@ -26,7 +27,7 @@ public void New_Creates_RunState () { var rs = new Application.RunState (null); Assert.Null (rs.Toplevel); - + var top = new Toplevel (); rs = new Application.RunState (top); Assert.Equal (top, rs.Toplevel); @@ -72,9 +73,7 @@ void Shutdown () Application.Shutdown (); #if DEBUG_IDISPOSABLE // Validate there are no outstanding RunState-based instances left - foreach (var inst in Application.RunState.Instances) { - Assert.True (inst.WasDisposed); - } + foreach (var inst in Application.RunState.Instances) Assert.True (inst.WasDisposed); #endif } diff --git a/UnitTests/StackExtensionsTests.cs b/UnitTests/Application/StackExtensionsTests.cs similarity index 99% rename from UnitTests/StackExtensionsTests.cs rename to UnitTests/Application/StackExtensionsTests.cs index fb61b1334d..fd52b4bb91 100644 --- a/UnitTests/StackExtensionsTests.cs +++ b/UnitTests/Application/StackExtensionsTests.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using Xunit; -namespace Terminal.Gui.Core { +namespace Terminal.Gui.ApplicationTests { public class StackExtensionsTests { [Fact] public void Stack_Toplevels_CreateToplevels () diff --git a/UnitTests/SynchronizatonContextTests.cs b/UnitTests/Application/SynchronizatonContextTests.cs similarity index 97% rename from UnitTests/SynchronizatonContextTests.cs rename to UnitTests/Application/SynchronizatonContextTests.cs index fe492c386e..c40682356c 100644 --- a/UnitTests/SynchronizatonContextTests.cs +++ b/UnitTests/Application/SynchronizatonContextTests.cs @@ -13,7 +13,7 @@ // Alias Console to MockConsole so we don't accidentally use Console using Console = Terminal.Gui.FakeConsole; -namespace Terminal.Gui.Core { +namespace Terminal.Gui.ApplicationTests { public class SyncrhonizationContextTests { [Fact, AutoInitShutdown] diff --git a/UnitTests/BorderTests.cs b/UnitTests/Core/BorderTests.cs similarity index 99% rename from UnitTests/BorderTests.cs rename to UnitTests/Core/BorderTests.cs index 860b0ebfa4..b8c330eb36 100644 --- a/UnitTests/BorderTests.cs +++ b/UnitTests/Core/BorderTests.cs @@ -6,7 +6,7 @@ using Xunit; using Rune = System.Rune; -namespace Terminal.Gui.Core { +namespace Terminal.Gui.CoreTests { public class BorderTests { [Fact] [AutoInitShutdown] diff --git a/UnitTests/ResponderTests.cs b/UnitTests/Core/ResponderTests.cs similarity index 95% rename from UnitTests/ResponderTests.cs rename to UnitTests/Core/ResponderTests.cs index 3b21a9af78..fdd59226bb 100644 --- a/UnitTests/ResponderTests.cs +++ b/UnitTests/Core/ResponderTests.cs @@ -1,14 +1,9 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using Terminal.Gui; using Xunit; -using static Terminal.Gui.Core.ViewTests; // Alias Console to MockConsole so we don't accidentally use Console using Console = Terminal.Gui.FakeConsole; -namespace Terminal.Gui.Core { +namespace Terminal.Gui.CoreTests { public class ResponderTests { [Fact] public void New_Initializes () diff --git a/UnitTests/AttributeTests.cs b/UnitTests/Drivers/AttributeTests.cs similarity index 98% rename from UnitTests/AttributeTests.cs rename to UnitTests/Drivers/AttributeTests.cs index 2b2684e211..ddc7b4695c 100644 --- a/UnitTests/AttributeTests.cs +++ b/UnitTests/Drivers/AttributeTests.cs @@ -7,7 +7,7 @@ // Alias Console to MockConsole so we don't accidentally use Console using Console = Terminal.Gui.FakeConsole; -namespace Terminal.Gui.ConsoleDrivers { +namespace Terminal.Gui.DriverTests { public class AttributeTests { [Fact] public void Constuctors_Constuct () diff --git a/UnitTests/ClipboardTests.cs b/UnitTests/Drivers/ClipboardTests.cs similarity index 93% rename from UnitTests/ClipboardTests.cs rename to UnitTests/Drivers/ClipboardTests.cs index 6cbb6302c7..fa96f0961c 100644 --- a/UnitTests/ClipboardTests.cs +++ b/UnitTests/Drivers/ClipboardTests.cs @@ -1,11 +1,12 @@ using System; using System.Diagnostics; using System.Runtime.InteropServices; +using Terminal.Gui; using Xunit; using Xunit.Abstractions; using static AutoInitShutdownAttribute; -namespace Terminal.Gui.ConsoleDrivers { +namespace Terminal.Gui.DriverTests { public class ClipboardTests { readonly ITestOutputHelper output; @@ -101,11 +102,8 @@ public void Contents_Fake_Gets_Sets_When_IsSupportedFalse () [Fact, AutoInitShutdown (useFakeClipboard: false)] public void IsSupported_Get () { - if (Clipboard.IsSupported) { - Assert.True (Clipboard.IsSupported); - } else { - Assert.False (Clipboard.IsSupported); - } + if (Clipboard.IsSupported) Assert.True (Clipboard.IsSupported); +else Assert.False (Clipboard.IsSupported); } [Fact, AutoInitShutdown (useFakeClipboard: false)] @@ -131,21 +129,15 @@ public void TryGetClipboardData_Gets_From_OS_Clipboard () public void TrySetClipboardData_Sets_The_OS_Clipboard () { var clipText = "The TrySetClipboardData_Sets_The_OS_Clipboard unit test pasted this to the OS clipboard."; - if (Clipboard.IsSupported) { - Assert.True (Clipboard.TrySetClipboardData (clipText)); - } else { - Assert.False (Clipboard.TrySetClipboardData (clipText)); - } + if (Clipboard.IsSupported) Assert.True (Clipboard.TrySetClipboardData (clipText)); +else Assert.False (Clipboard.TrySetClipboardData (clipText)); Application.Iteration += () => Application.RequestStop (); Application.Run (); - if (Clipboard.IsSupported) { - Assert.Equal (clipText, Clipboard.Contents); - } else { - Assert.NotEqual (clipText, Clipboard.Contents); - } + if (Clipboard.IsSupported) Assert.Equal (clipText, Clipboard.Contents); +else Assert.NotEqual (clipText, Clipboard.Contents); } @@ -217,9 +209,7 @@ public void Contents_Copies_From_OS_Clipboard () Application.Run (); - if (!failed) { - Assert.Equal (clipText, getClipText); - } + if (!failed) Assert.Equal (clipText, getClipText); } [Fact, AutoInitShutdown (useFakeClipboard: false)] @@ -275,9 +265,7 @@ public void Contents_Pastes_To_OS_Clipboard () Application.Run (); - if (!failed) { - Assert.Equal (clipText, clipReadText.TrimEnd ()); - } + if (!failed) Assert.Equal (clipText, clipReadText.TrimEnd ()); } @@ -292,7 +280,7 @@ bool xclipExists () try { var (_, result) = ClipboardProcessRunner.Process ("bash", $"-c \"which xclip\""); return result.TrimEnd () != ""; - } catch (System.Exception) { + } catch (Exception) { return false; } } diff --git a/UnitTests/Drivers/ColorTests.cs b/UnitTests/Drivers/ColorTests.cs new file mode 100644 index 0000000000..f42463c818 --- /dev/null +++ b/UnitTests/Drivers/ColorTests.cs @@ -0,0 +1,39 @@ +using System; +using Xunit; + +// Alias Console to MockConsole so we don't accidentally use Console +using Console = Terminal.Gui.FakeConsole; + +namespace Terminal.Gui.DriverTests { + public class ColorTests { + + [Theory] + [InlineData (typeof (FakeDriver))] + //[InlineData (typeof (NetDriver))] + //[InlineData (typeof (CursesDriver))] + //[InlineData (typeof (WindowsDriver))] + public void SetColors_Changes_Colors (Type driverType) + { + var driver = (ConsoleDriver)Activator.CreateInstance (driverType); + Application.Init (driver); + driver.Init (() => { }); + Assert.Equal (ConsoleColor.Gray, Console.ForegroundColor); + Assert.Equal (ConsoleColor.Black, Console.BackgroundColor); + + Console.ForegroundColor = ConsoleColor.Red; + Assert.Equal (ConsoleColor.Red, Console.ForegroundColor); + + Console.BackgroundColor = ConsoleColor.Green; + Assert.Equal (ConsoleColor.Green, Console.BackgroundColor); + + Console.ResetColor (); + Assert.Equal (ConsoleColor.Gray, Console.ForegroundColor); + Assert.Equal (ConsoleColor.Black, Console.BackgroundColor); + driver.End (); + + // Shutdown must be called to safely clean up Application if Init has been called + Application.Shutdown (); + } + + } +} \ No newline at end of file diff --git a/UnitTests/ConsoleDriverTests.cs b/UnitTests/Drivers/ConsoleDriverTests.cs similarity index 81% rename from UnitTests/ConsoleDriverTests.cs rename to UnitTests/Drivers/ConsoleDriverTests.cs index db8d167530..cdc8edfc6a 100644 --- a/UnitTests/ConsoleDriverTests.cs +++ b/UnitTests/Drivers/ConsoleDriverTests.cs @@ -1,16 +1,14 @@ using System; using System.Collections; using System.Collections.Generic; -using System.IO; using System.Linq; -using Terminal.Gui.Views; using Xunit; using Xunit.Abstractions; // Alias Console to MockConsole so we don't accidentally use Console using Console = Terminal.Gui.FakeConsole; -namespace Terminal.Gui.ConsoleDrivers { +namespace Terminal.Gui.DriverTests { public class ConsoleDriverTests { readonly ITestOutputHelper output; @@ -53,10 +51,10 @@ public void End_Cleans_Up (Type driverType) Application.Init (driver); driver.Init (() => { }); - FakeConsole.ForegroundColor = ConsoleColor.Red; + Console.ForegroundColor = ConsoleColor.Red; Assert.Equal (ConsoleColor.Red, Console.ForegroundColor); - FakeConsole.BackgroundColor = ConsoleColor.Green; + Console.BackgroundColor = ConsoleColor.Green; Assert.Equal (ConsoleColor.Green, Console.BackgroundColor); driver.Move (2, 3); Assert.Equal (2, Console.CursorLeft); @@ -72,34 +70,6 @@ public void End_Cleans_Up (Type driverType) Application.Shutdown (); } - [Theory] - [InlineData (typeof (FakeDriver))] - //[InlineData (typeof (NetDriver))] - //[InlineData (typeof (CursesDriver))] - //[InlineData (typeof (WindowsDriver))] - public void SetColors_Changes_Colors (Type driverType) - { - var driver = (ConsoleDriver)Activator.CreateInstance (driverType); - Application.Init (driver); - driver.Init (() => { }); - Assert.Equal (ConsoleColor.Gray, Console.ForegroundColor); - Assert.Equal (ConsoleColor.Black, Console.BackgroundColor); - - Console.ForegroundColor = ConsoleColor.Red; - Assert.Equal (ConsoleColor.Red, Console.ForegroundColor); - - Console.BackgroundColor = ConsoleColor.Green; - Assert.Equal (ConsoleColor.Green, Console.BackgroundColor); - - Console.ResetColor (); - Assert.Equal (ConsoleColor.Gray, Console.ForegroundColor); - Assert.Equal (ConsoleColor.Black, Console.BackgroundColor); - driver.End (); - - // Shutdown must be called to safely clean up Application if Init has been called - Application.Shutdown (); - } - [Theory] [InlineData (typeof (FakeDriver))] public void FakeDriver_Only_Sends_Keystrokes_Through_MockKeyPresses (Type driverType) @@ -119,9 +89,7 @@ public void FakeDriver_Only_Sends_Keystrokes_Through_MockKeyPresses (Type driver Application.Iteration += () => { count++; - if (count == 10) { - Application.RequestStop (); - } + if (count == 10) Application.RequestStop (); }; Application.Run (); @@ -146,7 +114,7 @@ public void FakeDriver_MockKeyPresses (Type driverType) var cki = new ConsoleKeyInfo (r, ck, false, false, false); mKeys.Push (cki); } - FakeConsole.MockKeyPresses = mKeys; + Console.MockKeyPresses = mKeys; var top = Application.Top; var view = new View (); @@ -163,9 +131,7 @@ public void FakeDriver_MockKeyPresses (Type driverType) top.Add (view); Application.Iteration += () => { - if (mKeys.Count == 0) { - Application.RequestStop (); - } + if (mKeys.Count == 0) Application.RequestStop (); }; Application.Run (); @@ -176,105 +142,6 @@ public void FakeDriver_MockKeyPresses (Type driverType) Application.Shutdown (); } - [Theory] - [InlineData (typeof (FakeDriver))] - public void SendKeys_Test (Type driverType) - { - var driver = (ConsoleDriver)Activator.CreateInstance (driverType); - Application.Init (driver); - - var top = Application.Top; - var view = new View (); - var shift = false; var alt = false; var control = false; - Key key = default; - Key lastKey = default; - List keyEnums = GetKeys (); - int i = 0; - int idxKey = 0; - var PushIterations = 0; - var PopIterations = 0; - - List GetKeys () - { - List keys = new List (); - - foreach (Key k in Enum.GetValues (typeof (Key))) { - if ((uint)k <= 0xff) { - keys.Add (k); - } else if ((uint)k > 0xff) { - break; - } - } - - return keys; - } - - view.KeyPress += (e) => { - e.Handled = true; - PopIterations++; - var rMk = new KeyModifiers () { - Shift = e.KeyEvent.IsShift, - Alt = e.KeyEvent.IsAlt, - Ctrl = e.KeyEvent.IsCtrl - }; - lastKey = ShortcutHelper.GetModifiersKey (new KeyEvent (e.KeyEvent.Key, rMk)); - Assert.Equal (key, lastKey); - }; - top.Add (view); - - Application.Iteration += () => { - switch (i) { - case 0: - SendKeys (); - break; - case 1: - shift = true; - SendKeys (); - break; - case 2: - alt = true; - SendKeys (); - break; - case 3: - control = true; - SendKeys (); - break; - } - if (PushIterations == keyEnums.Count * 4) { - Application.RequestStop (); - } - }; - - void SendKeys () - { - var k = shift && char.IsLetter ((char)keyEnums [idxKey]) && char.IsLower ((char)keyEnums [idxKey]) - ? (Key)char.ToUpper ((char)keyEnums [idxKey]) : keyEnums [idxKey]; - var c = (char)k; - var ck = char.IsLetter (c) ? (ConsoleKey)char.ToUpper (c) : (ConsoleKey)c; - var mk = new KeyModifiers () { - Shift = shift, - Alt = alt, - Ctrl = control - }; - key = ShortcutHelper.GetModifiersKey (new KeyEvent (k, mk)); - Application.Driver.SendKeys (c, ck, shift, alt, control); - PushIterations++; - if (idxKey + 1 < keyEnums.Count) { - idxKey++; - } else { - idxKey = 0; - i++; - } - } - - Application.Run (); - - Assert.Equal (key, lastKey); - - // Shutdown must be called to safely clean up Application if Init has been called - Application.Shutdown (); - } - [Theory] [InlineData (typeof (FakeDriver))] public void TerminalResized_Simulation (Type driverType) @@ -452,93 +319,7 @@ public void HeightAsBuffer_Is_True_Top_Cannot_Be_Greater_Than_BufferHeight_Minus Application.Shutdown (); } - - [Fact] - public void Internal_Tests () - { - var cs = new ColorScheme (); - Assert.Equal ("", cs.caller); - } - - [Fact] - [AutoInitShutdown] - public void KeyModifiers_Resetting_At_New_Keystrokes () - { - bool? okInitialFocused = null; - bool? cancelInitialFocused = null; - var okClicked = false; - var closing = false; - var cursorRight = false; - var endingKeyPress = false; - var closed = false; - - var top = Application.Top; - - var ok = new Button ("Ok"); - ok.Clicked += () => { - if (!okClicked) { - okClicked = true; - Application.RequestStop (); - } - }; - - var cancel = new Button ("Cancel"); - - var d = new Dialog ("Quit", cancel, ok); - d.KeyPress += (e) => { - if (e.KeyEvent.Key == (Key.Q | Key.CtrlMask)) { - if (!okClicked && !closing) { - okInitialFocused = ok.HasFocus; - cancelInitialFocused = cancel.HasFocus; - closing = true; - var mKeys = new Stack (); - var cki = new ConsoleKeyInfo ('\0', ConsoleKey.Enter, false, false, false); - mKeys.Push (cki); - cki = new ConsoleKeyInfo ('\0', ConsoleKey.RightArrow, false, false, false); - mKeys.Push (cki); - FakeConsole.MockKeyPresses = mKeys; - } - e.Handled = true; - } else if (e.KeyEvent.Key == Key.CursorRight) { - if (!cursorRight) { - cursorRight = true; - } else if (ok.HasFocus) { - e.Handled = endingKeyPress = true; - } - } - }; - d.Loaded += () => { - var mKeys = new Stack (); - var cki = new ConsoleKeyInfo ('q', ConsoleKey.Q, false, false, true); - mKeys.Push (cki); - FakeConsole.MockKeyPresses = mKeys; - }; - d.Closed += (_) => { - if (okClicked && closing) { - closed = true; - } - }; - - top.Ready += () => Application.Run (d); - - Application.Iteration += () => { - if (closed) { - Application.RequestStop (); - } - }; - - Application.Run (); - - Assert.False (okInitialFocused); - Assert.True (cancelInitialFocused); - Assert.True (okClicked); - Assert.True (closing); - Assert.True (cursorRight); - Assert.True (endingKeyPress); - Assert.True (closed); - Assert.Empty (FakeConsole.MockKeyPresses); - } - + [Fact, AutoInitShutdown] public void AddRune_On_Clip_Left_Or_Right_Replace_Previous_Or_Next_Wide_Rune_With_Space () { @@ -670,33 +451,21 @@ public void MakePrintable_Does_Not_Convert_Ansi_Chars_To_Unicode (uint code) [ClassData (typeof (PacketTest))] public void TestVKPacket (uint unicodeCharacter, bool shift, bool alt, bool control, uint initialVirtualKey, uint initialScanCode, Key expectedRemapping, uint expectedVirtualKey, uint expectedScanCode) { - ConsoleModifiers modifiers = new ConsoleModifiers (); - if (shift) { - modifiers |= ConsoleModifiers.Shift; - } - if (alt) { - modifiers |= ConsoleModifiers.Alt; - } - if (control) { - modifiers |= ConsoleModifiers.Control; - } + var modifiers = new ConsoleModifiers (); + if (shift) modifiers |= ConsoleModifiers.Shift; + if (alt) modifiers |= ConsoleModifiers.Alt; + if (control) modifiers |= ConsoleModifiers.Control; var mappedConsoleKey = ConsoleKeyMapping.GetConsoleKeyFromKey (unicodeCharacter, modifiers, out uint scanCode, out uint outputChar); - if ((scanCode > 0 || mappedConsoleKey == 0) && mappedConsoleKey == initialVirtualKey) { - Assert.Equal (mappedConsoleKey, initialVirtualKey); - } else { - Assert.Equal (mappedConsoleKey, outputChar < 0xff ? (uint)(outputChar & 0xff | 0xff << 8) : outputChar); - } + if ((scanCode > 0 || mappedConsoleKey == 0) && mappedConsoleKey == initialVirtualKey) Assert.Equal (mappedConsoleKey, initialVirtualKey); + else Assert.Equal (mappedConsoleKey, outputChar < 0xff ? outputChar & 0xff | 0xff << 8 : outputChar); Assert.Equal (scanCode, initialScanCode); var keyChar = ConsoleKeyMapping.GetKeyCharFromConsoleKey (mappedConsoleKey, modifiers, out uint consoleKey, out scanCode); //if (scanCode > 0 && consoleKey == keyChar && consoleKey > 48 && consoleKey > 57 && consoleKey < 65 && consoleKey > 91) { - if (scanCode > 0 && keyChar == 0 && consoleKey == mappedConsoleKey) { - Assert.Equal (0, (double)keyChar); - } else { - Assert.Equal (keyChar, unicodeCharacter); - } + if (scanCode > 0 && keyChar == 0 && consoleKey == mappedConsoleKey) Assert.Equal (0, (double)keyChar); + else Assert.Equal (keyChar, unicodeCharacter); Assert.Equal (consoleKey, expectedVirtualKey); Assert.Equal (scanCode, expectedScanCode); @@ -713,9 +482,7 @@ public void TestVKPacket (uint unicodeCharacter, bool shift, bool alt, bool cont Application.Iteration += () => { iterations++; - if (iterations == 0) { - Application.Driver.SendKeys ((char)mappedConsoleKey, ConsoleKey.Packet, shift, alt, control); - } + if (iterations == 0) Application.Driver.SendKeys ((char)mappedConsoleKey, ConsoleKey.Packet, shift, alt, control); }; Application.Run (); diff --git a/UnitTests/KeyTests.cs b/UnitTests/Drivers/KeyTests.cs similarity index 99% rename from UnitTests/KeyTests.cs rename to UnitTests/Drivers/KeyTests.cs index 455cfa9924..3d4d8606e3 100644 --- a/UnitTests/KeyTests.cs +++ b/UnitTests/Drivers/KeyTests.cs @@ -1,7 +1,7 @@ using System; using Xunit; -namespace Terminal.Gui.Core { +namespace Terminal.Gui.DriverTests { public class KeyTests { enum SimpleEnum { Zero, One, Two, Three, Four, Five } diff --git a/UnitTests/ContextMenuTests.cs b/UnitTests/Menus/ContextMenuTests.cs similarity index 99% rename from UnitTests/ContextMenuTests.cs rename to UnitTests/Menus/ContextMenuTests.cs index 00b35e6ed4..4e21849986 100644 --- a/UnitTests/ContextMenuTests.cs +++ b/UnitTests/Menus/ContextMenuTests.cs @@ -2,9 +2,9 @@ using System.Threading; using Xunit; using Xunit.Abstractions; -using GraphViewTests = Terminal.Gui.Views.GraphViewTests; +//using GraphViewTests = Terminal.Gui.Views.GraphViewTests; -namespace Terminal.Gui.Core { +namespace Terminal.Gui.MenuTests { public class ContextMenuTests { readonly ITestOutputHelper output; diff --git a/UnitTests/MenuTests.cs b/UnitTests/Menus/MenuTests.cs similarity index 99% rename from UnitTests/MenuTests.cs rename to UnitTests/Menus/MenuTests.cs index e41041e582..b82450c9c1 100644 --- a/UnitTests/MenuTests.cs +++ b/UnitTests/Menus/MenuTests.cs @@ -3,9 +3,9 @@ using System.Linq; using Xunit; using Xunit.Abstractions; -using static Terminal.Gui.Views.MenuTests; +//using static Terminal.Gui.ViewTests.MenuTests; -namespace Terminal.Gui.Views { +namespace Terminal.Gui.MenuTests { public class MenuTests { readonly ITestOutputHelper output; diff --git a/UnitTests/CollectionNavigatorTests.cs b/UnitTests/Text/CollectionNavigatorTests.cs similarity index 99% rename from UnitTests/CollectionNavigatorTests.cs rename to UnitTests/Text/CollectionNavigatorTests.cs index d0de09f3a4..7c93bf4997 100644 --- a/UnitTests/CollectionNavigatorTests.cs +++ b/UnitTests/Text/CollectionNavigatorTests.cs @@ -2,7 +2,7 @@ using System.Threading; using Xunit; -namespace Terminal.Gui.Core { +namespace Terminal.Gui.TextTests { public class CollectionNavigatorTests { static string [] simpleStrings = new string []{ "appricot", // 0 diff --git a/UnitTests/TextFormatterTests.cs b/UnitTests/Text/TextFormatterTests.cs similarity index 99% rename from UnitTests/TextFormatterTests.cs rename to UnitTests/Text/TextFormatterTests.cs index 63e28290e4..a791a6ffb0 100644 --- a/UnitTests/TextFormatterTests.cs +++ b/UnitTests/Text/TextFormatterTests.cs @@ -2,14 +2,14 @@ using System; using System.Collections.Generic; using System.Linq; -using Terminal.Gui.Views; +using Terminal.Gui; using Xunit; using Xunit.Abstractions; // Alias Console to MockConsole so we don't accidentally use Console using Console = Terminal.Gui.FakeConsole; -namespace Terminal.Gui.Core { +namespace Terminal.Gui.TextTests { public class TextFormatterTests { readonly ITestOutputHelper output; @@ -394,7 +394,7 @@ public void FindHotKey_Legacy_FirstUpperCase_Succeeds () bool supportFirstUpperCase = true; var text = ustring.Empty; - Rune hotKeySpecifier = (Rune)0; + var hotKeySpecifier = (Rune)0; int hotPos = 0; Key hotKey = Key.Unknown; bool result = false; @@ -437,7 +437,7 @@ public void FindHotKey_Legacy_FirstUpperCase_NotFound_Returns_False () bool supportFirstUpperCase = true; var text = ustring.Empty; - Rune hotKeySpecifier = (Rune)0; + var hotKeySpecifier = (Rune)0; int hotPos = 0; Key hotKey = Key.Unknown; bool result = false; @@ -2162,9 +2162,7 @@ public void WordWrap_preserveTrailingSpaces_Horizontal_With_Simple_Runes () var height = 8; var wrappedLines = TextFormatter.WordWrap (text, width, true); var breakLines = ""; - foreach (var line in wrappedLines) { - breakLines += $"{line}{Environment.NewLine}"; - } + foreach (var line in wrappedLines) breakLines += $"{line}{Environment.NewLine}"; var label = new Label (breakLines) { Width = Dim.Fill (), Height = Dim.Fill () }; var frame = new FrameView () { Width = Dim.Fill (), Height = Dim.Fill () }; @@ -2202,9 +2200,7 @@ public void WordWrap_preserveTrailingSpaces_Vertical_With_Simple_Runes () var height = 3; var wrappedLines = TextFormatter.WordWrap (text, height, true); var breakLines = ""; - for (int i = 0; i < wrappedLines.Count; i++) { - breakLines += $"{wrappedLines [i]}{(i < wrappedLines.Count - 1 ? Environment.NewLine : string.Empty)}"; - } + for (int i = 0; i < wrappedLines.Count; i++) breakLines += $"{wrappedLines [i]}{(i < wrappedLines.Count - 1 ? Environment.NewLine : string.Empty)}"; var label = new Label (breakLines) { TextDirection = TextDirection.TopBottom_LeftRight, Width = Dim.Fill (), @@ -2241,9 +2237,7 @@ public void WordWrap_preserveTrailingSpaces_Horizontal_With_Wide_Runes () var height = 8; var wrappedLines = TextFormatter.WordWrap (text, width, true); var breakLines = ""; - foreach (var line in wrappedLines) { - breakLines += $"{line}{Environment.NewLine}"; - } + foreach (var line in wrappedLines) breakLines += $"{line}{Environment.NewLine}"; var label = new Label (breakLines) { Width = Dim.Fill (), Height = Dim.Fill () }; var frame = new FrameView () { Width = Dim.Fill (), Height = Dim.Fill () }; @@ -2282,9 +2276,7 @@ public void WordWrap_preserveTrailingSpaces_Vertical_With_Wide_Runes () var height = 4; var wrappedLines = TextFormatter.WordWrap (text, width, true); var breakLines = ""; - for (int i = 0; i < wrappedLines.Count; i++) { - breakLines += $"{wrappedLines [i]}{(i < wrappedLines.Count - 1 ? Environment.NewLine : string.Empty)}"; - } + for (int i = 0; i < wrappedLines.Count; i++) breakLines += $"{wrappedLines [i]}{(i < wrappedLines.Count - 1 ? Environment.NewLine : string.Empty)}"; var label = new Label (breakLines) { TextDirection = TextDirection.TopBottom_LeftRight, Width = Dim.Fill (), @@ -2433,13 +2425,13 @@ public void ReplaceHotKeyWithTag () Assert.Equal (ustring.Make (new Rune [] { 't', tag, 's', 't' }), tf.ReplaceHotKeyWithTag (text, hotPos)); var result = tf.ReplaceHotKeyWithTag (text, hotPos); - Assert.Equal ('e', (uint)(result.ToRunes () [1])); + Assert.Equal ('e', result.ToRunes () [1]); text = "Ok"; tag = 'O'; hotPos = 0; Assert.Equal (ustring.Make (new Rune [] { tag, 'k' }), result = tf.ReplaceHotKeyWithTag (text, hotPos)); - Assert.Equal ('O', (uint)(result.ToRunes () [0])); + Assert.Equal ('O', result.ToRunes () [0]); text = "[◦ Ok ◦]"; text = ustring.Make (new Rune [] { '[', '◦', ' ', 'O', 'k', ' ', '◦', ']' }); @@ -2449,13 +2441,13 @@ public void ReplaceHotKeyWithTag () tag = 'O'; hotPos = 3; Assert.Equal (ustring.Make (new Rune [] { '[', '◦', ' ', tag, 'k', ' ', '◦', ']' }), result = tf.ReplaceHotKeyWithTag (text, hotPos)); - Assert.Equal ('O', (uint)(result.ToRunes () [3])); + Assert.Equal ('O', result.ToRunes () [3]); text = "^k"; tag = '^'; hotPos = 0; Assert.Equal (ustring.Make (new Rune [] { tag, 'k' }), result = tf.ReplaceHotKeyWithTag (text, hotPos)); - Assert.Equal ('^', (uint)(result.ToRunes () [0])); + Assert.Equal ('^', result.ToRunes () [0]); } [Fact] @@ -2814,37 +2806,37 @@ public void Reformat_Unicode_Wrap_Spaces_NewLines () [Fact] public void System_Rune_ColumnWidth () { - var c = new System.Rune ('a'); + var c = new Rune ('a'); Assert.Equal (1, Rune.ColumnWidth (c)); Assert.Equal (1, ustring.Make (c).ConsoleWidth); Assert.Equal (1, ustring.Make (c).Length); - c = new System.Rune ('b'); + c = new Rune ('b'); Assert.Equal (1, Rune.ColumnWidth (c)); Assert.Equal (1, ustring.Make (c).ConsoleWidth); Assert.Equal (1, ustring.Make (c).Length); - c = new System.Rune (123); + c = new Rune (123); Assert.Equal (1, Rune.ColumnWidth (c)); Assert.Equal (1, ustring.Make (c).ConsoleWidth); Assert.Equal (1, ustring.Make (c).Length); - c = new System.Rune ('\u1150'); + c = new Rune ('\u1150'); Assert.Equal (2, Rune.ColumnWidth (c)); // 0x1150 ᅐ Unicode Technical Report #11 Assert.Equal (2, ustring.Make (c).ConsoleWidth); Assert.Equal (3, ustring.Make (c).Length); - c = new System.Rune ('\u1161'); + c = new Rune ('\u1161'); Assert.Equal (0, Rune.ColumnWidth (c)); // 0x1161 ᅡ column width of 0 Assert.Equal (0, ustring.Make (c).ConsoleWidth); Assert.Equal (3, ustring.Make (c).Length); - c = new System.Rune (31); + c = new Rune (31); Assert.Equal (-1, Rune.ColumnWidth (c)); // non printable character Assert.Equal (0, ustring.Make (c).ConsoleWidth);// ConsoleWidth only returns zero or greater than zero Assert.Equal (1, ustring.Make (c).Length); - c = new System.Rune (127); + c = new Rune (127); Assert.Equal (-1, Rune.ColumnWidth (c)); // non printable character Assert.Equal (0, ustring.Make (c).ConsoleWidth); Assert.Equal (1, ustring.Make (c).Length); @@ -2896,9 +2888,7 @@ public void Format_WordWrap_preserveTrailingSpaces () Assert.Equal ("nd", list1 [10].ToString ()); Assert.Equal ("Line", list1 [11].ToString ()); Assert.Equal ("- 2.", list1 [^1].ToString ()); - foreach (var txt in list1) { - wrappedText1 += txt; - } + foreach (var txt in list1) wrappedText1 += txt; Assert.Equal (" Asentencehaswords. This isthesecondLine- 2.", wrappedText1); // With preserveTrailingSpaces = true. @@ -2920,9 +2910,7 @@ public void Format_WordWrap_preserveTrailingSpaces () Assert.Equal ("Line", list2 [13].ToString ()); Assert.Equal (" - ", list2 [14].ToString ()); Assert.Equal ("2. ", list2 [^1].ToString ()); - foreach (var txt in list2) { - wrappedText2 += txt; - } + foreach (var txt in list2) wrappedText2 += txt; Assert.Equal (" A sentence has words. This is the second Line - 2. ", wrappedText2); } @@ -3430,7 +3418,7 @@ public void GetSumMaxCharWidth_Simple_And_Wide_Runes () [Fact] public void GetSumMaxCharWidth_List_Simple_And_Wide_Runes () { - List text = new List () { "Hello", "World" }; + var text = new List () { "Hello", "World" }; Assert.Equal (2, TextFormatter.GetSumMaxCharWidth (text)); Assert.Equal (1, TextFormatter.GetSumMaxCharWidth (text, 1, 1)); text = new List () { "こんにちは", "世界" }; diff --git a/UnitTests/DialogTests.cs b/UnitTests/TopLevels/DialogTests.cs similarity index 92% rename from UnitTests/DialogTests.cs rename to UnitTests/TopLevels/DialogTests.cs index 1917b13e1d..3dea9ccb13 100644 --- a/UnitTests/DialogTests.cs +++ b/UnitTests/TopLevels/DialogTests.cs @@ -9,7 +9,7 @@ using Xunit.Abstractions; using NStack; -namespace Terminal.Gui.Views { +namespace Terminal.Gui.TopLevelTests { public class DialogTests { readonly ITestOutputHelper output; @@ -29,7 +29,7 @@ public DialogTests (ITestOutputHelper output) [AutoInitShutdown] public void ButtonAlignment_One () { - var d = ((FakeDriver)Application.Driver); + var d = (FakeDriver)Application.Driver; Application.RunState runstate = null; var title = "1234"; @@ -37,8 +37,8 @@ public void ButtonAlignment_One () var btnText = "ok"; var buttonRow = $"{d.VLine} {d.LeftBracket} {btnText} {d.RightBracket} {d.VLine}"; var width = buttonRow.Length; - var topRow = $"┌ {title} {new String (d.HLine.ToString () [0], width - title.Length - 4)}┐"; - var bottomRow = $"└{new String (d.HLine.ToString () [0], width - 2)}┘"; + var topRow = $"┌ {title} {new string (d.HLine.ToString () [0], width - title.Length - 4)}┐"; + var bottomRow = $"└{new string (d.HLine.ToString () [0], width - 2)}┘"; d.SetBufferSize (width, 3); @@ -74,7 +74,7 @@ public void ButtonAlignment_Two () { Application.RunState runstate = null; - var d = ((FakeDriver)Application.Driver); + var d = (FakeDriver)Application.Driver; var title = "1234"; // E.g "|[ yes ][ no ]|" @@ -85,8 +85,8 @@ public void ButtonAlignment_Two () var buttonRow = $@"{d.VLine} {btn1} {btn2} {d.VLine}"; var width = buttonRow.Length; - var topRow = $"┌ {title} {new String (d.HLine.ToString () [0], width - title.Length - 4)}┐"; - var bottomRow = $"└{new String (d.HLine.ToString () [0], width - 2)}┘"; + var topRow = $"┌ {title} {new string (d.HLine.ToString () [0], width - title.Length - 4)}┐"; + var bottomRow = $"└{new string (d.HLine.ToString () [0], width - 2)}┘"; d.SetBufferSize (buttonRow.Length, 3); @@ -123,7 +123,7 @@ public void ButtonAlignment_Two_Hidden () Application.RunState runstate = null; bool firstIteration = false; - var d = ((FakeDriver)Application.Driver); + var d = (FakeDriver)Application.Driver; var title = "1234"; // E.g "|[ yes ][ no ]|" @@ -134,8 +134,8 @@ public void ButtonAlignment_Two_Hidden () var buttonRow = $@"{d.VLine} {btn1} {btn2} {d.VLine}"; var width = buttonRow.Length; - var topRow = $"┌ {title} {new String (d.HLine.ToString () [0], width - title.Length - 4)}┐"; - var bottomRow = $"└{new String (d.HLine.ToString () [0], width - 2)}┘"; + var topRow = $"┌ {title} {new string (d.HLine.ToString () [0], width - title.Length - 4)}┐"; + var bottomRow = $"└{new string (d.HLine.ToString () [0], width - 2)}┘"; d.SetBufferSize (buttonRow.Length, 3); @@ -191,7 +191,7 @@ public void ButtonAlignment_Three () { Application.RunState runstate = null; - var d = ((FakeDriver)Application.Driver); + var d = (FakeDriver)Application.Driver; var title = "1234"; // E.g "|[ yes ][ no ][ maybe ]|" @@ -204,8 +204,8 @@ public void ButtonAlignment_Three () var buttonRow = $@"{d.VLine} {btn1} {btn2} {btn3} {d.VLine}"; var width = buttonRow.Length; - var topRow = $"┌ {title} {new String (d.HLine.ToString () [0], width - title.Length - 4)}┐"; - var bottomRow = $"└{new String (d.HLine.ToString () [0], width - 2)}┘"; + var topRow = $"┌ {title} {new string (d.HLine.ToString () [0], width - title.Length - 4)}┐"; + var bottomRow = $"└{new string (d.HLine.ToString () [0], width - 2)}┘"; d.SetBufferSize (buttonRow.Length, 3); @@ -241,7 +241,7 @@ public void ButtonAlignment_Four () { Application.RunState runstate = null; - var d = ((FakeDriver)Application.Driver); + var d = (FakeDriver)Application.Driver; var title = "1234"; @@ -257,8 +257,8 @@ public void ButtonAlignment_Four () var buttonRow = $"{d.VLine} {btn1} {btn2} {btn3} {btn4} {d.VLine}"; var width = buttonRow.Length; - var topRow = $"┌ {title} {new String (d.HLine.ToString () [0], width - title.Length - 4)}┐"; - var bottomRow = $"└{new String (d.HLine.ToString () [0], width - 2)}┘"; + var topRow = $"┌ {title} {new string (d.HLine.ToString () [0], width - title.Length - 4)}┐"; + var bottomRow = $"└{new string (d.HLine.ToString () [0], width - 2)}┘"; d.SetBufferSize (buttonRow.Length, 3); // Default - Center @@ -294,7 +294,7 @@ public void ButtonAlignment_Four_On_Smaller_Width () { Application.RunState runstate = null; - var d = ((FakeDriver)Application.Driver); + var d = (FakeDriver)Application.Driver; var title = "1234"; @@ -349,7 +349,7 @@ public void ButtonAlignment_Four_Wider () { Application.RunState runstate = null; - var d = ((FakeDriver)Application.Driver); + var d = (FakeDriver)Application.Driver; var title = "1234"; @@ -368,8 +368,8 @@ public void ButtonAlignment_Four_Wider () // 12345 123456 var buttonRow = $"{d.VLine} {btn1} {btn2} {btn3} {btn4} {d.VLine}"; var width = ustring.Make (buttonRow).ConsoleWidth; - var topRow = $"┌ {title} {new String (d.HLine.ToString () [0], width - title.Length - 4)}┐"; - var bottomRow = $"└{new String (d.HLine.ToString () [0], width - 2)}┘"; + var topRow = $"┌ {title} {new string (d.HLine.ToString () [0], width - title.Length - 4)}┐"; + var bottomRow = $"└{new string (d.HLine.ToString () [0], width - 2)}┘"; d.SetBufferSize (width, 3); // Default - Center @@ -405,7 +405,7 @@ public void ButtonAlignment_Four_WideOdd () { Application.RunState runstate = null; - var d = ((FakeDriver)Application.Driver); + var d = (FakeDriver)Application.Driver; var title = "1234"; @@ -423,8 +423,8 @@ public void ButtonAlignment_Four_WideOdd () // 12345 123456 var buttonRow = $"{d.VLine} {btn1} {btn2} {btn3} {btn4} {d.VLine}"; var width = buttonRow.Length; - var topRow = $"┌ {title} {new String (d.HLine.ToString () [0], width - title.Length - 4)}┐"; - var bottomRow = $"└{new String (d.HLine.ToString () [0], width - 2)}┘"; + var topRow = $"┌ {title} {new string (d.HLine.ToString () [0], width - title.Length - 4)}┐"; + var bottomRow = $"└{new string (d.HLine.ToString () [0], width - 2)}┘"; d.SetBufferSize (buttonRow.Length, 3); // Default - Center @@ -460,14 +460,14 @@ public void Zero_Buttons_Works () { Application.RunState runstate = null; - var d = ((FakeDriver)Application.Driver); + var d = (FakeDriver)Application.Driver; var title = "1234"; var buttonRow = $"{d.VLine} {d.VLine}"; var width = buttonRow.Length; - var topRow = $"┌ {title} {new String (d.HLine.ToString () [0], width - title.Length - 4)}┐"; - var bottomRow = $"└{new String (d.HLine.ToString () [0], width - 2)}┘"; + var topRow = $"┌ {title} {new string (d.HLine.ToString () [0], width - title.Length - 4)}┐"; + var bottomRow = $"└{new string (d.HLine.ToString () [0], width - 2)}┘"; d.SetBufferSize (buttonRow.Length, 3); (runstate, var _) = RunButtonTestDialog (title, width, Dialog.ButtonAlignments.Center, null); @@ -482,15 +482,15 @@ public void One_Button_Works () { Application.RunState runstate = null; - var d = ((FakeDriver)Application.Driver); + var d = (FakeDriver)Application.Driver; var title = "1234"; var btnText = "ok"; var buttonRow = $"{d.VLine} {d.LeftBracket} {btnText} {d.RightBracket} {d.VLine}"; var width = buttonRow.Length; - var topRow = $"┌ {title} {new String (d.HLine.ToString () [0], width - title.Length - 4)}┐"; - var bottomRow = $"└{new String (d.HLine.ToString () [0], width - 2)}┘"; + var topRow = $"┌ {title} {new string (d.HLine.ToString () [0], width - title.Length - 4)}┐"; + var bottomRow = $"└{new string (d.HLine.ToString () [0], width - 2)}┘"; d.SetBufferSize (buttonRow.Length, 3); (runstate, var _) = RunButtonTestDialog (title, width, Dialog.ButtonAlignments.Center, new Button (btnText)); @@ -504,7 +504,7 @@ public void Add_Button_Works () { Application.RunState runstate = null; - var d = ((FakeDriver)Application.Driver); + var d = (FakeDriver)Application.Driver; var title = "1234"; var btn1Text = "yes"; @@ -516,8 +516,8 @@ public void Add_Button_Works () var width = $@"{d.VLine} {btn1} {btn2} {d.VLine}".Length; d.SetBufferSize (width, 3); - var topRow = $"{d.ULCorner} {title} {new String (d.HLine.ToString () [0], width - title.Length - 4)}{d.URCorner}"; - var bottomRow = $"{d.LLCorner}{new String (d.HLine.ToString () [0], width - 2)}{d.LRCorner}"; + var topRow = $"{d.ULCorner} {title} {new string (d.HLine.ToString () [0], width - title.Length - 4)}{d.URCorner}"; + var bottomRow = $"{d.LLCorner}{new string (d.HLine.ToString () [0], width - 2)}{d.LRCorner}"; // Default (center) var dlg = new Dialog (title, width, 3, new Button (btn1Text)) { ButtonAlignment = Dialog.ButtonAlignments.Center }; @@ -550,7 +550,7 @@ public void Add_Button_Works () // Right dlg = new Dialog (title, width, 3, new Button (btn1Text)) { ButtonAlignment = Dialog.ButtonAlignments.Right }; runstate = Application.Begin (dlg); - buttonRow = $"{d.VLine}{new String (' ', width - btn1.Length - 2)}{btn1}{d.VLine}"; + buttonRow = $"{d.VLine}{new string (' ', width - btn1.Length - 2)}{btn1}{d.VLine}"; TestHelpers.AssertDriverContentsWithFrameAre ($"{topRow}\n{buttonRow}\n{bottomRow}", output); // Now add a second button @@ -564,7 +564,7 @@ public void Add_Button_Works () // Left dlg = new Dialog (title, width, 3, new Button (btn1Text)) { ButtonAlignment = Dialog.ButtonAlignments.Left }; runstate = Application.Begin (dlg); - buttonRow = $"{d.VLine}{btn1}{new String (' ', width - btn1.Length - 2)}{d.VLine}"; + buttonRow = $"{d.VLine}{btn1}{new string (' ', width - btn1.Length - 2)}{d.VLine}"; TestHelpers.AssertDriverContentsWithFrameAre ($"{topRow}\n{buttonRow}\n{bottomRow}", output); // Now add a second button diff --git a/UnitTests/MdiTests.cs b/UnitTests/TopLevels/MdiTests.cs similarity index 92% rename from UnitTests/MdiTests.cs rename to UnitTests/TopLevels/MdiTests.cs index 83860bf363..ef41e3c94f 100644 --- a/UnitTests/MdiTests.cs +++ b/UnitTests/TopLevels/MdiTests.cs @@ -3,12 +3,13 @@ using System.Linq; using System.Threading; using System.Threading.Tasks; +using Terminal.Gui; using Xunit; // Alias Console to MockConsole so we don't accidentally use Console using Console = Terminal.Gui.FakeConsole; -namespace Terminal.Gui.Core { +namespace Terminal.Gui.TopLevelTests { public class MdiTests { public MdiTests () { @@ -94,17 +95,11 @@ public void Application_RequestStop_With_Params_On_A_Not_MdiContainer_Always_Use Application.Iteration += () => { Assert.Null (Application.MdiChildes); - if (iterations == 4) { - Assert.True (Application.Current == d); - } else if (iterations == 3) { - Assert.True (Application.Current == top4); - } else if (iterations == 2) { - Assert.True (Application.Current == top3); - } else if (iterations == 1) { - Assert.True (Application.Current == top2); - } else { - Assert.True (Application.Current == top1); - } + if (iterations == 4) Assert.True (Application.Current == d); +else if (iterations == 3) Assert.True (Application.Current == top4); +else if (iterations == 2) Assert.True (Application.Current == top3); +else if (iterations == 1) Assert.True (Application.Current == top2); +else Assert.True (Application.Current == top1); Application.RequestStop (top1); iterations--; }; @@ -171,9 +166,7 @@ public void MdiContainer_With_Toplevel_RequestStop_Balanced () Assert.False (d.Running); } else { Assert.Equal (iterations, Application.MdiChildes.Count); - for (int i = 0; i < iterations; i++) { - Assert.Equal ((iterations - i + 1).ToString (), Application.MdiChildes [i].Id); - } + for (int i = 0; i < iterations; i++) Assert.Equal ((iterations - i + 1).ToString (), Application.MdiChildes [i].Id); } iterations--; }; @@ -231,9 +224,7 @@ public void MdiContainer_With_Application_RequestStop_MdiTop_With_Params () Assert.False (d.Running); } else { Assert.Equal (iterations, Application.MdiChildes.Count); - for (int i = 0; i < iterations; i++) { - Assert.Equal ((iterations - i + 1).ToString (), Application.MdiChildes [i].Id); - } + for (int i = 0; i < iterations; i++) Assert.Equal ((iterations - i + 1).ToString (), Application.MdiChildes [i].Id); } iterations--; }; @@ -292,9 +283,7 @@ public void MdiContainer_With_Application_RequestStop_MdiTop_Without_Params () Assert.False (d.Running); } else { Assert.Equal (iterations, Application.MdiChildes.Count); - for (int i = 0; i < iterations; i++) { - Assert.Equal ((iterations - i + 1).ToString (), Application.MdiChildes [i].Id); - } + for (int i = 0; i < iterations; i++) Assert.Equal ((iterations - i + 1).ToString (), Application.MdiChildes [i].Id); } iterations--; }; @@ -392,9 +381,7 @@ public void Modal_Toplevel_Can_Open_Another_Modal_Toplevel_But_RequestStop_To_Th Assert.False (Application.Current.Running); } else { Assert.Equal (iterations, Application.MdiChildes.Count); - for (int i = 0; i < iterations; i++) { - Assert.Equal ((iterations - i + 1).ToString (), Application.MdiChildes [i].Id); - } + for (int i = 0; i < iterations; i++) Assert.Equal ((iterations - i + 1).ToString (), Application.MdiChildes [i].Id); } iterations--; }; @@ -461,10 +448,8 @@ public void Modal_Toplevel_Can_Open_Another_Not_Modal_Toplevel_But_RequestStop_T Assert.True (c4.Running); } else { Assert.Equal (iterations, Application.MdiChildes.Count); - for (int i = 0; i < iterations; i++) { - Assert.Equal ((iterations - i + (iterations == 4 && i == 0 ? 2 : 1)).ToString (), + for (int i = 0; i < iterations; i++) Assert.Equal ((iterations - i + (iterations == 4 && i == 0 ? 2 : 1)).ToString (), Application.MdiChildes [i].Id); - } } iterations--; }; @@ -586,9 +571,7 @@ public void MdiContainer_Open_And_Close_Modal_And_Open_Not_Modal_Toplevels_Rando }; stage.Closed += (_) => { - if (iterations == 11) { - allStageClosed = true; - } + if (iterations == 11) allStageClosed = true; Assert.Equal (iterations, Application.MdiChildes.Count); if (running) { stageCompleted = true; @@ -610,16 +593,12 @@ public void MdiContainer_Open_And_Close_Modal_And_Open_Not_Modal_Toplevels_Rando running = false; Assert.Equal (iterations, Application.MdiChildes.Count); - } else if (!mdiRequestStop && running && !allStageClosed) { - Assert.Equal (iterations, Application.MdiChildes.Count); - - } else if (!mdiRequestStop && !running && allStageClosed) { + } else if (!mdiRequestStop && running && !allStageClosed) Assert.Equal (iterations, Application.MdiChildes.Count); +else if (!mdiRequestStop && !running && allStageClosed) { Assert.Equal (iterations, Application.MdiChildes.Count); mdiRequestStop = true; mdi.RequestStop (); - } else { - Assert.Empty (Application.MdiChildes); - } + } else Assert.Empty (Application.MdiChildes); }; Application.Run (mdi); diff --git a/UnitTests/MessageBoxTests.cs b/UnitTests/TopLevels/MessageBoxTests.cs similarity index 99% rename from UnitTests/MessageBoxTests.cs rename to UnitTests/TopLevels/MessageBoxTests.cs index dc98815517..3847922ed0 100644 --- a/UnitTests/MessageBoxTests.cs +++ b/UnitTests/TopLevels/MessageBoxTests.cs @@ -2,8 +2,9 @@ using Xunit; using Xunit.Abstractions; using System.Text; +using Terminal.Gui; -namespace Terminal.Gui.Views { +namespace Terminal.Gui.TopLevelTests { public class MessageBoxTests { readonly ITestOutputHelper output; @@ -54,7 +55,7 @@ public void MessageBox_With_Empty_Size_With_Button () iterations++; if (iterations == 0) { - StringBuilder aboutMessage = new StringBuilder (); + var aboutMessage = new StringBuilder (); aboutMessage.AppendLine (@"A comprehensive sample library for"); aboutMessage.AppendLine (@""); aboutMessage.AppendLine (@" _______ _ _ _____ _ "); diff --git a/UnitTests/ToplevelTests.cs b/UnitTests/TopLevels/ToplevelTests.cs similarity index 99% rename from UnitTests/ToplevelTests.cs rename to UnitTests/TopLevels/ToplevelTests.cs index 16a6daf5de..7cd2b1d069 100644 --- a/UnitTests/ToplevelTests.cs +++ b/UnitTests/TopLevels/ToplevelTests.cs @@ -1,8 +1,9 @@ using System; +using Terminal.Gui; using Xunit; using Xunit.Abstractions; -namespace Terminal.Gui.Core { +namespace Terminal.Gui.TopLevelTests { public class ToplevelTests { readonly ITestOutputHelper output; @@ -695,8 +696,7 @@ public void Mouse_Drag_On_Top_With_Superview_Null () ((FakeDriver)Application.Driver).SetBufferSize (40, 15); MessageBox.Query ("About", "Hello Word", "Ok"); - } else if (iterations == 1) { - TestHelpers.AssertDriverContentsWithFrameAre (@" + } else if (iterations == 1) TestHelpers.AssertDriverContentsWithFrameAre (@" File ┌ Window ──────────────────────────────┐ │ │ @@ -712,8 +712,7 @@ public void Mouse_Drag_On_Top_With_Superview_Null () │ │ └──────────────────────────────────────┘ CTRL-N New ", output); - - } else if (iterations == 2) { +else if (iterations == 2) { Assert.Null (Application.MouseGrabView); // Grab the mouse ReflectionTools.InvokePrivate ( @@ -816,11 +815,8 @@ public void Mouse_Drag_On_Top_With_Superview_Null () Assert.Null (Application.MouseGrabView); - } else if (iterations == 8) { - Application.RequestStop (); - } else if (iterations == 9) { - Application.RequestStop (); - } + } else if (iterations == 8) Application.RequestStop (); +else if (iterations == 9) Application.RequestStop (); }; Application.Run (); @@ -960,9 +956,7 @@ public void Mouse_Drag_On_Top_With_Superview_Not_Null () Assert.Null (Application.MouseGrabView); - } else if (iterations == 8) { - Application.RequestStop (); - } + } else if (iterations == 8) Application.RequestStop (); }; Application.Run (); diff --git a/UnitTests/WindowTests.cs b/UnitTests/TopLevels/WindowTests.cs similarity index 96% rename from UnitTests/WindowTests.cs rename to UnitTests/TopLevels/WindowTests.cs index d296ba1787..840105f1ae 100644 --- a/UnitTests/WindowTests.cs +++ b/UnitTests/TopLevels/WindowTests.cs @@ -1,13 +1,14 @@ using System; using Xunit; using Xunit.Abstractions; -using GraphViewTests = Terminal.Gui.Views.GraphViewTests; +//using GraphViewTests = Terminal.Gui.Views.GraphViewTests; // Alias Console to MockConsole so we don't accidentally use Console using Console = Terminal.Gui.FakeConsole; using NStack; +using Terminal.Gui; -namespace Terminal.Gui.Core { +namespace Terminal.Gui.TopLevelTests { public class WindowTests { readonly ITestOutputHelper output; @@ -22,7 +23,7 @@ public void New_Initializes () // Parameterless var r = new Window (); Assert.NotNull (r); - Assert.Equal(ustring.Empty, r.Title); + Assert.Equal (ustring.Empty, r.Title); Assert.Equal (LayoutStyle.Computed, r.LayoutStyle); Assert.Equal ("Window()({X=0,Y=0,Width=0,Height=0})", r.ToString ()); Assert.True (r.CanFocus); @@ -116,13 +117,13 @@ public void Set_Title_Fires_TitleChanging () r.Title = expectedDuring = expectedAfter = "title"; Assert.Equal (expectedAfter, r.Title.ToString ()); - expectedOld = r.Title.ToString(); + expectedOld = r.Title.ToString (); r.Title = expectedDuring = expectedAfter = "a different title"; Assert.Equal (expectedAfter, r.Title.ToString ()); // Now setup cancelling the change and change it back to "title" cancel = true; - expectedOld = r.Title.ToString(); + expectedOld = r.Title.ToString (); r.Title = expectedDuring = "title"; Assert.Equal (expectedAfter, r.Title.ToString ()); r.Dispose (); @@ -154,7 +155,7 @@ public void Set_Title_Fires_TitleChanged () r.Dispose (); } - [Fact,AutoInitShutdown] + [Fact, AutoInitShutdown] public void MenuBar_And_StatusBar_Inside_Window () { var menu = new MenuBar (new MenuBarItem [] { @@ -175,7 +176,7 @@ public void MenuBar_And_StatusBar_Inside_Window () var fv = new FrameView ("Frame View") { Y = 1, - Width = Dim.Fill(), + Width = Dim.Fill (), Height = Dim.Fill (1) }; var win = new Window (); diff --git a/UnitTests/WizardTests.cs b/UnitTests/TopLevels/WizardTests.cs similarity index 93% rename from UnitTests/WizardTests.cs rename to UnitTests/TopLevels/WizardTests.cs index aad4ae94bb..b48d306d59 100644 --- a/UnitTests/WizardTests.cs +++ b/UnitTests/TopLevels/WizardTests.cs @@ -9,7 +9,7 @@ using Xunit.Abstractions; using NStack; -namespace Terminal.Gui.Views { +namespace Terminal.Gui.TopLevelTests { public class WizardTests { readonly ITestOutputHelper output; @@ -92,7 +92,7 @@ public void WizardStep_Set_Title_Fires_TitleChanged () [Fact, AutoInitShutdown] public void DefaultConstructor_SizedProperly () { - var d = ((FakeDriver)Application.Driver); + var d = (FakeDriver)Application.Driver; var wizard = new Wizard (); Assert.NotEqual (0, wizard.Width); @@ -104,7 +104,7 @@ public void DefaultConstructor_SizedProperly () // and that the title is correct public void ZeroStepWizard_Shows () { - var d = ((FakeDriver)Application.Driver); + var d = (FakeDriver)Application.Driver; var title = "1234"; var stepTitle = ""; @@ -118,12 +118,12 @@ public void ZeroStepWizard_Shows () var btnNextText = "Finish"; var btnNext = $"{d.LeftBracket}{d.LeftDefaultIndicator} {btnNextText} {d.RightDefaultIndicator}{d.RightBracket}"; - var topRow = $"{d.ULDCorner} {title}{stepTitle} {new String (d.HDLine.ToString () [0], width - title.Length - stepTitle.Length - 4)}{d.URDCorner}"; - var row2 = $"{d.VDLine}{new String (' ', width - 2)}{d.VDLine}"; + var topRow = $"{d.ULDCorner} {title}{stepTitle} {new string (d.HDLine.ToString () [0], width - title.Length - stepTitle.Length - 4)}{d.URDCorner}"; + var row2 = $"{d.VDLine}{new string (' ', width - 2)}{d.VDLine}"; var row3 = row2; - var separatorRow = $"{d.VDLine}{new String (' ', width - 2)}{d.VDLine}"; - var buttonRow = $"{d.VDLine}{btnBack}{new String (' ', width - btnBack.Length - btnNext.Length - 2)}{btnNext}{d.VDLine}"; - var bottomRow = $"{d.LLDCorner}{new String (d.HDLine.ToString () [0], width - 2)}{d.LRDCorner}"; + var separatorRow = $"{d.VDLine}{new string (' ', width - 2)}{d.VDLine}"; + var buttonRow = $"{d.VDLine}{btnBack}{new string (' ', width - btnBack.Length - btnNext.Length - 2)}{btnNext}{d.VDLine}"; + var bottomRow = $"{d.LLDCorner}{new string (d.HDLine.ToString () [0], width - 2)}{d.LRDCorner}"; var wizard = new Wizard (title) { Width = width, Height = height }; Application.End (Application.Begin (wizard)); @@ -135,7 +135,7 @@ public void ZeroStepWizard_Shows () // and that the title is correct public void OneStepWizard_Shows () { - var d = ((FakeDriver)Application.Driver); + var d = (FakeDriver)Application.Driver; var title = "1234"; var stepTitle = "ABCD"; @@ -149,13 +149,13 @@ public void OneStepWizard_Shows () var btnNextText = "Finish"; // "Next"; var btnNext = $"{d.LeftBracket}{d.LeftDefaultIndicator} {btnNextText} {d.RightDefaultIndicator}{d.RightBracket}"; - var topRow = $"{d.ULDCorner} {title} - {stepTitle} {new String (d.HDLine.ToString () [0], width - title.Length - stepTitle.Length - 7)}{d.URDCorner}"; - var row2 = $"{d.VDLine}{new String (' ', width - 2)}{d.VDLine}"; + var topRow = $"{d.ULDCorner} {title} - {stepTitle} {new string (d.HDLine.ToString () [0], width - title.Length - stepTitle.Length - 7)}{d.URDCorner}"; + var row2 = $"{d.VDLine}{new string (' ', width - 2)}{d.VDLine}"; var row3 = row2; var row4 = row3; - var separatorRow = $"{d.VDLine}{new String (d.HLine.ToString () [0], width - 2)}{d.VDLine}"; - var buttonRow = $"{d.VDLine}{btnBack}{new String (' ', width - btnBack.Length - btnNext.Length - 2)}{btnNext}{d.VDLine}"; - var bottomRow = $"{d.LLDCorner}{new String (d.HDLine.ToString () [0], width - 2)}{d.LRDCorner}"; + var separatorRow = $"{d.VDLine}{new string (d.HLine.ToString () [0], width - 2)}{d.VDLine}"; + var buttonRow = $"{d.VDLine}{btnBack}{new string (' ', width - btnBack.Length - btnNext.Length - 2)}{btnNext}{d.VDLine}"; + var bottomRow = $"{d.LLDCorner}{new string (d.HDLine.ToString () [0], width - 2)}{d.LRDCorner}"; var wizard = new Wizard (title) { Width = width, Height = height }; wizard.AddStep (new Wizard.WizardStep (stepTitle)); @@ -207,7 +207,7 @@ public void ThreeStepWizard_Next_Shows_Steps () // this test is needed because Wizard overrides Dialog's title behavior ("Title - StepTitle") public void Setting_Title_Works () { - var d = ((FakeDriver)Application.Driver); + var d = (FakeDriver)Application.Driver; var title = "1234"; var stepTitle = " - ABCD"; @@ -219,13 +219,13 @@ public void Setting_Title_Works () var btnNextText = "Finish"; var btnNext = $"{d.LeftBracket}{d.LeftDefaultIndicator} {btnNextText} {d.RightDefaultIndicator}{d.RightBracket}"; - var topRow = $"{d.ULDCorner} {title}{stepTitle} {new String (d.HDLine.ToString () [0], width - title.Length - stepTitle.Length - 4)}{d.URDCorner}"; - var separatorRow = $"{d.VDLine}{new String (d.HLine.ToString () [0], width - 2)}{d.VDLine}"; + var topRow = $"{d.ULDCorner} {title}{stepTitle} {new string (d.HDLine.ToString () [0], width - title.Length - stepTitle.Length - 4)}{d.URDCorner}"; + var separatorRow = $"{d.VDLine}{new string (d.HLine.ToString () [0], width - 2)}{d.VDLine}"; // Once this is fixed, revert to commented out line: https://github.com/gui-cs/Terminal.Gui/issues/1791 - var buttonRow = $"{d.VDLine}{new String (' ', width - btnNext.Length - 2)}{btnNext}{d.VDLine}"; + var buttonRow = $"{d.VDLine}{new string (' ', width - btnNext.Length - 2)}{btnNext}{d.VDLine}"; //var buttonRow = $"{d.VDLine}{new String (' ', width - btnNext.Length - 2)}{btnNext}{d.VDLine}"; - var bottomRow = $"{d.LLDCorner}{new String (d.HDLine.ToString () [0], width - 2)}{d.LRDCorner}"; + var bottomRow = $"{d.LLDCorner}{new string (d.HDLine.ToString () [0], width - 2)}{d.LRDCorner}"; var wizard = new Wizard (title) { Width = width, Height = height }; wizard.AddStep (new Wizard.WizardStep ("ABCD")); @@ -560,13 +560,13 @@ public void Finish_Button_Closes () runstate = Application.Begin (wizard); Application.RunMainLoopIteration (ref runstate, true, ref firstIteration); - Assert.Equal (step1.Title.ToString(), wizard.CurrentStep.Title.ToString()); + Assert.Equal (step1.Title.ToString (), wizard.CurrentStep.Title.ToString ()); wizard.NextFinishButton.OnClicked (); Assert.False (finishedFired); Assert.False (closedFired); Assert.Equal (step2.Title.ToString (), wizard.CurrentStep.Title.ToString ()); - Assert.Equal (wizard.GetLastStep().Title.ToString(), wizard.CurrentStep.Title.ToString ()); + Assert.Equal (wizard.GetLastStep ().Title.ToString (), wizard.CurrentStep.Title.ToString ()); wizard.NextFinishButton.OnClicked (); Application.End (runstate); Assert.True (finishedFired); diff --git a/UnitTests/DimTests.cs b/UnitTests/Types/DimTests.cs similarity index 99% rename from UnitTests/DimTests.cs rename to UnitTests/Types/DimTests.cs index d474f61350..ef71f012c2 100644 --- a/UnitTests/DimTests.cs +++ b/UnitTests/Types/DimTests.cs @@ -6,14 +6,13 @@ using System.Linq; using System.Threading; using Terminal.Gui; -using Terminal.Gui.Views; using Xunit; using Xunit.Abstractions; // Alias Console to MockConsole so we don't accidentally use Console using Console = Terminal.Gui.FakeConsole; -namespace Terminal.Gui.Core { +namespace Terminal.Gui.TypeTests { public class DimTests { readonly ITestOutputHelper output; @@ -22,7 +21,7 @@ public DimTests (ITestOutputHelper output) this.output = output; Console.OutputEncoding = System.Text.Encoding.Default; // Change current culture - CultureInfo culture = CultureInfo.CreateSpecificCulture ("en-US"); + var culture = CultureInfo.CreateSpecificCulture ("en-US"); Thread.CurrentThread.CurrentCulture = culture; Thread.CurrentThread.CurrentUICulture = culture; } @@ -646,9 +645,7 @@ public void Dim_Add_Operator () }; Application.Iteration += () => { - while (count < 20) { - field.OnKeyDown (new KeyEvent (Key.Enter, new KeyModifiers ())); - } + while (count < 20) field.OnKeyDown (new KeyEvent (Key.Enter, new KeyModifiers ())); Application.RequestStop (); }; @@ -1091,9 +1088,7 @@ public void Dim_Subtract_Operator () }; Application.Iteration += () => { - while (count > 0) { - field.OnKeyDown (new KeyEvent (Key.Enter, new KeyModifiers ())); - } + while (count > 0) field.OnKeyDown (new KeyEvent (Key.Enter, new KeyModifiers ())); Application.RequestStop (); }; diff --git a/UnitTests/PointTests.cs b/UnitTests/Types/PointTests.cs similarity index 97% rename from UnitTests/PointTests.cs rename to UnitTests/Types/PointTests.cs index 95c1b3cf2d..e1af208491 100644 --- a/UnitTests/PointTests.cs +++ b/UnitTests/Types/PointTests.cs @@ -1,7 +1,7 @@ using System; using Xunit; -namespace Terminal.Gui.Types { +namespace Terminal.Gui.TypeTests { public class PointTests { [Fact] public void Point_New () diff --git a/UnitTests/PosTests.cs b/UnitTests/Types/PosTests.cs similarity index 99% rename from UnitTests/PosTests.cs rename to UnitTests/Types/PosTests.cs index 24a29f0397..858d956b7d 100644 --- a/UnitTests/PosTests.cs +++ b/UnitTests/Types/PosTests.cs @@ -5,14 +5,13 @@ using System.IO; using System.Linq; using Terminal.Gui; -using Terminal.Gui.Views; using Xunit; using Xunit.Abstractions; // Alias Console to MockConsole so we don't accidentally use Console using Console = Terminal.Gui.FakeConsole; -namespace Terminal.Gui.Core { +namespace Terminal.Gui.TypeTests { public class PosTests { readonly ITestOutputHelper output; diff --git a/UnitTests/RectTests.cs b/UnitTests/Types/RectTests.cs similarity index 98% rename from UnitTests/RectTests.cs rename to UnitTests/Types/RectTests.cs index 3b18cd3d75..62e1cc35be 100644 --- a/UnitTests/RectTests.cs +++ b/UnitTests/Types/RectTests.cs @@ -1,7 +1,7 @@ using System; using Xunit; -namespace Terminal.Gui.Types { +namespace Terminal.Gui.TypeTests { public class RectTests { [Fact] public void Rect_New () diff --git a/UnitTests/SizeTests.cs b/UnitTests/Types/SizeTests.cs similarity index 98% rename from UnitTests/SizeTests.cs rename to UnitTests/Types/SizeTests.cs index 6924e9668f..9783dac5b7 100644 --- a/UnitTests/SizeTests.cs +++ b/UnitTests/Types/SizeTests.cs @@ -1,7 +1,7 @@ using System; using Xunit; -namespace Terminal.Gui.Types { +namespace Terminal.Gui.TypeTests { public class SizeTests { [Fact] public void Size_New () diff --git a/UnitTests/ScenarioTests.cs b/UnitTests/UICatalog/ScenarioTests.cs similarity index 99% rename from UnitTests/ScenarioTests.cs rename to UnitTests/UICatalog/ScenarioTests.cs index 18d87bd891..a884bdc5c8 100644 --- a/UnitTests/ScenarioTests.cs +++ b/UnitTests/UICatalog/ScenarioTests.cs @@ -11,7 +11,7 @@ // Alias Console to MockConsole so we don't accidentally use Console using Console = Terminal.Gui.FakeConsole; -namespace UICatalog { +namespace UICatalog.Tests { public class ScenarioTests { readonly ITestOutputHelper output; diff --git a/UnitTests/AllViewsTests.cs b/UnitTests/Views/AllViewsTests.cs similarity index 99% rename from UnitTests/AllViewsTests.cs rename to UnitTests/Views/AllViewsTests.cs index a68d2f5104..24721e2701 100644 --- a/UnitTests/AllViewsTests.cs +++ b/UnitTests/Views/AllViewsTests.cs @@ -5,7 +5,7 @@ using Xunit; using System.IO; -namespace Terminal.Gui.Views { +namespace Terminal.Gui.ViewTests { public class AllViewsTests { [Fact] public void AllViews_Tests_All_Constructors () diff --git a/UnitTests/AutocompleteTests.cs b/UnitTests/Views/AutocompleteTests.cs similarity index 99% rename from UnitTests/AutocompleteTests.cs rename to UnitTests/Views/AutocompleteTests.cs index 783546b058..51dd0076ce 100644 --- a/UnitTests/AutocompleteTests.cs +++ b/UnitTests/Views/AutocompleteTests.cs @@ -7,7 +7,7 @@ using Terminal.Gui; using Xunit; -namespace Terminal.Gui.Core { +namespace Terminal.Gui.ViewTests { public class AutocompleteTests { [Fact] diff --git a/UnitTests/ButtonTests.cs b/UnitTests/Views/ButtonTests.cs similarity index 99% rename from UnitTests/ButtonTests.cs rename to UnitTests/Views/ButtonTests.cs index d2ee77845d..01fd330f26 100644 --- a/UnitTests/ButtonTests.cs +++ b/UnitTests/Views/ButtonTests.cs @@ -2,7 +2,7 @@ using Xunit; using Xunit.Abstractions; -namespace Terminal.Gui.Views { +namespace Terminal.Gui.ViewTests { public class ButtonTests { readonly ITestOutputHelper output; diff --git a/UnitTests/CheckboxTests.cs b/UnitTests/Views/CheckboxTests.cs similarity index 99% rename from UnitTests/CheckboxTests.cs rename to UnitTests/Views/CheckboxTests.cs index 0b0264bd08..82e34b6042 100644 --- a/UnitTests/CheckboxTests.cs +++ b/UnitTests/Views/CheckboxTests.cs @@ -6,7 +6,7 @@ using Xunit; using Xunit.Abstractions; -namespace Terminal.Gui.Views { +namespace Terminal.Gui.ViewTests { public class CheckboxTests { readonly ITestOutputHelper output; diff --git a/UnitTests/ColorPickerTests.cs b/UnitTests/Views/ColorPickerTests.cs similarity index 98% rename from UnitTests/ColorPickerTests.cs rename to UnitTests/Views/ColorPickerTests.cs index 8a33df60bb..04462d736d 100644 --- a/UnitTests/ColorPickerTests.cs +++ b/UnitTests/Views/ColorPickerTests.cs @@ -5,7 +5,7 @@ using System.Threading.Tasks; using Xunit; -namespace Terminal.Gui.Views { +namespace Terminal.Gui.ViewTests { public class ColorPickerTests { [Fact] public void Constructors () diff --git a/UnitTests/ComboBoxTests.cs b/UnitTests/Views/ComboBoxTests.cs similarity index 99% rename from UnitTests/ComboBoxTests.cs rename to UnitTests/Views/ComboBoxTests.cs index 41adc4b40d..3314614730 100644 --- a/UnitTests/ComboBoxTests.cs +++ b/UnitTests/Views/ComboBoxTests.cs @@ -4,7 +4,7 @@ using Xunit; using Xunit.Abstractions; -namespace Terminal.Gui.Views { +namespace Terminal.Gui.ViewTests { public class ComboBoxTests { ITestOutputHelper output; diff --git a/UnitTests/DateFieldTests.cs b/UnitTests/Views/DateFieldTests.cs similarity index 99% rename from UnitTests/DateFieldTests.cs rename to UnitTests/Views/DateFieldTests.cs index 9a5460d0a8..6713d36c45 100644 --- a/UnitTests/DateFieldTests.cs +++ b/UnitTests/Views/DateFieldTests.cs @@ -5,7 +5,7 @@ using System.Threading.Tasks; using Xunit; -namespace Terminal.Gui.Views { +namespace Terminal.Gui.ViewTests { public class DateFieldTests { [Fact] public void Constructors_Defaults () diff --git a/UnitTests/FrameViewTests.cs b/UnitTests/Views/FrameViewTests.cs similarity index 96% rename from UnitTests/FrameViewTests.cs rename to UnitTests/Views/FrameViewTests.cs index 11b7043386..1446b03d43 100644 --- a/UnitTests/FrameViewTests.cs +++ b/UnitTests/Views/FrameViewTests.cs @@ -5,7 +5,7 @@ using System.Threading.Tasks; using Xunit; -namespace Terminal.Gui.Views { +namespace Terminal.Gui.ViewTests { public class FrameViewTests { [Fact] public void Constuctors_Defaults () diff --git a/UnitTests/GraphViewTests.cs b/UnitTests/Views/GraphViewTests.cs similarity index 99% rename from UnitTests/GraphViewTests.cs rename to UnitTests/Views/GraphViewTests.cs index 17ef78697b..3b88089b60 100644 --- a/UnitTests/GraphViewTests.cs +++ b/UnitTests/Views/GraphViewTests.cs @@ -11,7 +11,7 @@ using Xunit.Abstractions; using Rune = System.Rune; -namespace Terminal.Gui.Views { +namespace Terminal.Gui.ViewTests { #region Helper Classes class FakeHAxis : HorizontalAxis { diff --git a/UnitTests/HexViewTests.cs b/UnitTests/Views/HexViewTests.cs similarity index 99% rename from UnitTests/HexViewTests.cs rename to UnitTests/Views/HexViewTests.cs index 5f54d40364..7e8cc02f26 100644 --- a/UnitTests/HexViewTests.cs +++ b/UnitTests/Views/HexViewTests.cs @@ -6,7 +6,7 @@ using System.Threading.Tasks; using Xunit; -namespace Terminal.Gui.Views { +namespace Terminal.Gui.ViewTests { public class HexViewTests { [Fact] public void Constructors_Defaults () diff --git a/UnitTests/LineViewTests.cs b/UnitTests/Views/LineViewTests.cs similarity index 96% rename from UnitTests/LineViewTests.cs rename to UnitTests/Views/LineViewTests.cs index 99b581be6b..328065f9d5 100644 --- a/UnitTests/LineViewTests.cs +++ b/UnitTests/Views/LineViewTests.cs @@ -1,7 +1,7 @@ using Terminal.Gui.Graphs; using Xunit; -namespace Terminal.Gui.Views { +namespace Terminal.Gui.ViewTests { public class LineViewTests { [Fact] diff --git a/UnitTests/ListViewTests.cs b/UnitTests/Views/ListViewTests.cs similarity index 99% rename from UnitTests/ListViewTests.cs rename to UnitTests/Views/ListViewTests.cs index 389a4137a5..01e7848101 100644 --- a/UnitTests/ListViewTests.cs +++ b/UnitTests/Views/ListViewTests.cs @@ -7,7 +7,7 @@ using Xunit; using Xunit.Abstractions; -namespace Terminal.Gui.Views { +namespace Terminal.Gui.ViewTests { public class ListViewTests { readonly ITestOutputHelper output; diff --git a/UnitTests/PanelViewTests.cs b/UnitTests/Views/PanelViewTests.cs similarity index 99% rename from UnitTests/PanelViewTests.cs rename to UnitTests/Views/PanelViewTests.cs index 3d596aaeb3..4ccd85f013 100644 --- a/UnitTests/PanelViewTests.cs +++ b/UnitTests/Views/PanelViewTests.cs @@ -6,7 +6,7 @@ using Xunit; using Xunit.Abstractions; -namespace Terminal.Gui.Views { +namespace Terminal.Gui.ViewTests { public class PanelViewTests { readonly ITestOutputHelper output; diff --git a/UnitTests/ProgressBarTests.cs b/UnitTests/Views/ProgressBarTests.cs similarity index 99% rename from UnitTests/ProgressBarTests.cs rename to UnitTests/Views/ProgressBarTests.cs index 8e5ffdbe23..b546cecb94 100644 --- a/UnitTests/ProgressBarTests.cs +++ b/UnitTests/Views/ProgressBarTests.cs @@ -5,7 +5,7 @@ using System.Threading.Tasks; using Xunit; -namespace Terminal.Gui.Views { +namespace Terminal.Gui.ViewTests { public class ProgressBarTests { [Fact] [AutoInitShutdown] diff --git a/UnitTests/RadioGroupTests.cs b/UnitTests/Views/RadioGroupTests.cs similarity index 99% rename from UnitTests/RadioGroupTests.cs rename to UnitTests/Views/RadioGroupTests.cs index 489f80897f..ec2e76a18b 100644 --- a/UnitTests/RadioGroupTests.cs +++ b/UnitTests/Views/RadioGroupTests.cs @@ -6,7 +6,7 @@ using Xunit; using Xunit.Abstractions; -namespace Terminal.Gui.Views { +namespace Terminal.Gui.ViewTests { public class RadioGroupTests { readonly ITestOutputHelper output; diff --git a/UnitTests/ScrollBarViewTests.cs b/UnitTests/Views/ScrollBarViewTests.cs similarity index 99% rename from UnitTests/ScrollBarViewTests.cs rename to UnitTests/Views/ScrollBarViewTests.cs index 8569273d83..b50d859e29 100644 --- a/UnitTests/ScrollBarViewTests.cs +++ b/UnitTests/Views/ScrollBarViewTests.cs @@ -5,7 +5,7 @@ using Xunit; using Xunit.Abstractions; -namespace Terminal.Gui.Views { +namespace Terminal.Gui.ViewTests { public class ScrollBarViewTests { readonly ITestOutputHelper output; diff --git a/UnitTests/ScrollViewTests.cs b/UnitTests/Views/ScrollViewTests.cs similarity index 99% rename from UnitTests/ScrollViewTests.cs rename to UnitTests/Views/ScrollViewTests.cs index b007d962f1..eb14fe339e 100644 --- a/UnitTests/ScrollViewTests.cs +++ b/UnitTests/Views/ScrollViewTests.cs @@ -6,7 +6,7 @@ using Xunit; using Xunit.Abstractions; -namespace Terminal.Gui.Views { +namespace Terminal.Gui.ViewTests { public class ScrollViewTests { readonly ITestOutputHelper output; diff --git a/UnitTests/StatusBarTests.cs b/UnitTests/Views/StatusBarTests.cs similarity index 99% rename from UnitTests/StatusBarTests.cs rename to UnitTests/Views/StatusBarTests.cs index e27a2910e9..89540d6073 100644 --- a/UnitTests/StatusBarTests.cs +++ b/UnitTests/Views/StatusBarTests.cs @@ -2,7 +2,7 @@ using Xunit; using Xunit.Abstractions; -namespace Terminal.Gui.Views { +namespace Terminal.Gui.ViewTests { public class StatusBarTests { readonly ITestOutputHelper output; diff --git a/UnitTests/TabViewTests.cs b/UnitTests/Views/TabViewTests.cs similarity index 99% rename from UnitTests/TabViewTests.cs rename to UnitTests/Views/TabViewTests.cs index a98f03566b..79da1e3a41 100644 --- a/UnitTests/TabViewTests.cs +++ b/UnitTests/Views/TabViewTests.cs @@ -8,7 +8,7 @@ using System.Globalization; using Xunit.Abstractions; -namespace Terminal.Gui.Views { +namespace Terminal.Gui.ViewTests { public class TabViewTests { readonly ITestOutputHelper output; diff --git a/UnitTests/TableViewTests.cs b/UnitTests/Views/TableViewTests.cs similarity index 99% rename from UnitTests/TableViewTests.cs rename to UnitTests/Views/TableViewTests.cs index 5b50cede89..bb08a22ffa 100644 --- a/UnitTests/TableViewTests.cs +++ b/UnitTests/Views/TableViewTests.cs @@ -9,7 +9,7 @@ using Xunit.Abstractions; using System.Reflection; -namespace Terminal.Gui.Views { +namespace Terminal.Gui.ViewTests { public class TableViewTests { readonly ITestOutputHelper output; diff --git a/UnitTests/TextFieldTests.cs b/UnitTests/Views/TextFieldTests.cs similarity index 99% rename from UnitTests/TextFieldTests.cs rename to UnitTests/Views/TextFieldTests.cs index a931f72e0b..860cfb68c1 100644 --- a/UnitTests/TextFieldTests.cs +++ b/UnitTests/Views/TextFieldTests.cs @@ -2,7 +2,7 @@ using System.Reflection; using Xunit; -namespace Terminal.Gui.Views { +namespace Terminal.Gui.ViewTests { public class TextFieldTests { // This class enables test functions annotated with the [InitShutdown] attribute diff --git a/UnitTests/TextValidateFieldTests.cs b/UnitTests/Views/TextValidateFieldTests.cs similarity index 99% rename from UnitTests/TextValidateFieldTests.cs rename to UnitTests/Views/TextValidateFieldTests.cs index 3275db3768..94999c363d 100644 --- a/UnitTests/TextValidateFieldTests.cs +++ b/UnitTests/Views/TextValidateFieldTests.cs @@ -5,7 +5,7 @@ using Xunit; -namespace Terminal.Gui.Views { +namespace Terminal.Gui.ViewTests { public class TextValidateField_NET_Provider_Tests { diff --git a/UnitTests/TextViewTests.cs b/UnitTests/Views/TextViewTests.cs similarity index 99% rename from UnitTests/TextViewTests.cs rename to UnitTests/Views/TextViewTests.cs index 90debaafb9..5add478f6d 100644 --- a/UnitTests/TextViewTests.cs +++ b/UnitTests/Views/TextViewTests.cs @@ -6,7 +6,7 @@ using Xunit; using Xunit.Abstractions; -namespace Terminal.Gui.Views { +namespace Terminal.Gui.ViewTests { public class TextViewTests { private static TextView _textView; readonly ITestOutputHelper output; diff --git a/UnitTests/TimeFieldTests.cs b/UnitTests/Views/TimeFieldTests.cs similarity index 99% rename from UnitTests/TimeFieldTests.cs rename to UnitTests/Views/TimeFieldTests.cs index f9d08c3730..410e39857f 100644 --- a/UnitTests/TimeFieldTests.cs +++ b/UnitTests/Views/TimeFieldTests.cs @@ -5,7 +5,7 @@ using System.Threading.Tasks; using Xunit; -namespace Terminal.Gui.Views { +namespace Terminal.Gui.ViewTests { public class TimeFieldTests { [Fact] public void Constructors_Defaults () diff --git a/UnitTests/TreeViewTests.cs b/UnitTests/Views/TreeViewTests.cs similarity index 99% rename from UnitTests/TreeViewTests.cs rename to UnitTests/Views/TreeViewTests.cs index 8cbb5825d7..3390339235 100644 --- a/UnitTests/TreeViewTests.cs +++ b/UnitTests/Views/TreeViewTests.cs @@ -8,7 +8,7 @@ using Xunit; using Xunit.Abstractions; -namespace Terminal.Gui.Views { +namespace Terminal.Gui.ViewTests { public class TreeViewTests { diff --git a/UnitTests/ViewTests.cs b/UnitTests/Views/ViewTests.cs similarity index 99% rename from UnitTests/ViewTests.cs rename to UnitTests/Views/ViewTests.cs index dd5fbf3ea7..b1a22046cc 100644 --- a/UnitTests/ViewTests.cs +++ b/UnitTests/Views/ViewTests.cs @@ -1,12 +1,12 @@ using System; using Xunit; using Xunit.Abstractions; -using GraphViewTests = Terminal.Gui.Views.GraphViewTests; +//using GraphViewTests = Terminal.Gui.Views.GraphViewTests; // Alias Console to MockConsole so we don't accidentally use Console using Console = Terminal.Gui.FakeConsole; -namespace Terminal.Gui.Core { +namespace Terminal.Gui.ViewTests { public class ViewTests { readonly ITestOutputHelper output;