diff --git a/UnitTests/AssemblyInfo.cs b/UnitTests/AssemblyInfo.cs index ddf16f7b8b..e03a2fd4d1 100644 --- a/UnitTests/AssemblyInfo.cs +++ b/UnitTests/AssemblyInfo.cs @@ -7,28 +7,3 @@ // Since Application is a singleton we can't run tests in parallel [assembly: CollectionBehavior (DisableTestParallelization = true)] -// This class enables test functions annotated with the [AutoInitShutdown] attribute to -// automatically call Application.Init before called and Application.Shutdown after -// -// This is necessary because a) Application is a singleton and Init/Shutdown must be called -// as a pair, and b) all unit test functions should be atomic. -[AttributeUsage (AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = false, Inherited = true)] -public class AutoInitShutdownAttribute : Xunit.Sdk.BeforeAfterTestAttribute { - - static bool _init = false; - public override void Before (MethodInfo methodUnderTest) - { - if (_init) { - throw new InvalidOperationException ("After did not run."); - } - - Application.Init (new FakeDriver (), new FakeMainLoop (() => FakeConsole.ReadKey (true))); - _init = true; - } - - public override void After (MethodInfo methodUnderTest) - { - Application.Shutdown (); - _init = false; - } -} \ No newline at end of file diff --git a/UnitTests/ButtonTests.cs b/UnitTests/ButtonTests.cs index 43808ea81f..d2ee77845d 100644 --- a/UnitTests/ButtonTests.cs +++ b/UnitTests/ButtonTests.cs @@ -29,7 +29,7 @@ public void Constructors_Defaults () var expected = @" [ ] "; - GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Application.End (rs); btn = new Button ("ARGS", true) { Text = "Test" }; @@ -47,7 +47,7 @@ [ ] expected = @" [◦ Test ◦] "; - GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Application.End (rs); btn = new Button (3, 4, "Test", true); @@ -65,7 +65,7 @@ [ ] expected = @" [◦ Test ◦] "; - GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Application.End (rs); } @@ -235,7 +235,7 @@ public void Update_Only_On_Or_After_Initialize () └────────────────────────────┘ "; - var pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + var pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new Rect (0, 0, 30, 5), pos); } @@ -273,7 +273,7 @@ public void Update_Parameterless_Only_On_Or_After_Initialize () └────────────────────────────┘ "; - var pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + var pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new Rect (0, 0, 30, 5), pos); } @@ -310,7 +310,7 @@ public void AutoSize_Stays_True_With_EmptyText () └────────────────────────────┘ "; - GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + TestHelpers.AssertDriverContentsWithFrameAre (expected, output); } [Fact, AutoInitShutdown] @@ -342,7 +342,7 @@ public void AutoSize_Stays_True_Center () └────────────────────────────┘ "; - GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.True (btn.AutoSize); btn.Text = "Say Hello 你 changed"; @@ -356,7 +356,7 @@ public void AutoSize_Stays_True_Center () └────────────────────────────┘ "; - GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + TestHelpers.AssertDriverContentsWithFrameAre (expected, output); } [Fact, AutoInitShutdown] @@ -389,7 +389,7 @@ public void AutoSize_Stays_True_AnchorEnd () └────────────────────────────┘ "; - GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.True (btn.AutoSize); btn.Text = "Say Hello 你 changed"; @@ -403,7 +403,7 @@ public void AutoSize_Stays_True_AnchorEnd () └────────────────────────────┘ "; - GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + TestHelpers.AssertDriverContentsWithFrameAre (expected, output); } [Fact, AutoInitShutdown] @@ -520,7 +520,7 @@ public void AutoSize_False_With_Fixed_Width () └────────────────────────────────────────────────────┘ "; - GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + TestHelpers.AssertDriverContentsWithFrameAre (expected, output); } [Fact, AutoInitShutdown] @@ -550,7 +550,7 @@ public void Pos_Center_Layout_AutoSize_True () └────────────────────────────┘ "; - GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + TestHelpers.AssertDriverContentsWithFrameAre (expected, output); } [Fact, AutoInitShutdown] @@ -582,7 +582,7 @@ public void Pos_Center_Layout_AutoSize_False () └────────────────────────────┘ "; - GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + TestHelpers.AssertDriverContentsWithFrameAre (expected, output); } } } diff --git a/UnitTests/CheckboxTests.cs b/UnitTests/CheckboxTests.cs index 99bbdf41fa..0b0264bd08 100644 --- a/UnitTests/CheckboxTests.cs +++ b/UnitTests/CheckboxTests.cs @@ -84,7 +84,7 @@ public void KeyBindings_Command () √ Test "; - var pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + var pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new Rect (0, 0, 6, 1), pos); } @@ -123,7 +123,7 @@ public void AutoSize_StaysVisible () "; // Positive test - var pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + var pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new Rect (0, 0, 30, 5), pos); // Also Positive test @@ -139,7 +139,7 @@ public void AutoSize_StaysVisible () └────────────────────────────┘ "; - GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new Rect (0, 0, 30, 5), pos); checkBox.Checked = true; @@ -153,7 +153,7 @@ public void AutoSize_StaysVisible () └────────────────────────────┘ "; - pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new Rect (0, 0, 30, 5), pos); checkBox.AutoSize = false; @@ -169,7 +169,7 @@ public void AutoSize_StaysVisible () └────────────────────────────┘ "; - pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new Rect (0, 0, 30, 5), pos); checkBox.Width = 19; @@ -186,7 +186,7 @@ public void AutoSize_StaysVisible () └────────────────────────────┘ "; - pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new Rect (0, 0, 30, 5), pos); checkBox.AutoSize = true; @@ -200,7 +200,7 @@ public void AutoSize_StaysVisible () └────────────────────────────┘ "; - pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new Rect (0, 0, 30, 5), pos); } @@ -240,7 +240,7 @@ public void TextAlignment_Left () └────────────────────────────┘ "; - var pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + var pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new Rect (0, 0, 30, 5), pos); checkBox.Checked = true; @@ -253,7 +253,7 @@ public void TextAlignment_Left () └────────────────────────────┘ "; - pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new Rect (0, 0, 30, 5), pos); } @@ -294,7 +294,7 @@ public void TextAlignment_Centered () └────────────────────────────┘ "; - var pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + var pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new Rect (0, 0, 30, 5), pos); checkBox.Checked = true; @@ -307,7 +307,7 @@ public void TextAlignment_Centered () └────────────────────────────┘ "; - pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new Rect (0, 0, 30, 5), pos); } @@ -364,7 +364,7 @@ public void TextAlignment_Justified () └────────────────────────────┘ "; - var pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + var pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new Rect (0, 0, 30, 6), pos); checkBox1.Checked = true; @@ -383,7 +383,7 @@ public void TextAlignment_Justified () └────────────────────────────┘ "; - pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new Rect (0, 0, 30, 6), pos); } @@ -424,7 +424,7 @@ public void TextAlignment_Right () └────────────────────────────┘ "; - var pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + var pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new Rect (0, 0, 30, 5), pos); checkBox.Checked = true; @@ -437,7 +437,7 @@ public void TextAlignment_Right () └────────────────────────────┘ "; - pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new Rect (0, 0, 30, 5), pos); } @@ -470,7 +470,7 @@ public void AutoSize_Stays_True_AnchorEnd_Without_HotKeySpecifier () └────────────────────────────┘ "; - GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.True (checkBox.AutoSize); checkBox.Text = "Check this out 你 changed"; @@ -484,7 +484,7 @@ public void AutoSize_Stays_True_AnchorEnd_Without_HotKeySpecifier () └────────────────────────────┘ "; - GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + TestHelpers.AssertDriverContentsWithFrameAre (expected, output); } [Fact, AutoInitShutdown] @@ -516,7 +516,7 @@ public void AutoSize_Stays_True_AnchorEnd_With_HotKeySpecifier () └────────────────────────────┘ "; - GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.True (checkBox.AutoSize); checkBox.Text = "Check this out 你 changed"; @@ -530,7 +530,7 @@ public void AutoSize_Stays_True_AnchorEnd_With_HotKeySpecifier () └────────────────────────────┘ "; - GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + TestHelpers.AssertDriverContentsWithFrameAre (expected, output); } } } diff --git a/UnitTests/ComboBoxTests.cs b/UnitTests/ComboBoxTests.cs index e6e0f731e5..bf5b385c08 100644 --- a/UnitTests/ComboBoxTests.cs +++ b/UnitTests/ComboBoxTests.cs @@ -144,7 +144,7 @@ public void KeyBindings_Command () Assert.Equal (0, cb.SelectedItem); Assert.Equal ("One", cb.Text); Application.Begin (Application.Top); - GraphViewTests.AssertDriverContentsWithFrameAre (@" + TestHelpers.AssertDriverContentsWithFrameAre (@" One ▼ One ", output); @@ -154,7 +154,7 @@ public void KeyBindings_Command () Assert.Equal (1, cb.SelectedItem); Assert.Equal ("Two", cb.Text); Application.Begin (Application.Top); - GraphViewTests.AssertDriverContentsWithFrameAre (@" + TestHelpers.AssertDriverContentsWithFrameAre (@" Two ▼ Two ", output); @@ -164,7 +164,7 @@ public void KeyBindings_Command () Assert.Equal (2, cb.SelectedItem); Assert.Equal ("Three", cb.Text); Application.Begin (Application.Top); - GraphViewTests.AssertDriverContentsWithFrameAre (@" + TestHelpers.AssertDriverContentsWithFrameAre (@" Three ▼ Three ", output); @@ -809,7 +809,7 @@ public void HideDropdownListOnClick_True_Highlight_Current_Item () Assert.Equal (-1, cb.SelectedItem); Assert.Equal ("", cb.Text); cb.Redraw (cb.Bounds); - GraphViewTests.AssertDriverContentsWithFrameAre (@" + TestHelpers.AssertDriverContentsWithFrameAre (@" ▼ One Two @@ -824,7 +824,7 @@ public void HideDropdownListOnClick_True_Highlight_Current_Item () cb.Subviews [1].GetNormalColor () }; - GraphViewTests.AssertDriverColorsAre (@" + TestHelpers.AssertDriverColorsAre (@" 000000 00000 22222 @@ -836,7 +836,7 @@ cb.Subviews [1].GetNormalColor () Assert.Equal (-1, cb.SelectedItem); Assert.Equal ("", cb.Text); cb.Redraw (cb.Bounds); - GraphViewTests.AssertDriverColorsAre (@" + TestHelpers.AssertDriverColorsAre (@" 000000 22222 00000 @@ -848,7 +848,7 @@ cb.Subviews [1].GetNormalColor () Assert.Equal (-1, cb.SelectedItem); Assert.Equal ("", cb.Text); cb.Redraw (cb.Bounds); - GraphViewTests.AssertDriverColorsAre (@" + TestHelpers.AssertDriverColorsAre (@" 000000 22222 22222 @@ -866,7 +866,7 @@ cb.Subviews [1].GetNormalColor () Assert.Equal (2, cb.SelectedItem); Assert.Equal ("Three", cb.Text); cb.Redraw (cb.Bounds); - GraphViewTests.AssertDriverColorsAre (@" + TestHelpers.AssertDriverColorsAre (@" 000000 22222 22222 @@ -878,7 +878,7 @@ cb.Subviews [1].GetNormalColor () Assert.Equal (2, cb.SelectedItem); Assert.Equal ("Three", cb.Text); cb.Redraw (cb.Bounds); - GraphViewTests.AssertDriverColorsAre (@" + TestHelpers.AssertDriverColorsAre (@" 000000 22222 00000 @@ -890,7 +890,7 @@ cb.Subviews [1].GetNormalColor () Assert.Equal (2, cb.SelectedItem); Assert.Equal ("Three", cb.Text); cb.Redraw (cb.Bounds); - GraphViewTests.AssertDriverColorsAre (@" + TestHelpers.AssertDriverColorsAre (@" 000000 00000 22222 diff --git a/UnitTests/ConsoleDriverTests.cs b/UnitTests/ConsoleDriverTests.cs index e9688c638b..d4d8e40fc7 100644 --- a/UnitTests/ConsoleDriverTests.cs +++ b/UnitTests/ConsoleDriverTests.cs @@ -551,7 +551,7 @@ public void AddRune_On_Clip_Left_Or_Right_Replace_Previous_Or_Next_Wide_Rune_Wit └────────────────────────────┘ "; - var pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + var pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new Rect (0, 0, 30, 10), pos); } @@ -581,7 +581,7 @@ public void Write_Do_Not_Change_On_ProcessKey () └──────────────────┘ "; - var pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + var pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new Rect (0, 0, 20, 8), pos); Assert.True (dlg.ProcessKey (new KeyEvent (Key.Tab, new KeyModifiers ()))); @@ -598,7 +598,7 @@ public void Write_Do_Not_Change_On_ProcessKey () └──────────────────┘ "; - pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new Rect (0, 0, 20, 8), pos); win.RequestStop (); diff --git a/UnitTests/ContextMenuTests.cs b/UnitTests/ContextMenuTests.cs index ad01177cc3..00b35e6ed4 100644 --- a/UnitTests/ContextMenuTests.cs +++ b/UnitTests/ContextMenuTests.cs @@ -72,7 +72,7 @@ public void Show_Hide_IsShow () └──────┘ "; - GraphViewTests.AssertDriverContentsAre (expected, output); + TestHelpers.AssertDriverContentsAre (expected, output); cm.Hide (); Assert.False (ContextMenu.IsShow); @@ -81,7 +81,7 @@ public void Show_Hide_IsShow () expected = ""; - GraphViewTests.AssertDriverContentsAre (expected, output); + TestHelpers.AssertDriverContentsAre (expected, output); } [Fact] @@ -105,7 +105,7 @@ public void Position_Changing () └──────┘ "; - GraphViewTests.AssertDriverContentsAre (expected, output); + TestHelpers.AssertDriverContentsAre (expected, output); cm.Position = new Point (5, 10); @@ -119,7 +119,7 @@ public void Position_Changing () └──────┘ "; - GraphViewTests.AssertDriverContentsAre (expected, output); + TestHelpers.AssertDriverContentsAre (expected, output); } @@ -144,7 +144,7 @@ public void MenuItens_Changing () └──────┘ "; - GraphViewTests.AssertDriverContentsAre (expected, output); + TestHelpers.AssertDriverContentsAre (expected, output); cm.MenuItems = new MenuBarItem (new MenuItem [] { new MenuItem ("First", "", null), @@ -164,7 +164,7 @@ public void MenuItens_Changing () └─────────┘ "; - GraphViewTests.AssertDriverContentsAre (expected, output); + TestHelpers.AssertDriverContentsAre (expected, output); } @@ -271,7 +271,7 @@ public void Show_Ensures_Display_Inside_The_Container_But_Preserves_Position () └──────┘ "; - var pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + var pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new Rect (72, 21, 80, 4), pos); cm.Hide (); @@ -312,7 +312,7 @@ public void Show_Ensures_Display_Inside_The_Container_Without_Overlap_The_Host ( View "; - var pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + var pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new Rect (70, 20, 78, 5), pos); cm.Hide (); @@ -347,7 +347,7 @@ public void Show_Display_Below_The_Bottom_Host_If_Has_Enough_Space () └──────┘ "; - var pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + var pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new Rect (10, 5, 18, 5), pos); cm.Hide (); @@ -370,7 +370,7 @@ public void Show_Display_Below_The_Bottom_Host_If_Has_Enough_Space () └──────┘ "; - pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new Rect (5, 10, 13, 7), pos); cm.Hide (); @@ -401,7 +401,7 @@ public void Show_Display_At_Zero_If_The_Toplevel_Width_Is_Less_Than_The_Menu_Wid └──── "; - var pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + var pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new Rect (0, 1, 5, 4), pos); cm.Hide (); @@ -431,7 +431,7 @@ public void Show_Display_At_Zero_If_The_Toplevel_Height_Is_Less_Than_The_Menu_He │ Two │ "; - var pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + var pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new Rect (0, 0, 8, 3), pos); cm.Hide (); @@ -484,7 +484,7 @@ public void ForceMinimumPosToZero_True_False () └──────┘ "; - var pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + var pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new Rect (0, 1, 8, 4), pos); cm.ForceMinimumPosToZero = false; @@ -498,7 +498,7 @@ public void ForceMinimumPosToZero_True_False () ──────┘ "; - pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new Rect (1, 0, 7, 3), pos); } @@ -611,7 +611,7 @@ File Edit F1 Help │ ^Q Quit "; - var pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + var pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new Rect (1, 0, 32, 17), pos); } @@ -675,7 +675,7 @@ File Edit F1 Help │ ^Q Quit "; - var pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + var pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new Rect (1, 0, 44, 17), pos); } @@ -707,7 +707,7 @@ public void Menus_And_SubMenus_Always_Try_To_Be_On_Screen () Assert.Equal (new Point (-1, -2), cm.Position); var top = Application.Top; Application.Begin (top); - GraphViewTests.AssertDriverContentsWithFrameAre (@" + TestHelpers.AssertDriverContentsWithFrameAre (@" ┌────────┐ │ One │ │ Two │ @@ -726,7 +726,7 @@ public void Menus_And_SubMenus_Always_Try_To_Be_On_Screen () })); Application.Refresh (); Assert.Equal (new Point (-1, -2), cm.Position); - GraphViewTests.AssertDriverContentsWithFrameAre (@" + TestHelpers.AssertDriverContentsWithFrameAre (@" ┌────────┐ │ One │ │ Two │ @@ -747,7 +747,7 @@ public void Menus_And_SubMenus_Always_Try_To_Be_On_Screen () cm.Show (); Application.Refresh (); Assert.Equal (new Point (41, -2), cm.Position); - GraphViewTests.AssertDriverContentsWithFrameAre (@" + TestHelpers.AssertDriverContentsWithFrameAre (@" ┌────────┐ │ One │ │ Two │ @@ -766,7 +766,7 @@ public void Menus_And_SubMenus_Always_Try_To_Be_On_Screen () })); Application.Refresh (); Assert.Equal (new Point (41, -2), cm.Position); - GraphViewTests.AssertDriverContentsWithFrameAre (@" + TestHelpers.AssertDriverContentsWithFrameAre (@" ┌────────┐ │ One │ │ Two │ @@ -786,7 +786,7 @@ public void Menus_And_SubMenus_Always_Try_To_Be_On_Screen () cm.Show (); Application.Refresh (); Assert.Equal (new Point (41, 9), cm.Position); - GraphViewTests.AssertDriverContentsWithFrameAre (@" + TestHelpers.AssertDriverContentsWithFrameAre (@" ┌────────┐ │ One │ │ Two │ @@ -805,7 +805,7 @@ public void Menus_And_SubMenus_Always_Try_To_Be_On_Screen () })); Application.Refresh (); Assert.Equal (new Point (41, 9), cm.Position); - GraphViewTests.AssertDriverContentsWithFrameAre (@" + TestHelpers.AssertDriverContentsWithFrameAre (@" ┌────────┐ ┌───────────┐│ One │ │ SubMenu1 ││ Two │ @@ -822,7 +822,7 @@ public void Menus_And_SubMenus_Always_Try_To_Be_On_Screen () cm.Show (); Application.Refresh (); Assert.Equal (new Point (41, 22), cm.Position); - GraphViewTests.AssertDriverContentsWithFrameAre (@" + TestHelpers.AssertDriverContentsWithFrameAre (@" ┌────────┐ │ One │ │ Two │ @@ -841,7 +841,7 @@ public void Menus_And_SubMenus_Always_Try_To_Be_On_Screen () })); Application.Refresh (); Assert.Equal (new Point (41, 22), cm.Position); - GraphViewTests.AssertDriverContentsWithFrameAre (@" + TestHelpers.AssertDriverContentsWithFrameAre (@" ┌───────────┐ │ SubMenu1 │┌────────┐ │ SubMenu2 ││ One │ @@ -858,7 +858,7 @@ public void Menus_And_SubMenus_Always_Try_To_Be_On_Screen () cm.Show (); Application.Refresh (); Assert.Equal (new Point (19, 10), cm.Position); - GraphViewTests.AssertDriverContentsWithFrameAre (@" + TestHelpers.AssertDriverContentsWithFrameAre (@" ┌────────┐ │ One │ │ Two │ @@ -877,7 +877,7 @@ public void Menus_And_SubMenus_Always_Try_To_Be_On_Screen () })); Application.Refresh (); Assert.Equal (new Point (19, 10), cm.Position); - GraphViewTests.AssertDriverContentsWithFrameAre (@" + TestHelpers.AssertDriverContentsWithFrameAre (@" ┌───────────┐────┐ │ SubMenu1 │ │ │ SubMenu2 │ │ diff --git a/UnitTests/DialogTests.cs b/UnitTests/DialogTests.cs index e25cdcc949..87cb30d049 100644 --- a/UnitTests/DialogTests.cs +++ b/UnitTests/DialogTests.cs @@ -43,28 +43,28 @@ public void ButtonAlignment_One () d.SetBufferSize (width, 3); (runstate, var _) = RunButtonTestDialog (title, width, Dialog.ButtonAlignments.Center, new Button (btnText)); - GraphViewTests.AssertDriverContentsWithFrameAre ($"{topRow}\n{buttonRow}\n{bottomRow}", output); + TestHelpers.AssertDriverContentsWithFrameAre ($"{topRow}\n{buttonRow}\n{bottomRow}", output); Application.End (runstate); // Justify buttonRow = $"{d.VLine} {d.LeftBracket} {btnText} {d.RightBracket}{d.VLine}"; Assert.Equal (width, buttonRow.Length); (runstate, var _) = RunButtonTestDialog (title, width, Dialog.ButtonAlignments.Justify, new Button (btnText)); - GraphViewTests.AssertDriverContentsWithFrameAre ($"{topRow}\n{buttonRow}\n{bottomRow}", output); + TestHelpers.AssertDriverContentsWithFrameAre ($"{topRow}\n{buttonRow}\n{bottomRow}", output); Application.End (runstate); // Right buttonRow = $"{d.VLine} {d.LeftBracket} {btnText} {d.RightBracket}{d.VLine}"; Assert.Equal (width, buttonRow.Length); (runstate, var _) = RunButtonTestDialog (title, width, Dialog.ButtonAlignments.Right, new Button (btnText)); - GraphViewTests.AssertDriverContentsWithFrameAre ($"{topRow}\n{buttonRow}\n{bottomRow}", output); + TestHelpers.AssertDriverContentsWithFrameAre ($"{topRow}\n{buttonRow}\n{bottomRow}", output); Application.End (runstate); // Left buttonRow = $"{d.VLine}{d.LeftBracket} {btnText} {d.RightBracket} {d.VLine}"; Assert.Equal (width, buttonRow.Length); (runstate, var _) = RunButtonTestDialog (title, width, Dialog.ButtonAlignments.Left, new Button (btnText)); - GraphViewTests.AssertDriverContentsWithFrameAre ($"{topRow}\n{buttonRow}\n{bottomRow}", output); + TestHelpers.AssertDriverContentsWithFrameAre ($"{topRow}\n{buttonRow}\n{bottomRow}", output); Application.End (runstate); } @@ -91,28 +91,28 @@ public void ButtonAlignment_Two () d.SetBufferSize (buttonRow.Length, 3); (runstate, var _) = RunButtonTestDialog (title, width, Dialog.ButtonAlignments.Center, new Button (btn1Text), new Button (btn2Text)); - GraphViewTests.AssertDriverContentsWithFrameAre ($"{topRow}\n{buttonRow}\n{bottomRow}", output); + TestHelpers.AssertDriverContentsWithFrameAre ($"{topRow}\n{buttonRow}\n{bottomRow}", output); Application.End (runstate); // Justify buttonRow = $@"{d.VLine}{btn1} {btn2}{d.VLine}"; Assert.Equal (width, buttonRow.Length); (runstate, var _) = RunButtonTestDialog (title, width, Dialog.ButtonAlignments.Justify, new Button (btn1Text), new Button (btn2Text)); - GraphViewTests.AssertDriverContentsWithFrameAre ($"{topRow}\n{buttonRow}\n{bottomRow}", output); + TestHelpers.AssertDriverContentsWithFrameAre ($"{topRow}\n{buttonRow}\n{bottomRow}", output); Application.End (runstate); // Right buttonRow = $@"{d.VLine} {btn1} {btn2}{d.VLine}"; Assert.Equal (width, buttonRow.Length); (runstate, var _) = RunButtonTestDialog (title, width, Dialog.ButtonAlignments.Right, new Button (btn1Text), new Button (btn2Text)); - GraphViewTests.AssertDriverContentsWithFrameAre ($"{topRow}\n{buttonRow}\n{bottomRow}", output); + TestHelpers.AssertDriverContentsWithFrameAre ($"{topRow}\n{buttonRow}\n{bottomRow}", output); Application.End (runstate); // Left buttonRow = $@"{d.VLine}{btn1} {btn2} {d.VLine}"; Assert.Equal (width, buttonRow.Length); (runstate, var _) = RunButtonTestDialog (title, width, Dialog.ButtonAlignments.Left, new Button (btn1Text), new Button (btn2Text)); - GraphViewTests.AssertDriverContentsWithFrameAre ($"{topRow}\n{buttonRow}\n{bottomRow}", output); + TestHelpers.AssertDriverContentsWithFrameAre ($"{topRow}\n{buttonRow}\n{bottomRow}", output); Application.End (runstate); } @@ -149,7 +149,7 @@ public void ButtonAlignment_Two_Hidden () //button1.Visible = false; //Application.RunMainLoopIteration (ref runstate, true, ref firstIteration); //buttonRow = $@"{d.VLine} {btn2} {d.VLine}"; - //GraphViewTests.AssertDriverContentsWithFrameAre ($"{topRow}\n{buttonRow}\n{bottomRow}", output); + //DriverAsserts.AssertDriverContentsWithFrameAre ($"{topRow}\n{buttonRow}\n{bottomRow}", output); //Application.End (runstate); // Justify @@ -160,21 +160,21 @@ public void ButtonAlignment_Two_Hidden () button1.Visible = false; Application.RunMainLoopIteration (ref runstate, true, ref firstIteration); buttonRow = $@"{d.VLine} {btn2}{d.VLine}"; - GraphViewTests.AssertDriverContentsWithFrameAre ($"{topRow}\n{buttonRow}\n{bottomRow}", output); + TestHelpers.AssertDriverContentsWithFrameAre ($"{topRow}\n{buttonRow}\n{bottomRow}", output); Application.End (runstate); //// Right //buttonRow = $@"{d.VLine} {btn1} {btn2}{d.VLine}"; //Assert.Equal (width, buttonRow.Length); //(runstate, dlg) = RunButtonTestDialog (title, width, Dialog.ButtonAlignments.Right, new Button (btn1Text), new Button (btn2Text)); - //GraphViewTests.AssertDriverContentsWithFrameAre ($"{topRow}\n{buttonRow}\n{bottomRow}", output); + //DriverAsserts.AssertDriverContentsWithFrameAre ($"{topRow}\n{buttonRow}\n{bottomRow}", output); //Application.End (runstate); //// Left //buttonRow = $@"{d.VLine}{btn1} {btn2} {d.VLine}"; //Assert.Equal (width, buttonRow.Length); //(runstate, dlg) = RunButtonTestDialog (title, width, Dialog.ButtonAlignments.Left, new Button (btn1Text), new Button (btn2Text)); - //GraphViewTests.AssertDriverContentsWithFrameAre ($"{topRow}\n{buttonRow}\n{bottomRow}", output); + //DriverAsserts.AssertDriverContentsWithFrameAre ($"{topRow}\n{buttonRow}\n{bottomRow}", output); //Application.End (runstate); } @@ -203,28 +203,28 @@ public void ButtonAlignment_Three () d.SetBufferSize (buttonRow.Length, 3); (runstate, var _) = RunButtonTestDialog (title, width, Dialog.ButtonAlignments.Center, new Button (btn1Text), new Button (btn2Text), new Button (btn3Text)); - GraphViewTests.AssertDriverContentsWithFrameAre ($"{topRow}\n{buttonRow}\n{bottomRow}", output); + TestHelpers.AssertDriverContentsWithFrameAre ($"{topRow}\n{buttonRow}\n{bottomRow}", output); Application.End (runstate); // Justify buttonRow = $@"{d.VLine}{btn1} {btn2} {btn3}{d.VLine}"; Assert.Equal (width, buttonRow.Length); (runstate, var _) = RunButtonTestDialog (title, width, Dialog.ButtonAlignments.Justify, new Button (btn1Text), new Button (btn2Text), new Button (btn3Text)); - GraphViewTests.AssertDriverContentsWithFrameAre ($"{topRow}\n{buttonRow}\n{bottomRow}", output); + TestHelpers.AssertDriverContentsWithFrameAre ($"{topRow}\n{buttonRow}\n{bottomRow}", output); Application.End (runstate); // Right buttonRow = $@"{d.VLine} {btn1} {btn2} {btn3}{d.VLine}"; Assert.Equal (width, buttonRow.Length); (runstate, var _) = RunButtonTestDialog (title, width, Dialog.ButtonAlignments.Right, new Button (btn1Text), new Button (btn2Text), new Button (btn3Text)); - GraphViewTests.AssertDriverContentsWithFrameAre ($"{topRow}\n{buttonRow}\n{bottomRow}", output); + TestHelpers.AssertDriverContentsWithFrameAre ($"{topRow}\n{buttonRow}\n{bottomRow}", output); Application.End (runstate); // Left buttonRow = $@"{d.VLine}{btn1} {btn2} {btn3} {d.VLine}"; Assert.Equal (width, buttonRow.Length); (runstate, var _) = RunButtonTestDialog (title, width, Dialog.ButtonAlignments.Left, new Button (btn1Text), new Button (btn2Text), new Button (btn3Text)); - GraphViewTests.AssertDriverContentsWithFrameAre ($"{topRow}\n{buttonRow}\n{bottomRow}", output); + TestHelpers.AssertDriverContentsWithFrameAre ($"{topRow}\n{buttonRow}\n{bottomRow}", output); Application.End (runstate); } @@ -256,28 +256,28 @@ public void ButtonAlignment_Four () // Default - Center (runstate, var _) = RunButtonTestDialog (title, width, Dialog.ButtonAlignments.Center, new Button (btn1Text), new Button (btn2Text), new Button (btn3Text), new Button (btn4Text)); - GraphViewTests.AssertDriverContentsWithFrameAre ($"{topRow}\n{buttonRow}\n{bottomRow}", output); + TestHelpers.AssertDriverContentsWithFrameAre ($"{topRow}\n{buttonRow}\n{bottomRow}", output); Application.End (runstate); // Justify buttonRow = $"{d.VLine}{btn1} {btn2} {btn3} {btn4}{d.VLine}"; Assert.Equal (width, buttonRow.Length); (runstate, var _) = RunButtonTestDialog (title, width, Dialog.ButtonAlignments.Justify, new Button (btn1Text), new Button (btn2Text), new Button (btn3Text), new Button (btn4Text)); - GraphViewTests.AssertDriverContentsWithFrameAre ($"{topRow}\n{buttonRow}\n{bottomRow}", output); + TestHelpers.AssertDriverContentsWithFrameAre ($"{topRow}\n{buttonRow}\n{bottomRow}", output); Application.End (runstate); // Right buttonRow = $"{d.VLine} {btn1} {btn2} {btn3} {btn4}{d.VLine}"; Assert.Equal (width, buttonRow.Length); (runstate, var _) = RunButtonTestDialog (title, width, Dialog.ButtonAlignments.Right, new Button (btn1Text), new Button (btn2Text), new Button (btn3Text), new Button (btn4Text)); - GraphViewTests.AssertDriverContentsWithFrameAre ($"{topRow}\n{buttonRow}\n{bottomRow}", output); + TestHelpers.AssertDriverContentsWithFrameAre ($"{topRow}\n{buttonRow}\n{bottomRow}", output); Application.End (runstate); // Left buttonRow = $"{d.VLine}{btn1} {btn2} {btn3} {btn4} {d.VLine}"; Assert.Equal (width, buttonRow.Length); (runstate, var _) = RunButtonTestDialog (title, width, Dialog.ButtonAlignments.Left, new Button (btn1Text), new Button (btn2Text), new Button (btn3Text), new Button (btn4Text)); - GraphViewTests.AssertDriverContentsWithFrameAre ($"{topRow}\n{buttonRow}\n{bottomRow}", output); + TestHelpers.AssertDriverContentsWithFrameAre ($"{topRow}\n{buttonRow}\n{bottomRow}", output); Application.End (runstate); } @@ -312,28 +312,28 @@ public void ButtonAlignment_Four_Wider () // Default - Center (runstate, var _) = RunButtonTestDialog (title, width, Dialog.ButtonAlignments.Center, new Button (btn1Text), new Button (btn2Text), new Button (btn3Text), new Button (btn4Text)); - GraphViewTests.AssertDriverContentsWithFrameAre ($"{topRow}\n{buttonRow}\n{bottomRow}", output); + TestHelpers.AssertDriverContentsWithFrameAre ($"{topRow}\n{buttonRow}\n{bottomRow}", output); Application.End (runstate); // Justify buttonRow = $"{d.VLine}{btn1} {btn2} {btn3} {btn4}{d.VLine}"; Assert.Equal (width, ustring.Make (buttonRow).ConsoleWidth); (runstate, var _) = RunButtonTestDialog (title, width, Dialog.ButtonAlignments.Justify, new Button (btn1Text), new Button (btn2Text), new Button (btn3Text), new Button (btn4Text)); - GraphViewTests.AssertDriverContentsWithFrameAre ($"{topRow}\n{buttonRow}\n{bottomRow}", output); + TestHelpers.AssertDriverContentsWithFrameAre ($"{topRow}\n{buttonRow}\n{bottomRow}", output); Application.End (runstate); // Right buttonRow = $"{d.VLine} {btn1} {btn2} {btn3} {btn4}{d.VLine}"; Assert.Equal (width, ustring.Make (buttonRow).ConsoleWidth); (runstate, var _) = RunButtonTestDialog (title, width, Dialog.ButtonAlignments.Right, new Button (btn1Text), new Button (btn2Text), new Button (btn3Text), new Button (btn4Text)); - GraphViewTests.AssertDriverContentsWithFrameAre ($"{topRow}\n{buttonRow}\n{bottomRow}", output); + TestHelpers.AssertDriverContentsWithFrameAre ($"{topRow}\n{buttonRow}\n{bottomRow}", output); Application.End (runstate); // Left buttonRow = $"{d.VLine}{btn1} {btn2} {btn3} {btn4} {d.VLine}"; Assert.Equal (width, ustring.Make (buttonRow).ConsoleWidth); (runstate, var _) = RunButtonTestDialog (title, width, Dialog.ButtonAlignments.Left, new Button (btn1Text), new Button (btn2Text), new Button (btn3Text), new Button (btn4Text)); - GraphViewTests.AssertDriverContentsWithFrameAre ($"{topRow}\n{buttonRow}\n{bottomRow}", output); + TestHelpers.AssertDriverContentsWithFrameAre ($"{topRow}\n{buttonRow}\n{bottomRow}", output); Application.End (runstate); } @@ -367,28 +367,28 @@ public void ButtonAlignment_Four_WideOdd () // Default - Center (runstate, var _) = RunButtonTestDialog (title, width, Dialog.ButtonAlignments.Center, new Button (btn1Text), new Button (btn2Text), new Button (btn3Text), new Button (btn4Text)); - GraphViewTests.AssertDriverContentsWithFrameAre ($"{topRow}\n{buttonRow}\n{bottomRow}", output); + TestHelpers.AssertDriverContentsWithFrameAre ($"{topRow}\n{buttonRow}\n{bottomRow}", output); Application.End (runstate); // Justify buttonRow = $"{d.VLine}{btn1} {btn2} {btn3} {btn4}{d.VLine}"; Assert.Equal (width, buttonRow.Length); (runstate, var _) = RunButtonTestDialog (title, width, Dialog.ButtonAlignments.Justify, new Button (btn1Text), new Button (btn2Text), new Button (btn3Text), new Button (btn4Text)); - GraphViewTests.AssertDriverContentsWithFrameAre ($"{topRow}\n{buttonRow}\n{bottomRow}", output); + TestHelpers.AssertDriverContentsWithFrameAre ($"{topRow}\n{buttonRow}\n{bottomRow}", output); Application.End (runstate); // Right buttonRow = $"{d.VLine} {btn1} {btn2} {btn3} {btn4}{d.VLine}"; Assert.Equal (width, buttonRow.Length); (runstate, var _) = RunButtonTestDialog (title, width, Dialog.ButtonAlignments.Right, new Button (btn1Text), new Button (btn2Text), new Button (btn3Text), new Button (btn4Text)); - GraphViewTests.AssertDriverContentsWithFrameAre ($"{topRow}\n{buttonRow}\n{bottomRow}", output); + TestHelpers.AssertDriverContentsWithFrameAre ($"{topRow}\n{buttonRow}\n{bottomRow}", output); Application.End (runstate); // Left buttonRow = $"{d.VLine}{btn1} {btn2} {btn3} {btn4} {d.VLine}"; Assert.Equal (width, buttonRow.Length); (runstate, var _) = RunButtonTestDialog (title, width, Dialog.ButtonAlignments.Left, new Button (btn1Text), new Button (btn2Text), new Button (btn3Text), new Button (btn4Text)); - GraphViewTests.AssertDriverContentsWithFrameAre ($"{topRow}\n{buttonRow}\n{bottomRow}", output); + TestHelpers.AssertDriverContentsWithFrameAre ($"{topRow}\n{buttonRow}\n{bottomRow}", output); Application.End (runstate); } @@ -409,7 +409,7 @@ public void Zero_Buttons_Works () d.SetBufferSize (buttonRow.Length, 3); (runstate, var _) = RunButtonTestDialog (title, width, Dialog.ButtonAlignments.Center, null); - GraphViewTests.AssertDriverContentsWithFrameAre ($"{topRow}\n{buttonRow}\n{bottomRow}", output); + TestHelpers.AssertDriverContentsWithFrameAre ($"{topRow}\n{buttonRow}\n{bottomRow}", output); Application.End (runstate); } @@ -432,7 +432,7 @@ public void One_Button_Works () d.SetBufferSize (buttonRow.Length, 3); (runstate, var _) = RunButtonTestDialog (title, width, Dialog.ButtonAlignments.Center, new Button (btnText)); - GraphViewTests.AssertDriverContentsWithFrameAre ($"{topRow}\n{buttonRow}\n{bottomRow}", output); + TestHelpers.AssertDriverContentsWithFrameAre ($"{topRow}\n{buttonRow}\n{bottomRow}", output); Application.End (runstate); } @@ -461,56 +461,56 @@ public void Add_Button_Works () var dlg = new Dialog (title, width, 3, new Button (btn1Text)) { ButtonAlignment = Dialog.ButtonAlignments.Center }; runstate = Application.Begin (dlg); var buttonRow = $"{d.VLine} {btn1} {d.VLine}"; - GraphViewTests.AssertDriverContentsWithFrameAre ($"{topRow}\n{buttonRow}\n{bottomRow}", output); + TestHelpers.AssertDriverContentsWithFrameAre ($"{topRow}\n{buttonRow}\n{bottomRow}", output); // Now add a second button buttonRow = $"{d.VLine} {btn1} {btn2} {d.VLine}"; dlg.AddButton (new Button (btn2Text)); bool first = false; Application.RunMainLoopIteration (ref runstate, true, ref first); - GraphViewTests.AssertDriverContentsWithFrameAre ($"{topRow}\n{buttonRow}\n{bottomRow}", output); + TestHelpers.AssertDriverContentsWithFrameAre ($"{topRow}\n{buttonRow}\n{bottomRow}", output); Application.End (runstate); // Justify dlg = new Dialog (title, width, 3, new Button (btn1Text)) { ButtonAlignment = Dialog.ButtonAlignments.Justify }; runstate = Application.Begin (dlg); buttonRow = $"{d.VLine} {btn1}{d.VLine}"; - GraphViewTests.AssertDriverContentsWithFrameAre ($"{topRow}\n{buttonRow}\n{bottomRow}", output); + TestHelpers.AssertDriverContentsWithFrameAre ($"{topRow}\n{buttonRow}\n{bottomRow}", output); // Now add a second button buttonRow = $"{d.VLine}{btn1} {btn2}{d.VLine}"; dlg.AddButton (new Button (btn2Text)); first = false; Application.RunMainLoopIteration (ref runstate, true, ref first); - GraphViewTests.AssertDriverContentsWithFrameAre ($"{topRow}\n{buttonRow}\n{bottomRow}", output); + TestHelpers.AssertDriverContentsWithFrameAre ($"{topRow}\n{buttonRow}\n{bottomRow}", output); Application.End (runstate); // 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}"; - GraphViewTests.AssertDriverContentsWithFrameAre ($"{topRow}\n{buttonRow}\n{bottomRow}", output); + TestHelpers.AssertDriverContentsWithFrameAre ($"{topRow}\n{buttonRow}\n{bottomRow}", output); // Now add a second button buttonRow = $"{d.VLine} {btn1} {btn2}{d.VLine}"; dlg.AddButton (new Button (btn2Text)); first = false; Application.RunMainLoopIteration (ref runstate, true, ref first); - GraphViewTests.AssertDriverContentsWithFrameAre ($"{topRow}\n{buttonRow}\n{bottomRow}", output); + TestHelpers.AssertDriverContentsWithFrameAre ($"{topRow}\n{buttonRow}\n{bottomRow}", output); Application.End (runstate); // 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}"; - GraphViewTests.AssertDriverContentsWithFrameAre ($"{topRow}\n{buttonRow}\n{bottomRow}", output); + TestHelpers.AssertDriverContentsWithFrameAre ($"{topRow}\n{buttonRow}\n{bottomRow}", output); // Now add a second button buttonRow = $"{d.VLine}{btn1} {btn2} {d.VLine}"; dlg.AddButton (new Button (btn2Text)); first = false; Application.RunMainLoopIteration (ref runstate, true, ref first); - GraphViewTests.AssertDriverContentsWithFrameAre ($"{topRow}\n{buttonRow}\n{bottomRow}", output); + TestHelpers.AssertDriverContentsWithFrameAre ($"{topRow}\n{buttonRow}\n{bottomRow}", output); Application.End (runstate); } } diff --git a/UnitTests/DimTests.cs b/UnitTests/DimTests.cs index 0d4dbeb9b8..7148d8e68f 100644 --- a/UnitTests/DimTests.cs +++ b/UnitTests/DimTests.cs @@ -1002,7 +1002,7 @@ public void Dim_Add_Operator_With_Text () field.KeyDown += (k) => { if (k.KeyEvent.Key == Key.Enter) { ((FakeDriver)Application.Driver).SetBufferSize (22, count + 4); - var pos = GraphViewTests.AssertDriverContentsWithFrameAre (expecteds [count], output); + var pos = TestHelpers.AssertDriverContentsWithFrameAre (expecteds [count], output); Assert.Equal (new Rect (0, 0, 22, count + 4), pos); if (count < 20) { @@ -1148,7 +1148,7 @@ public void Dim_Subtract_Operator_With_Text () field.KeyDown += (k) => { if (k.KeyEvent.Key == Key.Enter) { ((FakeDriver)Application.Driver).SetBufferSize (22, count + 4); - var pos = GraphViewTests.AssertDriverContentsWithFrameAre (expecteds [count], output); + var pos = TestHelpers.AssertDriverContentsWithFrameAre (expecteds [count], output); Assert.Equal (new Rect (0, 0, 22, count + 4), pos); if (count > 0) { diff --git a/UnitTests/GraphViewTests.cs b/UnitTests/GraphViewTests.cs index b1665b54fa..9d3f03dabe 100644 --- a/UnitTests/GraphViewTests.cs +++ b/UnitTests/GraphViewTests.cs @@ -93,192 +93,6 @@ public static GraphView GetGraph () return gv; } -#pragma warning disable xUnit1013 // Public method should be marked as test - public static void AssertDriverContentsAre (string expectedLook, ITestOutputHelper output) - { -#pragma warning restore xUnit1013 // Public method should be marked as test - - var sb = new StringBuilder (); - var driver = ((FakeDriver)Application.Driver); - - var contents = driver.Contents; - - for (int r = 0; r < driver.Rows; r++) { - for (int c = 0; c < driver.Cols; c++) { - sb.Append ((char)contents [r, c, 0]); - } - sb.AppendLine (); - } - - var actualLook = sb.ToString (); - - if (!string.Equals (expectedLook, actualLook)) { - - // ignore trailing whitespace on each line - var trailingWhitespace = new Regex (@"\s+$", RegexOptions.Multiline); - - // get rid of trailing whitespace on each line (and leading/trailing whitespace of start/end of full string) - expectedLook = trailingWhitespace.Replace (expectedLook, "").Trim (); - actualLook = trailingWhitespace.Replace (actualLook, "").Trim (); - - // standardize line endings for the comparison - expectedLook = expectedLook.Replace ("\r\n", "\n"); - actualLook = actualLook.Replace ("\r\n", "\n"); - - output?.WriteLine ("Expected:" + Environment.NewLine + expectedLook); - output?.WriteLine ("But Was:" + Environment.NewLine + actualLook); - - Assert.Equal (expectedLook, actualLook); - } - } - - public static Rect AssertDriverContentsWithFrameAre (string expectedLook, ITestOutputHelper output) - { - var lines = new List> (); - var sb = new StringBuilder (); - var driver = ((FakeDriver)Application.Driver); - var x = -1; - var y = -1; - int w = -1; - int h = -1; - - var contents = driver.Contents; - - for (int r = 0; r < driver.Rows; r++) { - var runes = new List (); - for (int c = 0; c < driver.Cols; c++) { - var rune = (char)contents [r, c, 0]; - if (rune != ' ') { - if (x == -1) { - x = c; - y = r; - for (int i = 0; i < c; i++) { - runes.InsertRange (i, new List () { ' ' }); - } - } - if (Rune.ColumnWidth (rune) > 1) { - c++; - } - if (c + 1 > w) { - w = c + 1; - } - h = r - y + 1; - } - if (x > -1) { - runes.Add (rune); - } - } - if (runes.Count > 0) { - lines.Add (runes); - } - } - - // Remove unnecessary empty lines - if (lines.Count > 0) { - for (int r = lines.Count - 1; r > h - 1; r--) { - lines.RemoveAt (r); - } - } - - // Remove trailing whitespace on each line - for (int r = 0; r < lines.Count; r++) { - List row = lines [r]; - for (int c = row.Count - 1; c >= 0; c--) { - var rune = row [c]; - if (rune != ' ' || (row.Sum (x => Rune.ColumnWidth (x)) == w)) { - break; - } - row.RemoveAt (c); - } - } - - // Convert char list to string - for (int r = 0; r < lines.Count; r++) { - var line = new string (lines [r].ToArray ()); - if (r == lines.Count - 1) { - sb.Append (line); - } else { - sb.AppendLine (line); - } - } - - var actualLook = sb.ToString (); - - if (!string.Equals (expectedLook, actualLook)) { - - // standardize line endings for the comparison - expectedLook = expectedLook.Replace ("\r\n", "\n"); - actualLook = actualLook.Replace ("\r\n", "\n"); - - // Remove the first and the last line ending from the expectedLook - if (expectedLook.StartsWith ("\n")) { - expectedLook = expectedLook [1..]; - } - if (expectedLook.EndsWith ("\n")) { - expectedLook = expectedLook [..^1]; - } - - output?.WriteLine ("Expected:" + Environment.NewLine + expectedLook); - output?.WriteLine ("But Was:" + Environment.NewLine + actualLook); - - Assert.Equal (expectedLook, actualLook); - } - return new Rect (x > -1 ? x : 0, y > -1 ? y : 0, w > -1 ? w : 0, h > -1 ? h : 0); - } - -#pragma warning disable xUnit1013 // Public method should be marked as test - /// - /// Verifies the console was rendered using the given at the given locations. - /// Pass a bitmap of indexes into as and the - /// test method will verify those colors were used in the row/col of the console during rendering - /// - /// Numbers between 0 and 9 for each row/col of the console. Must be valid indexes of - /// - public static void AssertDriverColorsAre (string expectedLook, Attribute [] expectedColors) - { -#pragma warning restore xUnit1013 // Public method should be marked as test - - if (expectedColors.Length > 10) { - throw new ArgumentException ("This method only works for UIs that use at most 10 colors"); - } - - expectedLook = expectedLook.Trim (); - var driver = ((FakeDriver)Application.Driver); - - var contents = driver.Contents; - - int r = 0; - foreach (var line in expectedLook.Split ('\n').Select (l => l.Trim ())) { - - for (int c = 0; c < line.Length; c++) { - - int val = contents [r, c, 1]; - - var match = expectedColors.Where (e => e.Value == val).ToList (); - if (match.Count == 0) { - throw new Exception ($"Unexpected color {DescribeColor (val)} was used at row {r} and col {c} (indexes start at 0). Color value was {val} (expected colors were {string.Join (",", expectedColors.Select (c => c.Value))})"); - } else if (match.Count > 1) { - throw new ArgumentException ($"Bad value for expectedColors, {match.Count} Attributes had the same Value"); - } - - var colorUsed = Array.IndexOf (expectedColors, match [0]).ToString () [0]; - var userExpected = line [c]; - - if (colorUsed != userExpected) { - throw new Exception ($"Colors used did not match expected at row {r} and col {c} (indexes start at 0). Color index used was {DescribeColor (colorUsed)} but test expected {DescribeColor (userExpected)} (these are indexes into the expectedColors array)"); - } - } - - r++; - } - } - - private static object DescribeColor (int userExpected) - { - var a = new Attribute (userExpected); - return $"{a.Foreground},{a.Background}"; - } - #region Screen to Graph Tests [Fact] @@ -833,7 +647,7 @@ public void TestRendering_MultibarSeries () │ MM MM MM ┼──┬M──┬M──┬M────── heytherebob "; - GraphViewTests.AssertDriverContentsAre (looksLike, output); + TestHelpers.AssertDriverContentsAre (looksLike, output); // Shutdown must be called to safely clean up Application if Init has been called Application.Shutdown (); @@ -1253,7 +1067,7 @@ public void TestTextAnnotation_ScreenUnits () 0┼┬┬┬┬┬┬┬┬ 0 5"; - GraphViewTests.AssertDriverContentsAre (expected, output); + TestHelpers.AssertDriverContentsAre (expected, output); // user scrolls up one unit of graph space gv.ScrollOffset = new PointF (0, 1f); @@ -1270,7 +1084,7 @@ public void TestTextAnnotation_ScreenUnits () 1┼┬┬┬┬┬┬┬┬ 0 5"; - GraphViewTests.AssertDriverContentsAre (expected, output); + TestHelpers.AssertDriverContentsAre (expected, output); // Shutdown must be called to safely clean up Application if Init has been called Application.Shutdown (); @@ -1297,7 +1111,7 @@ public void TestTextAnnotation_GraphUnits () 0┼┬┬┬┬┬┬┬┬ 0 5"; - GraphViewTests.AssertDriverContentsAre (expected, output); + TestHelpers.AssertDriverContentsAre (expected, output); // user scrolls up one unit of graph space gv.ScrollOffset = new PointF (0, 1f); @@ -1315,7 +1129,7 @@ public void TestTextAnnotation_GraphUnits () 1┼┬┬┬┬┬┬┬┬ 0 5"; - GraphViewTests.AssertDriverContentsAre (expected, output); + TestHelpers.AssertDriverContentsAre (expected, output); // Shutdown must be called to safely clean up Application if Init has been called Application.Shutdown (); @@ -1345,7 +1159,7 @@ public void TestTextAnnotation_LongText () 0┼┬┬┬┬┬┬┬┬ 0 5"; - GraphViewTests.AssertDriverContentsAre (expected, output); + TestHelpers.AssertDriverContentsAre (expected, output); // Shutdown must be called to safely clean up Application if Init has been called @@ -1374,7 +1188,7 @@ public void TestTextAnnotation_Offscreen () 0┼┬┬┬┬┬┬┬┬ 0 5"; - GraphViewTests.AssertDriverContentsAre (expected, output); + TestHelpers.AssertDriverContentsAre (expected, output); // Shutdown must be called to safely clean up Application if Init has been called Application.Shutdown (); @@ -1409,7 +1223,7 @@ public void TestTextAnnotation_EmptyText (string whitespace) 0┼┬┬┬┬┬┬┬┬ 0 5"; - GraphViewTests.AssertDriverContentsAre (expected, output); + TestHelpers.AssertDriverContentsAre (expected, output); // Shutdown must be called to safely clean up Application if Init has been called @@ -1444,7 +1258,7 @@ public void LegendNormalUsage_WithBorder () 0┼┬┬┬┬┬┬┬┬ 0 5"; - GraphViewTests.AssertDriverContentsAre (expected, output); + TestHelpers.AssertDriverContentsAre (expected, output); // Shutdown must be called to safely clean up Application if Init has been called @@ -1473,7 +1287,7 @@ public void LegendNormalUsage_WithoutBorder () 0┼┬┬┬┬┬┬┬┬ 0 5"; - GraphViewTests.AssertDriverContentsAre (expected, output); + TestHelpers.AssertDriverContentsAre (expected, output); // Shutdown must be called to safely clean up Application if Init has been called @@ -1515,7 +1329,7 @@ public void PathAnnotation_Box () 0┼┬┬┬┬┬┬┬┬ 0 5"; - GraphViewTests.AssertDriverContentsAre (expected, output); + TestHelpers.AssertDriverContentsAre (expected, output); // Shutdown must be called to safely clean up Application if Init has been called @@ -1554,7 +1368,7 @@ public void YAxisLabels_With_MarginBottom () 0 5 "; - GraphViewTests.AssertDriverContentsAre (expected, output); + TestHelpers.AssertDriverContentsAre (expected, output); // Shutdown must be called to safely clean up Application if Init has been called @@ -1595,7 +1409,7 @@ public void XAxisLabels_With_MarginLeft () 0 5 "; - GraphViewTests.AssertDriverContentsAre (expected, output); + TestHelpers.AssertDriverContentsAre (expected, output); // Shutdown must be called to safely clean up Application if Init has been called @@ -1622,7 +1436,7 @@ public void MarginBottom_BiggerThanHeight_ExpectBlankGraph () "; - GraphViewTests.AssertDriverContentsAre (expected, output); + TestHelpers.AssertDriverContentsAre (expected, output); // Shutdown must be called to safely clean up Application if Init has been called @@ -1647,7 +1461,7 @@ public void MarginLeft_BiggerThanWidth_ExpectBlankGraph () "; - GraphViewTests.AssertDriverContentsAre (expected, output); + TestHelpers.AssertDriverContentsAre (expected, output); // Shutdown must be called to safely clean up Application if Init has been called @@ -1679,7 +1493,7 @@ public void PathAnnotation_Diamond () 0┼┬┬┬┬┬┬┬┬ 0 5"; - GraphViewTests.AssertDriverContentsAre (expected, output); + TestHelpers.AssertDriverContentsAre (expected, output); // Shutdown must be called to safely clean up Application if Init has been called @@ -1726,14 +1540,14 @@ public void LabelChangeText_RendersCorrectly (bool useFill) mount.Redraw (mount.Bounds); // should have the initial text - GraphViewTests.AssertDriverContentsAre ("ff", null); + TestHelpers.AssertDriverContentsAre ("ff", null); // change the text and redraw lbl1.Text = "ff1234"; mount.Redraw (mount.Bounds); // should have the new text rendered - GraphViewTests.AssertDriverContentsAre ("ff1234", null); + TestHelpers.AssertDriverContentsAre ("ff1234", null); } finally { diff --git a/UnitTests/ListViewTests.cs b/UnitTests/ListViewTests.cs index 03b01547aa..a9a29543df 100644 --- a/UnitTests/ListViewTests.cs +++ b/UnitTests/ListViewTests.cs @@ -247,7 +247,7 @@ public void Ensures_Visibility_SelectedItem_On_MoveDown_And_MoveUp () Application.Refresh (); Assert.Equal (0, lv.SelectedItem); - GraphViewTests.AssertDriverContentsWithFrameAre (@" + TestHelpers.AssertDriverContentsWithFrameAre (@" ┌──────────┐ │Line0 │ │Line1 │ @@ -264,7 +264,7 @@ public void Ensures_Visibility_SelectedItem_On_MoveDown_And_MoveUp () Assert.True (lv.ScrollDown (10)); lv.Redraw (lv.Bounds); Assert.Equal (0, lv.SelectedItem); - GraphViewTests.AssertDriverContentsWithFrameAre (@" + TestHelpers.AssertDriverContentsWithFrameAre (@" ┌──────────┐ │Line10 │ │Line11 │ @@ -281,7 +281,7 @@ public void Ensures_Visibility_SelectedItem_On_MoveDown_And_MoveUp () Assert.True (lv.MoveDown ()); lv.Redraw (lv.Bounds); Assert.Equal (1, lv.SelectedItem); - GraphViewTests.AssertDriverContentsWithFrameAre (@" + TestHelpers.AssertDriverContentsWithFrameAre (@" ┌──────────┐ │Line1 │ │Line2 │ @@ -298,7 +298,7 @@ public void Ensures_Visibility_SelectedItem_On_MoveDown_And_MoveUp () Assert.True (lv.MoveEnd ()); lv.Redraw (lv.Bounds); Assert.Equal (19, lv.SelectedItem); - GraphViewTests.AssertDriverContentsWithFrameAre (@" + TestHelpers.AssertDriverContentsWithFrameAre (@" ┌──────────┐ │Line19 │ │ │ @@ -315,7 +315,7 @@ public void Ensures_Visibility_SelectedItem_On_MoveDown_And_MoveUp () Assert.True (lv.ScrollUp (20)); lv.Redraw (lv.Bounds); Assert.Equal (19, lv.SelectedItem); - GraphViewTests.AssertDriverContentsWithFrameAre (@" + TestHelpers.AssertDriverContentsWithFrameAre (@" ┌──────────┐ │Line0 │ │Line1 │ @@ -332,7 +332,7 @@ public void Ensures_Visibility_SelectedItem_On_MoveDown_And_MoveUp () Assert.True (lv.MoveDown ()); lv.Redraw (lv.Bounds); Assert.Equal (19, lv.SelectedItem); - GraphViewTests.AssertDriverContentsWithFrameAre (@" + TestHelpers.AssertDriverContentsWithFrameAre (@" ┌──────────┐ │Line10 │ │Line11 │ @@ -349,7 +349,7 @@ public void Ensures_Visibility_SelectedItem_On_MoveDown_And_MoveUp () Assert.True (lv.ScrollUp (20)); lv.Redraw (lv.Bounds); Assert.Equal (19, lv.SelectedItem); - GraphViewTests.AssertDriverContentsWithFrameAre (@" + TestHelpers.AssertDriverContentsWithFrameAre (@" ┌──────────┐ │Line0 │ │Line1 │ @@ -366,7 +366,7 @@ public void Ensures_Visibility_SelectedItem_On_MoveDown_And_MoveUp () Assert.True (lv.MoveDown ()); lv.Redraw (lv.Bounds); Assert.Equal (19, lv.SelectedItem); - GraphViewTests.AssertDriverContentsWithFrameAre (@" + TestHelpers.AssertDriverContentsWithFrameAre (@" ┌──────────┐ │Line10 │ │Line11 │ @@ -383,7 +383,7 @@ public void Ensures_Visibility_SelectedItem_On_MoveDown_And_MoveUp () Assert.True (lv.MoveHome ()); lv.Redraw (lv.Bounds); Assert.Equal (0, lv.SelectedItem); - GraphViewTests.AssertDriverContentsWithFrameAre (@" + TestHelpers.AssertDriverContentsWithFrameAre (@" ┌──────────┐ │Line0 │ │Line1 │ @@ -400,7 +400,7 @@ public void Ensures_Visibility_SelectedItem_On_MoveDown_And_MoveUp () Assert.True (lv.ScrollDown (20)); lv.Redraw (lv.Bounds); Assert.Equal (0, lv.SelectedItem); - GraphViewTests.AssertDriverContentsWithFrameAre (@" + TestHelpers.AssertDriverContentsWithFrameAre (@" ┌──────────┐ │Line19 │ │ │ @@ -417,7 +417,7 @@ public void Ensures_Visibility_SelectedItem_On_MoveDown_And_MoveUp () Assert.True (lv.MoveUp ()); lv.Redraw (lv.Bounds); Assert.Equal (0, lv.SelectedItem); - GraphViewTests.AssertDriverContentsWithFrameAre (@" + TestHelpers.AssertDriverContentsWithFrameAre (@" ┌──────────┐ │Line0 │ │Line1 │ diff --git a/UnitTests/MenuTests.cs b/UnitTests/MenuTests.cs index 0f10e48a91..a587a996b7 100644 --- a/UnitTests/MenuTests.cs +++ b/UnitTests/MenuTests.cs @@ -150,7 +150,7 @@ public void MenuOpening_MenuOpened_MenuClosing_Events () │ Copy Copies the selection. │ └──────────────────────────────┘ "; - GraphViewTests.AssertDriverContentsAre (expected, output); + TestHelpers.AssertDriverContentsAre (expected, output); cancelClosing = true; Assert.True (menu.ProcessHotKey (new KeyEvent (Key.F9, new KeyModifiers ()))); @@ -163,7 +163,7 @@ public void MenuOpening_MenuOpened_MenuClosing_Events () │ Copy Copies the selection. │ └──────────────────────────────┘ "; - GraphViewTests.AssertDriverContentsAre (expected, output); + TestHelpers.AssertDriverContentsAre (expected, output); cancelClosing = false; Assert.True (menu.ProcessHotKey (new KeyEvent (Key.F9, new KeyModifiers ()))); @@ -173,7 +173,7 @@ public void MenuOpening_MenuOpened_MenuClosing_Events () expected = @" Edit "; - GraphViewTests.AssertDriverContentsAre (expected, output); + TestHelpers.AssertDriverContentsAre (expected, output); void New () => miAction = "New"; void Copy () => miAction = "Copy"; @@ -608,7 +608,7 @@ public void DrawFrame_With_Positive_Positions () └──────┘ "; - var pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + var pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new Rect (0, 1, 8, 4), pos); } @@ -637,7 +637,7 @@ public void DrawFrame_With_Negative_Positions () ──────┘ "; - var pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + var pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new Rect (0, 0, 7, 4), pos); menu.CloseAllMenus (); @@ -651,7 +651,7 @@ public void DrawFrame_With_Negative_Positions () ──────┘ "; - pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new Rect (1, 0, 7, 3), pos); menu.CloseAllMenus (); @@ -667,7 +667,7 @@ public void DrawFrame_With_Negative_Positions () └────── "; - pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new Rect (0, 1, 7, 4), pos); menu.CloseAllMenus (); @@ -682,7 +682,7 @@ public void DrawFrame_With_Negative_Positions () │ Two "; - pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new Rect (0, 0, 7, 3), pos); } @@ -710,7 +710,7 @@ public void UseSubMenusSingleFrame_False_By_Keyboard () Numbers "; - var pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + var pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.True (menu.ProcessHotKey (new KeyEvent (Key.F9, null))); Application.Top.Redraw (Application.Top.Bounds); @@ -723,7 +723,7 @@ public void UseSubMenusSingleFrame_False_By_Keyboard () └────────┘ "; - pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.True (Application.Top.Subviews [1].ProcessKey (new KeyEvent (Key.CursorDown, null))); Application.Top.Redraw (Application.Top.Bounds); @@ -737,7 +737,7 @@ public void UseSubMenusSingleFrame_False_By_Keyboard () └─────────────┘ "; - pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.True (Application.Top.Subviews [2].ProcessKey (new KeyEvent (Key.CursorLeft, null))); Application.Top.Redraw (Application.Top.Bounds); @@ -750,7 +750,7 @@ public void UseSubMenusSingleFrame_False_By_Keyboard () └────────┘ "; - pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.True (Application.Top.Subviews [1].ProcessKey (new KeyEvent (Key.Esc, null))); Application.Top.Redraw (Application.Top.Bounds); @@ -758,7 +758,7 @@ public void UseSubMenusSingleFrame_False_By_Keyboard () Numbers "; - pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); } [Fact, AutoInitShutdown] @@ -785,7 +785,7 @@ public void UseSubMenusSingleFrame_False_By_Mouse () Numbers "; - var pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + var pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new Rect (1, 0, 8, 1), pos); Assert.True (menu.MouseEvent (new MouseEvent () { @@ -804,7 +804,7 @@ public void UseSubMenusSingleFrame_False_By_Mouse () └────────┘ "; - pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new Rect (1, 0, 10, 6), pos); Assert.False (menu.MouseEvent (new MouseEvent () { @@ -824,7 +824,7 @@ public void UseSubMenusSingleFrame_False_By_Mouse () └─────────────┘ "; - pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new Rect (1, 0, 25, 7), pos); Assert.False (menu.MouseEvent (new MouseEvent () { @@ -843,7 +843,7 @@ public void UseSubMenusSingleFrame_False_By_Mouse () └────────┘ "; - pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new Rect (1, 0, 10, 6), pos); Assert.False (menu.MouseEvent (new MouseEvent () { @@ -857,7 +857,7 @@ public void UseSubMenusSingleFrame_False_By_Mouse () Numbers "; - pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new Rect (1, 0, 8, 1), pos); } @@ -887,7 +887,7 @@ public void UseSubMenusSingleFrame_True_By_Keyboard () Numbers "; - var pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + var pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new Rect (1, 0, 8, 1), pos); Assert.True (menu.ProcessHotKey (new KeyEvent (Key.F9, null))); @@ -901,7 +901,7 @@ public void UseSubMenusSingleFrame_True_By_Keyboard () └────────┘ "; - pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new Rect (1, 0, 10, 6), pos); Assert.True (Application.Top.Subviews [1].ProcessKey (new KeyEvent (Key.CursorDown, null))); @@ -917,7 +917,7 @@ public void UseSubMenusSingleFrame_True_By_Keyboard () └─────────────┘ "; - pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new Rect (1, 0, 15, 7), pos); Assert.True (Application.Top.Subviews [2].ProcessKey (new KeyEvent (Key.Enter, null))); @@ -931,7 +931,7 @@ public void UseSubMenusSingleFrame_True_By_Keyboard () └────────┘ "; - pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new Rect (1, 0, 10, 6), pos); Assert.True (Application.Top.Subviews [1].ProcessKey (new KeyEvent (Key.Esc, null))); @@ -940,7 +940,7 @@ public void UseSubMenusSingleFrame_True_By_Keyboard () Numbers "; - pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new Rect (1, 0, 8, 1), pos); } @@ -970,7 +970,7 @@ public void UseSubMenusSingleFrame_True_By_Mouse () Numbers "; - var pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + var pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new Rect (1, 0, 8, 1), pos); Assert.True (menu.MouseEvent (new MouseEvent () { @@ -989,7 +989,7 @@ public void UseSubMenusSingleFrame_True_By_Mouse () └────────┘ "; - pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new Rect (1, 0, 10, 6), pos); Assert.False (menu.MouseEvent (new MouseEvent () { @@ -1009,7 +1009,7 @@ public void UseSubMenusSingleFrame_True_By_Mouse () └─────────────┘ "; - pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new Rect (1, 0, 15, 7), pos); Assert.False (menu.MouseEvent (new MouseEvent () { @@ -1028,7 +1028,7 @@ public void UseSubMenusSingleFrame_True_By_Mouse () └────────┘ "; - pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new Rect (1, 0, 10, 6), pos); Assert.False (menu.MouseEvent (new MouseEvent () { @@ -1042,7 +1042,7 @@ public void UseSubMenusSingleFrame_True_By_Mouse () Numbers "; - pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new Rect (1, 0, 8, 1), pos); } @@ -1074,7 +1074,7 @@ public void HotKey_MenuBar_OnKeyDown_OnKeyUp_ProcessHotKey_ProcessKey () File Edit "; - var pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + var pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new Rect (1, 0, 11, 1), pos); Assert.True (menu.ProcessKey (new (Key.N, null))); @@ -1088,7 +1088,7 @@ File Edit File Edit "; - pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new Rect (1, 0, 11, 1), pos); Assert.True (menu.ProcessKey (new (Key.CursorRight, null))); @@ -1205,13 +1205,13 @@ public void MenuBar_Submenus_Alignment_Correct () Application.Top.Add (menu); Application.Top.Redraw (Application.Top.Bounds); - GraphViewTests.AssertDriverContentsAre (expectedMenu.ClosedMenuText, output); + TestHelpers.AssertDriverContentsAre (expectedMenu.ClosedMenuText, output); for (var i = 0; i < expectedMenu.Menus.Length; i++) { menu.OpenMenu (i); Assert.True (menu.IsMenuOpen); Application.Top.Redraw (Application.Top.Bounds); - GraphViewTests.AssertDriverContentsAre (expectedMenu.expectedSubMenuOpen (i), output); + TestHelpers.AssertDriverContentsAre (expectedMenu.expectedSubMenuOpen (i), output); } } @@ -1249,7 +1249,7 @@ public void HotKey_MenuBar_ProcessHotKey_Menu_ProcessKey () Assert.True (menu.ProcessHotKey (new (Key.AltMask | Key.F, new KeyModifiers () { Alt = true }))); Assert.True (menu.IsMenuOpen); Application.Top.Redraw (Application.Top.Bounds); - GraphViewTests.AssertDriverContentsAre (expectedMenu.expectedSubMenuOpen (0), output); + TestHelpers.AssertDriverContentsAre (expectedMenu.expectedSubMenuOpen (0), output); Assert.True (Application.Top.Subviews [1].ProcessKey (new (Key.N, null))); Application.MainLoop.MainIteration (); @@ -1258,7 +1258,7 @@ public void HotKey_MenuBar_ProcessHotKey_Menu_ProcessKey () Assert.True (menu.ProcessHotKey (new (Key.AltMask | Key.E, new KeyModifiers () { Alt = true }))); Assert.True (menu.IsMenuOpen); Application.Top.Redraw (Application.Top.Bounds); - GraphViewTests.AssertDriverContentsAre (expectedMenu.expectedSubMenuOpen (1), output); + TestHelpers.AssertDriverContentsAre (expectedMenu.expectedSubMenuOpen (1), output); Assert.True (Application.Top.Subviews [1].ProcessKey (new (Key.C, null))); Application.MainLoop.MainIteration (); @@ -1294,19 +1294,19 @@ public void MenuBar_Position_And_Size_With_HotKeys_Is_The_Same_As_Without_HotKey Assert.True (menu.ProcessHotKey (new (Key.F9, new KeyModifiers ()))); Assert.True (menu.IsMenuOpen); Application.Top.Redraw (Application.Top.Bounds); - GraphViewTests.AssertDriverContentsAre (expectedMenu.expectedSubMenuOpen (0), output); + TestHelpers.AssertDriverContentsAre (expectedMenu.expectedSubMenuOpen (0), output); // Open second Assert.True (Application.Top.Subviews [1].ProcessKey (new (Key.CursorRight, null))); Assert.True (menu.IsMenuOpen); Application.Top.Redraw (Application.Top.Bounds); - GraphViewTests.AssertDriverContentsAre (expectedMenu.expectedSubMenuOpen (1), output); + TestHelpers.AssertDriverContentsAre (expectedMenu.expectedSubMenuOpen (1), output); // Close menu Assert.True (menu.ProcessHotKey (new (Key.F9, new KeyModifiers ()))); Assert.False (menu.IsMenuOpen); Application.Top.Redraw (Application.Top.Bounds); - GraphViewTests.AssertDriverContentsAre (expectedMenu.ClosedMenuText, output); + TestHelpers.AssertDriverContentsAre (expectedMenu.ClosedMenuText, output); Application.Top.Remove (menu); @@ -1326,19 +1326,19 @@ public void MenuBar_Position_And_Size_With_HotKeys_Is_The_Same_As_Without_HotKey Assert.True (menu.ProcessHotKey (new (Key.F9, new KeyModifiers ()))); Assert.True (menu.IsMenuOpen); Application.Top.Redraw (Application.Top.Bounds); - GraphViewTests.AssertDriverContentsAre (expectedMenu.expectedSubMenuOpen (0), output); + TestHelpers.AssertDriverContentsAre (expectedMenu.expectedSubMenuOpen (0), output); // Open second Assert.True (Application.Top.Subviews [1].ProcessKey (new (Key.CursorRight, null))); Assert.True (menu.IsMenuOpen); Application.Top.Redraw (Application.Top.Bounds); - GraphViewTests.AssertDriverContentsAre (expectedMenu.expectedSubMenuOpen (1), output); + TestHelpers.AssertDriverContentsAre (expectedMenu.expectedSubMenuOpen (1), output); // Close menu Assert.True (menu.ProcessHotKey (new (Key.F9, new KeyModifiers ()))); Assert.False (menu.IsMenuOpen); Application.Top.Redraw (Application.Top.Bounds); - GraphViewTests.AssertDriverContentsAre (expectedMenu.ClosedMenuText, output); + TestHelpers.AssertDriverContentsAre (expectedMenu.ClosedMenuText, output); } [Fact, AutoInitShutdown] @@ -1370,12 +1370,12 @@ public void MenuBar_ButtonPressed_Open_The_Menu_ButtonPressed_Again_Close_The_Me Assert.True (menu.IsMenuOpen); Application.Top.Redraw (Application.Top.Bounds); - GraphViewTests.AssertDriverContentsAre (expectedMenu.expectedSubMenuOpen (0), output); + TestHelpers.AssertDriverContentsAre (expectedMenu.expectedSubMenuOpen (0), output); Assert.True (menu.MouseEvent (new MouseEvent () { X = 1, Y = 0, Flags = MouseFlags.Button1Pressed, View = menu })); Assert.False (menu.IsMenuOpen); Application.Top.Redraw (Application.Top.Bounds); - GraphViewTests.AssertDriverContentsAre (expectedMenu.ClosedMenuText, output); + TestHelpers.AssertDriverContentsAre (expectedMenu.ClosedMenuText, output); } [Fact] @@ -1432,38 +1432,38 @@ public void Parent_MenuItem_Stay_Focused_If_Child_MenuItem_Is_Empty_By_Mouse () Assert.True (menu.IsMenuOpen); Assert.False (tf.HasFocus); Application.Top.Redraw (Application.Top.Bounds); - GraphViewTests.AssertDriverContentsAre (expectedMenu.expectedSubMenuOpen (0), output); + TestHelpers.AssertDriverContentsAre (expectedMenu.expectedSubMenuOpen (0), output); Assert.True (menu.MouseEvent (new MouseEvent () { X = 8, Y = 0, Flags = MouseFlags.ReportMousePosition, View = menu })); Assert.True (menu.IsMenuOpen); Assert.False (tf.HasFocus); Application.Top.Redraw (Application.Top.Bounds); - GraphViewTests.AssertDriverContentsAre (expectedMenu.expectedSubMenuOpen (1), output); + TestHelpers.AssertDriverContentsAre (expectedMenu.expectedSubMenuOpen (1), output); Assert.True (menu.MouseEvent (new MouseEvent () { X = 15, Y = 0, Flags = MouseFlags.ReportMousePosition, View = menu })); Assert.True (menu.IsMenuOpen); Assert.False (tf.HasFocus); Application.Top.Redraw (Application.Top.Bounds); - GraphViewTests.AssertDriverContentsAre (expectedMenu.expectedSubMenuOpen (2), output); + TestHelpers.AssertDriverContentsAre (expectedMenu.expectedSubMenuOpen (2), output); Assert.True (menu.MouseEvent (new MouseEvent () { X = 8, Y = 0, Flags = MouseFlags.ReportMousePosition, View = menu })); Assert.True (menu.IsMenuOpen); Assert.False (tf.HasFocus); Application.Top.Redraw (Application.Top.Bounds); - GraphViewTests.AssertDriverContentsAre (expectedMenu.ClosedMenuText, output); + TestHelpers.AssertDriverContentsAre (expectedMenu.ClosedMenuText, output); Assert.True (menu.MouseEvent (new MouseEvent () { X = 1, Y = 0, Flags = MouseFlags.ReportMousePosition, View = menu })); Assert.True (menu.IsMenuOpen); Assert.False (tf.HasFocus); Application.Top.Redraw (Application.Top.Bounds); - GraphViewTests.AssertDriverContentsAre (expectedMenu.expectedSubMenuOpen (0), output); + TestHelpers.AssertDriverContentsAre (expectedMenu.expectedSubMenuOpen (0), output); Assert.True (menu.MouseEvent (new MouseEvent () { X = 8, Y = 0, Flags = MouseFlags.Button1Pressed, View = menu })); Assert.False (menu.IsMenuOpen); Assert.True (tf.HasFocus); Application.Top.Redraw (Application.Top.Bounds); - GraphViewTests.AssertDriverContentsAre (expectedMenu.ClosedMenuText, output); + TestHelpers.AssertDriverContentsAre (expectedMenu.ClosedMenuText, output); } [Fact, AutoInitShutdown] @@ -1498,40 +1498,40 @@ public void Parent_MenuItem_Stay_Focused_If_Child_MenuItem_Is_Empty_By_Keyboard Assert.True (menu.IsMenuOpen); Assert.False (tf.HasFocus); Application.Top.Redraw (Application.Top.Bounds); - GraphViewTests.AssertDriverContentsAre (expectedMenu.expectedSubMenuOpen(0), output); + TestHelpers.AssertDriverContentsAre (expectedMenu.expectedSubMenuOpen(0), output); // Right - Edit has no sub menu; this tests that no sub menu shows Assert.True (menu.openMenu.ProcessKey (new KeyEvent (Key.CursorRight, new KeyModifiers ()))); Assert.True (menu.IsMenuOpen); Assert.False (tf.HasFocus); Application.Top.Redraw (Application.Top.Bounds); - GraphViewTests.AssertDriverContentsAre (expectedMenu.expectedSubMenuOpen (1), output); + TestHelpers.AssertDriverContentsAre (expectedMenu.expectedSubMenuOpen (1), output); // Right - Format Assert.True (menu.openMenu.ProcessKey (new KeyEvent (Key.CursorRight, new KeyModifiers ()))); Assert.True (menu.IsMenuOpen); Assert.False (tf.HasFocus); Application.Top.Redraw (Application.Top.Bounds); - GraphViewTests.AssertDriverContentsAre (expectedMenu.expectedSubMenuOpen (2), output); + TestHelpers.AssertDriverContentsAre (expectedMenu.expectedSubMenuOpen (2), output); // Left - Edit Assert.True (menu.openMenu.ProcessKey (new KeyEvent (Key.CursorLeft, new KeyModifiers ()))); Assert.True (menu.IsMenuOpen); Assert.False (tf.HasFocus); Application.Top.Redraw (Application.Top.Bounds); - GraphViewTests.AssertDriverContentsAre (expectedMenu.expectedSubMenuOpen (1), output); + TestHelpers.AssertDriverContentsAre (expectedMenu.expectedSubMenuOpen (1), output); Assert.True (menu.openMenu.ProcessKey (new KeyEvent (Key.CursorLeft, new KeyModifiers ()))); Assert.True (menu.IsMenuOpen); Assert.False (tf.HasFocus); Application.Top.Redraw (Application.Top.Bounds); - GraphViewTests.AssertDriverContentsAre (expectedMenu.expectedSubMenuOpen (0), output); + TestHelpers.AssertDriverContentsAre (expectedMenu.expectedSubMenuOpen (0), output); Assert.True (menu.ProcessHotKey (new KeyEvent (Key.F9, new KeyModifiers ()))); Assert.False (menu.IsMenuOpen); Assert.True (tf.HasFocus); Application.Top.Redraw (Application.Top.Bounds); - GraphViewTests.AssertDriverContentsAre (expectedMenu.ClosedMenuText, output); + TestHelpers.AssertDriverContentsAre (expectedMenu.ClosedMenuText, output); } [Fact, AutoInitShutdown] diff --git a/UnitTests/MessageBoxTests.cs b/UnitTests/MessageBoxTests.cs index 44518ba686..2c79aa2994 100644 --- a/UnitTests/MessageBoxTests.cs +++ b/UnitTests/MessageBoxTests.cs @@ -29,7 +29,7 @@ public void MessageBox_With_Empty_Size_Without_Buttons () } else if (iterations == 1) { Application.Top.Redraw (Application.Top.Bounds); - GraphViewTests.AssertDriverContentsWithFrameAre (@" + TestHelpers.AssertDriverContentsWithFrameAre (@" ┌ Title ─────────────────────────────────────────┐ │ Message │ │ │ @@ -71,7 +71,7 @@ public void MessageBox_With_Empty_Size_With_Button () Application.RequestStop (); } else if (iterations == 1) { Application.Top.Redraw (Application.Top.Bounds); - GraphViewTests.AssertDriverContentsWithFrameAre (@" + TestHelpers.AssertDriverContentsWithFrameAre (@" ┌ About UI Catalog ──────────────────────────────────────────┐ │ A comprehensive sample library for │ │ │ @@ -110,7 +110,7 @@ public void MessageBox_With_A_Lower_Fixed_Size () Application.RequestStop (); } else if (iterations == 1) { Application.Top.Redraw (Application.Top.Bounds); - GraphViewTests.AssertDriverContentsWithFrameAre (@" + TestHelpers.AssertDriverContentsWithFrameAre (@" ┌─────┐ │Messa│ │ ge │ @@ -140,7 +140,7 @@ public void MessageBox_With_A_Enough_Fixed_Size () Application.RequestStop (); } else if (iterations == 1) { Application.Top.Redraw (Application.Top.Bounds); - GraphViewTests.AssertDriverContentsWithFrameAre (@" + TestHelpers.AssertDriverContentsWithFrameAre (@" ┌ Title ──┐ │ Message │ │ │ @@ -170,7 +170,7 @@ public void MessageBox_With_A_Label_Without_Spaces () Application.RequestStop (); } else if (iterations == 1) { Application.Top.Redraw (Application.Top.Bounds); - GraphViewTests.AssertDriverContentsWithFrameAre (@" + TestHelpers.AssertDriverContentsWithFrameAre (@" ┌ mywindow ────────────────────────────────────────────────────────────────────┐ │ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff│ │ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff│ @@ -224,7 +224,7 @@ public void MessageBox_With_A_Label_With_Spaces () Application.RequestStop (); } else if (iterations == 1) { Application.Top.Redraw (Application.Top.Bounds); - GraphViewTests.AssertDriverContentsWithFrameAre (@" + TestHelpers.AssertDriverContentsWithFrameAre (@" ┌ mywindow ────────────────────────────────────────────────────────────────────┐ │ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff │ │ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff │ diff --git a/UnitTests/PanelViewTests.cs b/UnitTests/PanelViewTests.cs index 2da60dfaaa..3d596aaeb3 100644 --- a/UnitTests/PanelViewTests.cs +++ b/UnitTests/PanelViewTests.cs @@ -405,7 +405,7 @@ public void Setting_Child_Size_Disable_AutoSize () └──────────────────────────────────────────────────────────────────────────────┘ "; - var pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + var pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new Rect (0, 0, 80, 25), pos); } @@ -472,7 +472,7 @@ public void Not_Setting_Child_Size_Default_AutoSize_True () └──────────────────────────────────────────────────────────────────────────────┘ "; - var pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + var pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new Rect (0, 0, 80, 25), pos); } } diff --git a/UnitTests/PosTests.cs b/UnitTests/PosTests.cs index 528a722ebc..259bb106c5 100644 --- a/UnitTests/PosTests.cs +++ b/UnitTests/PosTests.cs @@ -164,7 +164,7 @@ public void Bottom_Equal_Inside_Window () └──────────────────────────────────────┘ "; - GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + TestHelpers.AssertDriverContentsWithFrameAre (expected, output); } [Fact] @@ -211,7 +211,7 @@ public void AnchorEnd_Better_Than_Bottom_Equal_Inside_Window () └──────────────────────────────────────┘ "; - GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + TestHelpers.AssertDriverContentsWithFrameAre (expected, output); } [Fact] @@ -274,7 +274,7 @@ public void Bottom_Equal_Inside_Window_With_MenuBar_And_StatusBar_On_Toplevel () F1 Help "; - GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + TestHelpers.AssertDriverContentsWithFrameAre (expected, output); } [Fact] @@ -337,7 +337,7 @@ public void AnchorEnd_Better_Than_Bottom_Equal_Inside_Window_With_MenuBar_And_St F1 Help "; - GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + TestHelpers.AssertDriverContentsWithFrameAre (expected, output); } [Fact] diff --git a/UnitTests/RadioGroupTests.cs b/UnitTests/RadioGroupTests.cs index 5ec6bbdd94..7536288024 100644 --- a/UnitTests/RadioGroupTests.cs +++ b/UnitTests/RadioGroupTests.cs @@ -99,7 +99,7 @@ public void DisplayMode_Width_Height_Vertical_Horizontal_Space () └────────────────────────────┘ "; - var pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + var pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new Rect (0, 0, 30, 5), pos); rg.DisplayMode = DisplayModeLayout.Horizontal; @@ -120,7 +120,7 @@ public void DisplayMode_Width_Height_Vertical_Horizontal_Space () └────────────────────────────┘ "; - pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new Rect (0, 0, 30, 5), pos); rg.HorizontalSpace = 4; @@ -140,7 +140,7 @@ public void DisplayMode_Width_Height_Vertical_Horizontal_Space () └────────────────────────────┘ "; - pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new Rect (0, 0, 30, 5), pos); } diff --git a/UnitTests/ScenarioTests.cs b/UnitTests/ScenarioTests.cs index ae40ea9883..7a158f76cc 100644 --- a/UnitTests/ScenarioTests.cs +++ b/UnitTests/ScenarioTests.cs @@ -11,7 +11,7 @@ // Alias Console to MockConsole so we don't accidentally use Console using Console = Terminal.Gui.FakeConsole; -namespace Terminal.Gui { +namespace UICatalog { public class ScenarioTests { readonly ITestOutputHelper output; diff --git a/UnitTests/ScrollBarViewTests.cs b/UnitTests/ScrollBarViewTests.cs index 0248674bf8..1826279781 100644 --- a/UnitTests/ScrollBarViewTests.cs +++ b/UnitTests/ScrollBarViewTests.cs @@ -737,7 +737,7 @@ public void Hosting_ShowBothScrollIndicator_Invisible () └───────────────────────────────────────────┘ "; - var pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + var pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new Rect (0, 0, 45, 20), pos); textView.WordWrap = true; @@ -774,7 +774,7 @@ public void Hosting_ShowBothScrollIndicator_Invisible () └────────────────────────┘ "; - pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new Rect (0, 0, 26, 20), pos); ((FakeDriver)Application.Driver).SetBufferSize (10, 10); @@ -800,7 +800,7 @@ public void Hosting_ShowBothScrollIndicator_Invisible () └────────┘ "; - pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new Rect (0, 0, 10, 10), pos); } @@ -824,7 +824,7 @@ public void ContentBottomRightCorner_Not_Redraw_If_Both_Size_Equal_To_Zero () Assert.True (sbv.OtherScrollBarView.ShowScrollIndicator); Assert.True (sbv.Visible); Assert.True (sbv.OtherScrollBarView.Visible); - GraphViewTests.AssertDriverContentsWithFrameAre (@" + TestHelpers.AssertDriverContentsWithFrameAre (@" This is a tes▲ This is a tes┬ This is a tes┴ @@ -842,7 +842,7 @@ This is a tes▼ Assert.False (sbv.Visible); Assert.False (sbv.OtherScrollBarView.Visible); Application.Top.Redraw (Application.Top.Bounds); - GraphViewTests.AssertDriverContentsWithFrameAre (@" + TestHelpers.AssertDriverContentsWithFrameAre (@" This is a test This is a test This is a test @@ -860,7 +860,7 @@ This is a test Assert.True (sbv.Visible); Assert.True (sbv.OtherScrollBarView.Visible); Application.Top.Redraw (Application.Top.Bounds); - GraphViewTests.AssertDriverContentsWithFrameAre (@" + TestHelpers.AssertDriverContentsWithFrameAre (@" This is a tes▲ This is a tes┬ This is a tes┴ @@ -887,7 +887,7 @@ public void ContentBottomRightCorner_Not_Redraw_If_One_Size_Equal_To_Zero () Assert.Null (sbv.OtherScrollBarView); Assert.True (sbv.ShowScrollIndicator); Assert.True (sbv.Visible); - GraphViewTests.AssertDriverContentsWithFrameAre (@" + TestHelpers.AssertDriverContentsWithFrameAre (@" This is a tes▲ This is a tes┬ This is a tes┴ @@ -901,7 +901,7 @@ This is a tes▼ Assert.False (sbv.ShowScrollIndicator); Assert.False (sbv.Visible); Application.Top.Redraw (Application.Top.Bounds); - GraphViewTests.AssertDriverContentsWithFrameAre (@" + TestHelpers.AssertDriverContentsWithFrameAre (@" This is a test This is a test This is a test @@ -930,7 +930,7 @@ public void ShowScrollIndicator_False_Must_Also_Set_Visible_To_False_To_Not_Resp Assert.Null (sbv.OtherScrollBarView); Assert.False (sbv.ShowScrollIndicator); Assert.False (sbv.Visible); - GraphViewTests.AssertDriverContentsWithFrameAre (@" + TestHelpers.AssertDriverContentsWithFrameAre (@" This is a test[ Click Me! ] This is a test This is a test @@ -957,7 +957,7 @@ This is a test Assert.False (sbv.ShowScrollIndicator); Assert.True (sbv.Visible); Application.Top.Redraw (Application.Top.Bounds); - GraphViewTests.AssertDriverContentsWithFrameAre (@" + TestHelpers.AssertDriverContentsWithFrameAre (@" This is a test[ Click Me! ] This is a test This is a test diff --git a/UnitTests/ScrollViewTests.cs b/UnitTests/ScrollViewTests.cs index 434f06ddb8..b007d962f1 100644 --- a/UnitTests/ScrollViewTests.cs +++ b/UnitTests/ScrollViewTests.cs @@ -196,13 +196,13 @@ public void AutoHideScrollBars_ShowHorizontalScrollIndicator_ShowVerticalScrollI Assert.True (sv.AutoHideScrollBars); Assert.False (sv.ShowHorizontalScrollIndicator); Assert.False (sv.ShowVerticalScrollIndicator); - GraphViewTests.AssertDriverContentsWithFrameAre ("", output); + TestHelpers.AssertDriverContentsWithFrameAre ("", output); sv.AutoHideScrollBars = false; sv.ShowHorizontalScrollIndicator = true; sv.ShowVerticalScrollIndicator = true; sv.Redraw (sv.Bounds); - GraphViewTests.AssertDriverContentsWithFrameAre (@" + TestHelpers.AssertDriverContentsWithFrameAre (@" ▲ ┬ │ @@ -233,7 +233,7 @@ public void ContentSize_AutoHideScrollBars_ShowHorizontalScrollIndicator_ShowVer Assert.True (sv.AutoHideScrollBars); Assert.True (sv.ShowHorizontalScrollIndicator); Assert.True (sv.ShowVerticalScrollIndicator); - GraphViewTests.AssertDriverContentsWithFrameAre (@" + TestHelpers.AssertDriverContentsWithFrameAre (@" ▲ ┬ ┴ @@ -267,7 +267,7 @@ public void ContentOffset_ContentSize_AutoHideScrollBars_ShowHorizontalScrollInd Assert.True (sv.AutoHideScrollBars); Assert.True (sv.ShowHorizontalScrollIndicator); Assert.True (sv.ShowVerticalScrollIndicator); - GraphViewTests.AssertDriverContentsWithFrameAre (@" + TestHelpers.AssertDriverContentsWithFrameAre (@" ▲ ░ ░ diff --git a/UnitTests/StatusBarTests.cs b/UnitTests/StatusBarTests.cs index c66d2c0ff1..7e524bf177 100644 --- a/UnitTests/StatusBarTests.cs +++ b/UnitTests/StatusBarTests.cs @@ -113,7 +113,7 @@ public void Redraw_Output () ^O Open {Application.Driver.VLine} ^Q Quit "; - GraphViewTests.AssertDriverContentsAre (expected, output); + TestHelpers.AssertDriverContentsAre (expected, output); sb = new StatusBar (new StatusItem [] { new StatusItem (Key.CtrlMask | Key.Q, "~CTRL-O~ Open", null), @@ -125,7 +125,7 @@ public void Redraw_Output () CTRL-O Open {Application.Driver.VLine} CTRL-Q Quit "; - GraphViewTests.AssertDriverContentsAre (expected, output); + TestHelpers.AssertDriverContentsAre (expected, output); } [Fact] diff --git a/UnitTests/TabViewTests.cs b/UnitTests/TabViewTests.cs index b1da152910..ab376fd3e0 100644 --- a/UnitTests/TabViewTests.cs +++ b/UnitTests/TabViewTests.cs @@ -257,7 +257,7 @@ public void ShowTopLine_True_TabsOnBottom_False_TestThinTabView_WithLongNames () tv.Redraw (tv.Bounds); - GraphViewTests.AssertDriverContentsWithFrameAre (@" + TestHelpers.AssertDriverContentsWithFrameAre (@" ┌──┐ │12│13 │ └─────┐ @@ -268,7 +268,7 @@ public void ShowTopLine_True_TabsOnBottom_False_TestThinTabView_WithLongNames () tv.Redraw (tv.Bounds); - GraphViewTests.AssertDriverContentsWithFrameAre (@" + TestHelpers.AssertDriverContentsWithFrameAre (@" ┌──┐ 12│13│ ┌──┘ └──┐ @@ -282,7 +282,7 @@ public void ShowTopLine_True_TabsOnBottom_False_TestThinTabView_WithLongNames () tv.Redraw (tv.Bounds); - GraphViewTests.AssertDriverContentsWithFrameAre (@" + TestHelpers.AssertDriverContentsWithFrameAre (@" ┌───────┐ │1234567│ │ └► @@ -293,7 +293,7 @@ public void ShowTopLine_True_TabsOnBottom_False_TestThinTabView_WithLongNames () tv.SelectedTab = tab2; tv.Redraw (tv.Bounds); - GraphViewTests.AssertDriverContentsWithFrameAre (@" + TestHelpers.AssertDriverContentsWithFrameAre (@" ┌──┐ │13│ ◄ └─────┐ @@ -307,7 +307,7 @@ public void ShowTopLine_True_TabsOnBottom_False_TestThinTabView_WithLongNames () tv.Redraw (tv.Bounds); - GraphViewTests.AssertDriverContentsWithFrameAre (@" + TestHelpers.AssertDriverContentsWithFrameAre (@" ┌───────┐ │abcdefg│ ◄ └┐ @@ -333,7 +333,7 @@ public void ShowTopLine_False_TabsOnBottom_False_TestThinTabView_WithLongNames ( tv.Redraw (tv.Bounds); - GraphViewTests.AssertDriverContentsWithFrameAre (@" + TestHelpers.AssertDriverContentsWithFrameAre (@" │12│13 │ └─────┐ │hi │ @@ -345,7 +345,7 @@ public void ShowTopLine_False_TabsOnBottom_False_TestThinTabView_WithLongNames ( tv.Redraw (tv.Bounds); - GraphViewTests.AssertDriverContentsWithFrameAre (@" + TestHelpers.AssertDriverContentsWithFrameAre (@" 12│13│ ┌──┘ └──┐ │hi2 │ @@ -360,7 +360,7 @@ public void ShowTopLine_False_TabsOnBottom_False_TestThinTabView_WithLongNames ( tv.Redraw (tv.Bounds); - GraphViewTests.AssertDriverContentsWithFrameAre (@" + TestHelpers.AssertDriverContentsWithFrameAre (@" │1234567│ │ └► │hi │ @@ -371,7 +371,7 @@ public void ShowTopLine_False_TabsOnBottom_False_TestThinTabView_WithLongNames ( tv.SelectedTab = tab2; tv.Redraw (tv.Bounds); - GraphViewTests.AssertDriverContentsWithFrameAre (@" + TestHelpers.AssertDriverContentsWithFrameAre (@" │13│ ◄ └─────┐ │hi2 │ @@ -385,7 +385,7 @@ public void ShowTopLine_False_TabsOnBottom_False_TestThinTabView_WithLongNames ( tv.Redraw (tv.Bounds); - GraphViewTests.AssertDriverContentsWithFrameAre (@" + TestHelpers.AssertDriverContentsWithFrameAre (@" │abcdefg│ ◄ └┐ │hi2 │ @@ -403,7 +403,7 @@ public void ShowTopLine_True_TabsOnBottom_False_TestTabView_Width4 () tv.Redraw (tv.Bounds); - GraphViewTests.AssertDriverContentsWithFrameAre (@" + TestHelpers.AssertDriverContentsWithFrameAre (@" ┌─┐ │T│ │ └► @@ -423,7 +423,7 @@ public void ShowTopLine_False_TabsOnBottom_False_TestTabView_Width4 () tv.Redraw (tv.Bounds); - GraphViewTests.AssertDriverContentsWithFrameAre (@" + TestHelpers.AssertDriverContentsWithFrameAre (@" │T│ │ └► │hi│ @@ -441,7 +441,7 @@ public void ShowTopLine_True_TabsOnBottom_False_TestTabView_Width3 () tv.Redraw (tv.Bounds); - GraphViewTests.AssertDriverContentsWithFrameAre (@" + TestHelpers.AssertDriverContentsWithFrameAre (@" ┌┐ ││ │└► @@ -461,7 +461,7 @@ public void ShowTopLine_False_TabsOnBottom_False_TestTabView_Width3 () tv.Redraw (tv.Bounds); - GraphViewTests.AssertDriverContentsWithFrameAre (@" + TestHelpers.AssertDriverContentsWithFrameAre (@" ││ │└► │h│ @@ -487,7 +487,7 @@ public void ShowTopLine_True_TabsOnBottom_True_TestThinTabView_WithLongNames () tv.Redraw (tv.Bounds); - GraphViewTests.AssertDriverContentsWithFrameAre (@" + TestHelpers.AssertDriverContentsWithFrameAre (@" ┌────────┐ │hi │ │ ┌─────┘ @@ -501,7 +501,7 @@ public void ShowTopLine_True_TabsOnBottom_True_TestThinTabView_WithLongNames () tv.Redraw (tv.Bounds); - GraphViewTests.AssertDriverContentsWithFrameAre (@" + TestHelpers.AssertDriverContentsWithFrameAre (@" ┌────────┐ │hi │ │ ┌► @@ -512,7 +512,7 @@ public void ShowTopLine_True_TabsOnBottom_True_TestThinTabView_WithLongNames () tv.SelectedTab = tab2; tv.Redraw (tv.Bounds); - GraphViewTests.AssertDriverContentsWithFrameAre (@" + TestHelpers.AssertDriverContentsWithFrameAre (@" ┌────────┐ │hi2 │ ◄ ┌─────┘ @@ -526,7 +526,7 @@ public void ShowTopLine_True_TabsOnBottom_True_TestThinTabView_WithLongNames () tv.Redraw (tv.Bounds); - GraphViewTests.AssertDriverContentsWithFrameAre (@" + TestHelpers.AssertDriverContentsWithFrameAre (@" ┌────────┐ │hi2 │ ◄ ┌┘ @@ -552,7 +552,7 @@ public void ShowTopLine_False_TabsOnBottom_True_TestThinTabView_WithLongNames () tv.Redraw (tv.Bounds); - GraphViewTests.AssertDriverContentsWithFrameAre (@" + TestHelpers.AssertDriverContentsWithFrameAre (@" ┌────────┐ │hi │ │ │ @@ -564,7 +564,7 @@ public void ShowTopLine_False_TabsOnBottom_True_TestThinTabView_WithLongNames () tv.Redraw (tv.Bounds); - GraphViewTests.AssertDriverContentsWithFrameAre (@" + TestHelpers.AssertDriverContentsWithFrameAre (@" ┌────────┐ │hi2 │ │ │ @@ -579,7 +579,7 @@ public void ShowTopLine_False_TabsOnBottom_True_TestThinTabView_WithLongNames () tv.Redraw (tv.Bounds); - GraphViewTests.AssertDriverContentsWithFrameAre (@" + TestHelpers.AssertDriverContentsWithFrameAre (@" ┌────────┐ │hi │ │ │ @@ -590,7 +590,7 @@ public void ShowTopLine_False_TabsOnBottom_True_TestThinTabView_WithLongNames () tv.SelectedTab = tab2; tv.Redraw (tv.Bounds); - GraphViewTests.AssertDriverContentsWithFrameAre (@" + TestHelpers.AssertDriverContentsWithFrameAre (@" ┌────────┐ │hi2 │ │ │ @@ -604,7 +604,7 @@ public void ShowTopLine_False_TabsOnBottom_True_TestThinTabView_WithLongNames () tv.Redraw (tv.Bounds); - GraphViewTests.AssertDriverContentsWithFrameAre (@" + TestHelpers.AssertDriverContentsWithFrameAre (@" ┌────────┐ │hi2 │ │ │ @@ -624,7 +624,7 @@ public void ShowTopLine_True_TabsOnBottom_True_TestTabView_Width4 () tv.Redraw (tv.Bounds); - GraphViewTests.AssertDriverContentsWithFrameAre (@" + TestHelpers.AssertDriverContentsWithFrameAre (@" ┌──┐ │hi│ │ ┌► @@ -644,7 +644,7 @@ public void ShowTopLine_False_TabsOnBottom_True_TestTabView_Width4 () tv.Redraw (tv.Bounds); - GraphViewTests.AssertDriverContentsWithFrameAre (@" + TestHelpers.AssertDriverContentsWithFrameAre (@" ┌──┐ │hi│ │ │ @@ -664,7 +664,7 @@ public void ShowTopLine_True_TabsOnBottom_True_TestTabView_Width3 () tv.Redraw (tv.Bounds); - GraphViewTests.AssertDriverContentsWithFrameAre (@" + TestHelpers.AssertDriverContentsWithFrameAre (@" ┌─┐ │h│ │┌► @@ -684,7 +684,7 @@ public void ShowTopLine_False_TabsOnBottom_True_TestTabView_Width3 () tv.Redraw (tv.Bounds); - GraphViewTests.AssertDriverContentsWithFrameAre (@" + TestHelpers.AssertDriverContentsWithFrameAre (@" ┌─┐ │h│ │ │ @@ -706,7 +706,7 @@ public void ShowTopLine_True_TabsOnBottom_False_With_Unicode () tv.Redraw (tv.Bounds); - GraphViewTests.AssertDriverContentsWithFrameAre (@" + TestHelpers.AssertDriverContentsWithFrameAre (@" ┌────┐ │Tab0│ │ └─────────────► @@ -717,7 +717,7 @@ public void ShowTopLine_True_TabsOnBottom_False_With_Unicode () tv.Redraw (tv.Bounds); - GraphViewTests.AssertDriverContentsWithFrameAre (@" + TestHelpers.AssertDriverContentsWithFrameAre (@" ┌──────────────┐ │Les Misérables│ ◄ └───┐ @@ -741,7 +741,7 @@ public void ShowTopLine_True_TabsOnBottom_True_With_Unicode () tv.Redraw (tv.Bounds); - GraphViewTests.AssertDriverContentsWithFrameAre (@" + TestHelpers.AssertDriverContentsWithFrameAre (@" ┌──────────────────┐ │hi │ │ ┌─────────────► @@ -752,7 +752,7 @@ public void ShowTopLine_True_TabsOnBottom_True_With_Unicode () tv.Redraw (tv.Bounds); - GraphViewTests.AssertDriverContentsWithFrameAre (@" + TestHelpers.AssertDriverContentsWithFrameAre (@" ┌──────────────────┐ │hi2 │ ◄ ┌───┘ diff --git a/UnitTests/TableViewTests.cs b/UnitTests/TableViewTests.cs index ddc9b642eb..6d075909b5 100644 --- a/UnitTests/TableViewTests.cs +++ b/UnitTests/TableViewTests.cs @@ -459,7 +459,7 @@ public void TableView_ExpandLastColumn_True () ├─┼──────┤ │1│2 │ "; - GraphViewTests.AssertDriverContentsAre (expected, output); + TestHelpers.AssertDriverContentsAre (expected, output); // Shutdown must be called to safely clean up Application if Init has been called Application.Shutdown (); @@ -482,7 +482,7 @@ public void TableView_ExpandLastColumn_False () ├─┼─┼────┤ │1│2│ │ "; - GraphViewTests.AssertDriverContentsAre (expected, output); + TestHelpers.AssertDriverContentsAre (expected, output); // Shutdown must be called to safely clean up Application if Init has been called Application.Shutdown (); @@ -506,7 +506,7 @@ public void TableView_ExpandLastColumn_False_ExactBounds () ├─┼─┤ │1│2│ "; - GraphViewTests.AssertDriverContentsAre (expected, output); + TestHelpers.AssertDriverContentsAre (expected, output); // Shutdown must be called to safely clean up Application if Init has been called Application.Shutdown (); @@ -670,7 +670,7 @@ public void TableView_ColorTests_FocusedOrNot (bool focused) ├─┼─┤ │1│2│ "; - GraphViewTests.AssertDriverContentsAre (expected, output); + TestHelpers.AssertDriverContentsAre (expected, output); string expectedColors = @" @@ -680,7 +680,7 @@ public void TableView_ColorTests_FocusedOrNot (bool focused) 01000 "; - GraphViewTests.AssertDriverColorsAre (expectedColors, new Attribute [] { + TestHelpers.AssertDriverColorsAre (expectedColors, new Attribute [] { // 0 tv.ColorScheme.Normal, // 1 @@ -714,7 +714,7 @@ public void TableView_ColorTests_InvertSelectedCellFirstCharacter (bool focused) ├─┼─┤ │1│2│ "; - GraphViewTests.AssertDriverContentsAre (expected, output); + TestHelpers.AssertDriverContentsAre (expected, output); string expectedColors = @" @@ -727,7 +727,7 @@ public void TableView_ColorTests_InvertSelectedCellFirstCharacter (bool focused) var invertHotFocus = new Attribute(tv.ColorScheme.HotFocus.Background,tv.ColorScheme.HotFocus.Foreground); var invertHotNormal = new Attribute(tv.ColorScheme.HotNormal.Background,tv.ColorScheme.HotNormal.Foreground); - GraphViewTests.AssertDriverColorsAre (expectedColors, new Attribute [] { + TestHelpers.AssertDriverColorsAre (expectedColors, new Attribute [] { // 0 tv.ColorScheme.Normal, // 1 @@ -771,7 +771,7 @@ public void TableView_ColorsTest_RowColorGetter (bool focused) ├─┼─┤ │1│2│ "; - GraphViewTests.AssertDriverContentsAre (expected, output); + TestHelpers.AssertDriverContentsAre (expected, output); string expectedColors = @" @@ -781,7 +781,7 @@ public void TableView_ColorsTest_RowColorGetter (bool focused) 21222 "; - GraphViewTests.AssertDriverColorsAre (expectedColors, new Attribute [] { + TestHelpers.AssertDriverColorsAre (expectedColors, new Attribute [] { // 0 tv.ColorScheme.Normal, // 1 @@ -803,7 +803,7 @@ public void TableView_ColorsTest_RowColorGetter (bool focused) ├─┼─┤ │1│5│ "; - GraphViewTests.AssertDriverContentsAre (expected, output); + TestHelpers.AssertDriverContentsAre (expected, output); expectedColors = @" @@ -816,7 +816,7 @@ public void TableView_ColorsTest_RowColorGetter (bool focused) // now we only see 2 colors used (the selected cell color and Normal // rowHighlight should no longer be used because the delegate returned null // (now that the cell value is 5 - which does not match the conditional) - GraphViewTests.AssertDriverColorsAre (expectedColors, new Attribute [] { + TestHelpers.AssertDriverColorsAre (expectedColors, new Attribute [] { // 0 tv.ColorScheme.Normal, // 1 @@ -864,7 +864,7 @@ public void TableView_ColorsTest_ColorGetter (bool focused) ├─┼─┤ │1│2│ "; - GraphViewTests.AssertDriverContentsAre (expected, output); + TestHelpers.AssertDriverContentsAre (expected, output); string expectedColors = @" @@ -874,7 +874,7 @@ public void TableView_ColorsTest_ColorGetter (bool focused) 01020 "; - GraphViewTests.AssertDriverColorsAre (expectedColors, new Attribute [] { + TestHelpers.AssertDriverColorsAre (expectedColors, new Attribute [] { // 0 tv.ColorScheme.Normal, // 1 @@ -896,7 +896,7 @@ public void TableView_ColorsTest_ColorGetter (bool focused) ├─┼─┤ │1│5│ "; - GraphViewTests.AssertDriverContentsAre (expected, output); + TestHelpers.AssertDriverContentsAre (expected, output); expectedColors = @" @@ -909,7 +909,7 @@ public void TableView_ColorsTest_ColorGetter (bool focused) // now we only see 2 colors used (the selected cell color and Normal // cellHighlight should no longer be used because the delegate returned null // (now that the cell value is 5 - which does not match the conditional) - GraphViewTests.AssertDriverColorsAre (expectedColors, new Attribute [] { + TestHelpers.AssertDriverColorsAre (expectedColors, new Attribute [] { // 0 tv.ColorScheme.Normal, // 1 @@ -1005,7 +1005,7 @@ public void ScrollRight_SmoothScrolling () │A│B│C│ │1│2│3│"; - GraphViewTests.AssertDriverContentsAre (expected, output); + TestHelpers.AssertDriverContentsAre (expected, output); // Scroll right @@ -1026,7 +1026,7 @@ public void ScrollRight_SmoothScrolling () │B│C│D│ │2│3│4│"; - GraphViewTests.AssertDriverContentsAre (expected, output); + TestHelpers.AssertDriverContentsAre (expected, output); // Shutdown must be called to safely clean up Application if Init has been called @@ -1070,7 +1070,7 @@ public void ScrollRight_WithoutSmoothScrolling () │A│B│C│ │1│2│3│"; - GraphViewTests.AssertDriverContentsAre (expected, output); + TestHelpers.AssertDriverContentsAre (expected, output); // Scroll right @@ -1091,7 +1091,7 @@ public void ScrollRight_WithoutSmoothScrolling () │D│E│F│ │4│5│6│"; - GraphViewTests.AssertDriverContentsAre (expected, output); + TestHelpers.AssertDriverContentsAre (expected, output); // Shutdown must be called to safely clean up Application if Init has been called @@ -1135,7 +1135,7 @@ public void LongColumnTest () │1│2 │ "; - GraphViewTests.AssertDriverContentsAre (expected, output); + TestHelpers.AssertDriverContentsAre (expected, output); // get a style for the long column var style = tableView.Style.GetOrCreateColumnStyle(dt.Columns[2]); @@ -1152,7 +1152,7 @@ public void LongColumnTest () │1│2│aaaaaaaaaa │ │1│2│aaa │ "; - GraphViewTests.AssertDriverContentsAre (expected, output); + TestHelpers.AssertDriverContentsAre (expected, output); // revert the style change style.MaxWidth = TableView.DefaultMaxCellWidth; @@ -1172,7 +1172,7 @@ public void LongColumnTest () │1│2│aaaaaaaaaaaaa... │ │1│2│aaa │ "; - GraphViewTests.AssertDriverContentsAre (expected, output); + TestHelpers.AssertDriverContentsAre (expected, output); // revert style change style.RepresentationGetter = null; @@ -1197,7 +1197,7 @@ public void LongColumnTest () │1│2│aaaaaaaaaaaaaaaaaaa│ │1│2│aaa │ "; - GraphViewTests.AssertDriverContentsAre (expected, output); + TestHelpers.AssertDriverContentsAre (expected, output); // Now test making the width too small for the MinAcceptableWidth // the Column won't fit so should not be rendered @@ -1214,7 +1214,7 @@ public void LongColumnTest () │1│2 │ "; - GraphViewTests.AssertDriverContentsAre (expected, output); + TestHelpers.AssertDriverContentsAre (expected, output); // setting width to 10 leaves just enough space for the column to // meet MinAcceptableWidth of 5. Column width includes terminator line @@ -1228,7 +1228,7 @@ public void LongColumnTest () │1│2│aaaa│ │1│2│aaa │ "; - GraphViewTests.AssertDriverContentsAre (expected, output); + TestHelpers.AssertDriverContentsAre (expected, output); Application.Shutdown (); } @@ -1274,7 +1274,7 @@ public void ScrollIndicators () ├─┼─┼─► │1│2│3│"; - GraphViewTests.AssertDriverContentsAre (expected, output); + TestHelpers.AssertDriverContentsAre (expected, output); // Scroll right @@ -1291,7 +1291,7 @@ public void ScrollIndicators () ◄─┼─┼─► │2│3│4│"; - GraphViewTests.AssertDriverContentsAre (expected, output); + TestHelpers.AssertDriverContentsAre (expected, output); // Scroll right twice more (to end of columns) @@ -1306,7 +1306,7 @@ public void ScrollIndicators () ◄─┼─┼─┤ │4│5│6│"; - GraphViewTests.AssertDriverContentsAre (expected, output); + TestHelpers.AssertDriverContentsAre (expected, output); // Shutdown must be called to safely clean up Application if Init has been called Application.Shutdown (); diff --git a/UnitTests/TestHelpers.cs b/UnitTests/TestHelpers.cs new file mode 100644 index 0000000000..95ece35f68 --- /dev/null +++ b/UnitTests/TestHelpers.cs @@ -0,0 +1,230 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Xunit.Abstractions; +using Xunit; +using Terminal.Gui; +using Rune = System.Rune; +using Attribute = Terminal.Gui.Attribute; +using System.Text.RegularExpressions; +using System.Reflection; + + +// This class enables test functions annotated with the [AutoInitShutdown] attribute to +// automatically call Application.Init before called and Application.Shutdown after +// +// This is necessary because a) Application is a singleton and Init/Shutdown must be called +// as a pair, and b) all unit test functions should be atomic. +[AttributeUsage (AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = false, Inherited = true)] +public class AutoInitShutdownAttribute : Xunit.Sdk.BeforeAfterTestAttribute { + + static bool _init = false; + public override void Before (MethodInfo methodUnderTest) + { + if (_init) { + throw new InvalidOperationException ("After did not run."); + } + + Application.Init (new FakeDriver (), new FakeMainLoop (() => FakeConsole.ReadKey (true))); + _init = true; + } + + public override void After (MethodInfo methodUnderTest) + { + Application.Shutdown (); + _init = false; + } +} + +class TestHelpers { + + +#pragma warning disable xUnit1013 // Public method should be marked as test + public static void AssertDriverContentsAre (string expectedLook, ITestOutputHelper output) + { +#pragma warning restore xUnit1013 // Public method should be marked as test + + var sb = new StringBuilder (); + var driver = ((FakeDriver)Application.Driver); + + var contents = driver.Contents; + + for (int r = 0; r < driver.Rows; r++) { + for (int c = 0; c < driver.Cols; c++) { + sb.Append ((char)contents [r, c, 0]); + } + sb.AppendLine (); + } + + var actualLook = sb.ToString (); + + if (!string.Equals (expectedLook, actualLook)) { + + // ignore trailing whitespace on each line + var trailingWhitespace = new Regex (@"\s+$", RegexOptions.Multiline); + + // get rid of trailing whitespace on each line (and leading/trailing whitespace of start/end of full string) + expectedLook = trailingWhitespace.Replace (expectedLook, "").Trim (); + actualLook = trailingWhitespace.Replace (actualLook, "").Trim (); + + // standardize line endings for the comparison + expectedLook = expectedLook.Replace ("\r\n", "\n"); + actualLook = actualLook.Replace ("\r\n", "\n"); + + output?.WriteLine ("Expected:" + Environment.NewLine + expectedLook); + output?.WriteLine ("But Was:" + Environment.NewLine + actualLook); + + Assert.Equal (expectedLook, actualLook); + } + } + + public static Rect AssertDriverContentsWithFrameAre (string expectedLook, ITestOutputHelper output) + { + var lines = new List> (); + var sb = new StringBuilder (); + var driver = ((FakeDriver)Application.Driver); + var x = -1; + var y = -1; + int w = -1; + int h = -1; + + var contents = driver.Contents; + + for (int r = 0; r < driver.Rows; r++) { + var runes = new List (); + for (int c = 0; c < driver.Cols; c++) { + var rune = (char)contents [r, c, 0]; + if (rune != ' ') { + if (x == -1) { + x = c; + y = r; + for (int i = 0; i < c; i++) { + runes.InsertRange (i, new List () { ' ' }); + } + } + if (Rune.ColumnWidth (rune) > 1) { + c++; + } + if (c + 1 > w) { + w = c + 1; + } + h = r - y + 1; + } + if (x > -1) { + runes.Add (rune); + } + } + if (runes.Count > 0) { + lines.Add (runes); + } + } + + // Remove unnecessary empty lines + if (lines.Count > 0) { + for (int r = lines.Count - 1; r > h - 1; r--) { + lines.RemoveAt (r); + } + } + + // Remove trailing whitespace on each line + for (int r = 0; r < lines.Count; r++) { + List row = lines [r]; + for (int c = row.Count - 1; c >= 0; c--) { + var rune = row [c]; + if (rune != ' ' || (row.Sum (x => Rune.ColumnWidth (x)) == w)) { + break; + } + row.RemoveAt (c); + } + } + + // Convert char list to string + for (int r = 0; r < lines.Count; r++) { + var line = new string (lines [r].ToArray ()); + if (r == lines.Count - 1) { + sb.Append (line); + } else { + sb.AppendLine (line); + } + } + + var actualLook = sb.ToString (); + + if (!string.Equals (expectedLook, actualLook)) { + + // standardize line endings for the comparison + expectedLook = expectedLook.Replace ("\r\n", "\n"); + actualLook = actualLook.Replace ("\r\n", "\n"); + + // Remove the first and the last line ending from the expectedLook + if (expectedLook.StartsWith ("\n")) { + expectedLook = expectedLook [1..]; + } + if (expectedLook.EndsWith ("\n")) { + expectedLook = expectedLook [..^1]; + } + + output?.WriteLine ("Expected:" + Environment.NewLine + expectedLook); + output?.WriteLine ("But Was:" + Environment.NewLine + actualLook); + + Assert.Equal (expectedLook, actualLook); + } + return new Rect (x > -1 ? x : 0, y > -1 ? y : 0, w > -1 ? w : 0, h > -1 ? h : 0); + } + +#pragma warning disable xUnit1013 // Public method should be marked as test + /// + /// Verifies the console was rendered using the given at the given locations. + /// Pass a bitmap of indexes into as and the + /// test method will verify those colors were used in the row/col of the console during rendering + /// + /// Numbers between 0 and 9 for each row/col of the console. Must be valid indexes of + /// + public static void AssertDriverColorsAre (string expectedLook, Attribute [] expectedColors) + { +#pragma warning restore xUnit1013 // Public method should be marked as test + + if (expectedColors.Length > 10) { + throw new ArgumentException ("This method only works for UIs that use at most 10 colors"); + } + + expectedLook = expectedLook.Trim (); + var driver = ((FakeDriver)Application.Driver); + + var contents = driver.Contents; + + int r = 0; + foreach (var line in expectedLook.Split ('\n').Select (l => l.Trim ())) { + + for (int c = 0; c < line.Length; c++) { + + int val = contents [r, c, 1]; + + var match = expectedColors.Where (e => e.Value == val).ToList (); + if (match.Count == 0) { + throw new Exception ($"Unexpected color {DescribeColor (val)} was used at row {r} and col {c} (indexes start at 0). Color value was {val} (expected colors were {string.Join (",", expectedColors.Select (c => c.Value))})"); + } else if (match.Count > 1) { + throw new ArgumentException ($"Bad value for expectedColors, {match.Count} Attributes had the same Value"); + } + + var colorUsed = Array.IndexOf (expectedColors, match [0]).ToString () [0]; + var userExpected = line [c]; + + if (colorUsed != userExpected) { + throw new Exception ($"Colors used did not match expected at row {r} and col {c} (indexes start at 0). Color index used was {DescribeColor (colorUsed)} but test expected {DescribeColor (userExpected)} (these are indexes into the expectedColors array)"); + } + } + + r++; + } + } + + private static object DescribeColor (int userExpected) + { + var a = new Attribute (userExpected); + return $"{a.Foreground},{a.Background}"; + } +} + diff --git a/UnitTests/TextFormatterTests.cs b/UnitTests/TextFormatterTests.cs index 0199df733e..29018c4ae1 100644 --- a/UnitTests/TextFormatterTests.cs +++ b/UnitTests/TextFormatterTests.cs @@ -2190,7 +2190,7 @@ public void WordWrap_preserveTrailingSpaces_Horizontal_With_Simple_Runes () └───┘ "; - var pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + var pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new Rect (0, 0, width + 2, height + 2), pos); } @@ -2229,7 +2229,7 @@ public void WordWrap_preserveTrailingSpaces_Vertical_With_Simple_Runes () └────────┘ "; - var pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + var pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new Rect (0, 0, width + 2, height + 2), pos); } @@ -2270,7 +2270,7 @@ public void WordWrap_preserveTrailingSpaces_Horizontal_With_Wide_Runes () └──────┘ "; - var pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + var pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new Rect (0, 0, width + 2, height + 2), pos); } @@ -2310,7 +2310,7 @@ public void WordWrap_preserveTrailingSpaces_Vertical_With_Wide_Runes () └────────┘ "; - var pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + var pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new Rect (0, 0, width + 2, height + 2), pos); } @@ -3059,7 +3059,7 @@ public void Draw_Horizontal_Simple_Runes () Demo Simple Rune "; - var pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + var pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new Rect (0, 0, 16, 1), pos); } @@ -3096,7 +3096,7 @@ public void Draw_Vertical_Simple_Runes () e "; - var pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + var pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new Rect (0, 0, 1, 16), pos); } @@ -3114,7 +3114,7 @@ public void Draw_Horizontal_Wide_Runes () デモエムポンズ "; - var pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + var pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new Rect (0, 0, 14, 1), pos); } @@ -3140,7 +3140,7 @@ public void Draw_Vertical_Wide_Runes () ズ "; - var pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + var pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new Rect (0, 0, 2, 7), pos); } @@ -3169,7 +3169,7 @@ public void Draw_Vertical_Wide_Runes_With_ForceValidatePosDim () ズ "; - var pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + var pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new Rect (0, 0, 2, 7), pos); } @@ -3208,7 +3208,7 @@ public void Draw_Horizontal_Simple_TextAlignments () └────────────────────┘ "; - var pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + var pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new Rect (0, 0, width + 2, 6), pos); } @@ -3263,7 +3263,7 @@ public void Draw_Vertical_Simple_TextAlignments () └───────┘ "; - var pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + var pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new Rect (0, 0, 9, height + 2), pos); } @@ -3302,7 +3302,7 @@ public void Draw_Horizontal_Wide_TextAlignments () └─────────────────────────┘ "; - var pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + var pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new Rect (0, 0, width + 2, 6), pos); } @@ -3361,7 +3361,7 @@ public void Draw_Vertical_Wide_TextAlignments () └───────────┘ "; - var pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + var pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new Rect (0, 0, 13, height + 2), pos); } @@ -3385,7 +3385,7 @@ public void Draw_Fill_Remaining () tf2.Draw (new Rect (new Point (0, 2), tf2Size), view.GetNormalColor (), view.ColorScheme.HotNormal); - GraphViewTests.AssertDriverContentsWithFrameAre (@" + TestHelpers.AssertDriverContentsWithFrameAre (@" This view needs to be cleared before rewritten. This TextFormatter (tf1) without fill will not be cleared on rewritten. This TextFormatter (tf2) with fill will be cleared on rewritten. @@ -3400,7 +3400,7 @@ This TextFormatter (tf2) with fill will be cleared on rewritten. tf2.Text = "This TextFormatter (tf2) is rewritten."; tf2.Draw (new Rect (new Point (0, 2), tf2Size), view.GetNormalColor (), view.ColorScheme.HotNormal); - GraphViewTests.AssertDriverContentsWithFrameAre (@" + TestHelpers.AssertDriverContentsWithFrameAre (@" This view is rewritten. This TextFormatter (tf1) is rewritten.will not be cleared on rewritten. This TextFormatter (tf2) is rewritten. @@ -3502,7 +3502,7 @@ public void AutoSize_False_View_IsEmpty_False_Return_Null_Lines () └────────┘ "; - var pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + var pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new Rect (0, 0, 10, 4), pos); text = "0123456789"; @@ -3520,7 +3520,7 @@ public void AutoSize_False_View_IsEmpty_False_Return_Null_Lines () └────────┘ "; - pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new Rect (0, 0, 10, 4), pos); } @@ -3555,7 +3555,7 @@ public void AutoSize_False_View_IsEmpty_True_Minimum_Height () └────────┘ "; - var pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + var pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new Rect (0, 0, 10, 4), pos); text = "0123456789"; @@ -3574,7 +3574,7 @@ public void AutoSize_False_View_IsEmpty_True_Minimum_Height () └────────┘ "; - pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new Rect (0, 0, 10, 4), pos); } @@ -3610,7 +3610,7 @@ public void AutoSize_True_Label_IsEmpty_False_Never_Return_Null_Lines () └────────┘ "; - var pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + var pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new Rect (0, 0, 10, 4), pos); text = "0123456789"; @@ -3629,7 +3629,7 @@ public void AutoSize_True_Label_IsEmpty_False_Never_Return_Null_Lines () └────────┘ "; - pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new Rect (0, 0, 10, 4), pos); } @@ -3666,7 +3666,7 @@ public void AutoSize_False_Label_IsEmpty_True_Return_Null_Lines () └────────┘ "; - var pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + var pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new Rect (0, 0, 10, 4), pos); text = "0123456789"; @@ -3685,7 +3685,7 @@ public void AutoSize_False_Label_IsEmpty_True_Return_Null_Lines () └────────┘ "; - pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new Rect (0, 0, 10, 4), pos); } @@ -3720,7 +3720,7 @@ public void AutoSize_True_Label_IsEmpty_False_Minimum_Height () └────────┘ "; - var pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + var pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new Rect (0, 0, 10, 4), pos); text = "0123456789"; @@ -3739,7 +3739,7 @@ public void AutoSize_True_Label_IsEmpty_False_Minimum_Height () └────────┘ "; - pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new Rect (0, 0, 10, 4), pos); } @@ -3775,7 +3775,7 @@ public void AutoSize_False_Label_Height_Zero_Returns_Minimum_Height () └────────┘ "; - var pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + var pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new Rect (0, 0, 10, 4), pos); text = "0123456789"; @@ -3794,7 +3794,7 @@ public void AutoSize_False_Label_Height_Zero_Returns_Minimum_Height () └────────┘ "; - pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new Rect (0, 0, 10, 4), pos); } @@ -3837,7 +3837,7 @@ public void AutoSize_True_View_IsEmpty_False_Minimum_Width () └──┘ "; - var pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + var pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new Rect (0, 0, 4, 10), pos); text = "0123456789"; @@ -3862,7 +3862,7 @@ public void AutoSize_True_View_IsEmpty_False_Minimum_Width () └──┘ "; - pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new Rect (0, 0, 4, 10), pos); } @@ -3904,7 +3904,7 @@ public void AutoSize_False_View_Width_Null_Returns_Host_Frame_Width () └──┘ "; - var pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + var pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new Rect (0, 0, 4, 10), pos); text = "0123456789"; @@ -3929,7 +3929,7 @@ public void AutoSize_False_View_Width_Null_Returns_Host_Frame_Width () └──┘ "; - pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new Rect (0, 0, 4, 10), pos); } @@ -3972,7 +3972,7 @@ public void AutoSize_True_View_IsEmpty_False_Minimum_Width_Wide_Rune () └──┘ "; - var pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + var pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new Rect (0, 0, 4, 10), pos); text = "0123456789"; @@ -3997,7 +3997,7 @@ public void AutoSize_True_View_IsEmpty_False_Minimum_Width_Wide_Rune () └──┘ "; - pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new Rect (0, 0, 4, 10), pos); } @@ -4039,7 +4039,7 @@ public void AutoSize_False_View_Width_Zero_Returns_Minimum_Width_With_Wide_Rune └──┘ "; - var pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + var pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new Rect (0, 0, 4, 10), pos); text = "0123456789"; @@ -4064,7 +4064,7 @@ public void AutoSize_False_View_Width_Zero_Returns_Minimum_Width_With_Wide_Rune └──┘ "; - pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new Rect (0, 0, 4, 10), pos); } diff --git a/UnitTests/TextViewTests.cs b/UnitTests/TextViewTests.cs index 0b32588d3f..193ecc549a 100644 --- a/UnitTests/TextViewTests.cs +++ b/UnitTests/TextViewTests.cs @@ -1973,7 +1973,7 @@ public void WordWrap_WrapModel_Output () tv.Redraw (tv.Bounds); - GraphViewTests.AssertDriverContentsWithFrameAre (@" + TestHelpers.AssertDriverContentsWithFrameAre (@" This is the first @@ -2000,7 +2000,7 @@ public void WordWrap_Deleting_Backwards () Assert.Equal (new Point (0, 0), tv.CursorPosition); Assert.Equal (0, tv.LeftColumn); - GraphViewTests.AssertDriverContentsAre (@" + TestHelpers.AssertDriverContentsAre (@" aaaa ", output); @@ -2008,35 +2008,35 @@ public void WordWrap_Deleting_Backwards () Assert.True (tv.ProcessKey (new KeyEvent (Key.Backspace, new KeyModifiers ()))); Application.Refresh (); Assert.Equal (0, tv.LeftColumn); - GraphViewTests.AssertDriverContentsAre (@" + TestHelpers.AssertDriverContentsAre (@" aaa ", output); Assert.True (tv.ProcessKey (new KeyEvent (Key.Backspace, new KeyModifiers ()))); Application.Refresh (); Assert.Equal (0, tv.LeftColumn); - GraphViewTests.AssertDriverContentsAre (@" + TestHelpers.AssertDriverContentsAre (@" aa ", output); Assert.True (tv.ProcessKey (new KeyEvent (Key.Backspace, new KeyModifiers ()))); Application.Refresh (); Assert.Equal (0, tv.LeftColumn); - GraphViewTests.AssertDriverContentsAre (@" + TestHelpers.AssertDriverContentsAre (@" a ", output); Assert.True (tv.ProcessKey (new KeyEvent (Key.Backspace, new KeyModifiers ()))); Application.Refresh (); Assert.Equal (0, tv.LeftColumn); - GraphViewTests.AssertDriverContentsAre (@" + TestHelpers.AssertDriverContentsAre (@" ", output); Assert.True (tv.ProcessKey (new KeyEvent (Key.Backspace, new KeyModifiers ()))); Application.Refresh (); Assert.Equal (0, tv.LeftColumn); - GraphViewTests.AssertDriverContentsAre (@" + TestHelpers.AssertDriverContentsAre (@" ", output); } @@ -2055,7 +2055,7 @@ public void WordWrap_ReadOnly_CursorPosition_SelectedText_Copy () Application.Top.Add (tv); tv.Redraw (tv.Bounds); - GraphViewTests.AssertDriverContentsWithFrameAre (@" + TestHelpers.AssertDriverContentsWithFrameAre (@" This is the first line. @@ -2069,7 +2069,7 @@ This is tv.CursorPosition = new Point (6, 2); Assert.Equal (new Point (5, 2), tv.CursorPosition); tv.Redraw (tv.Bounds); - GraphViewTests.AssertDriverContentsWithFrameAre (@" + TestHelpers.AssertDriverContentsWithFrameAre (@" This is the first line. @@ -5953,7 +5953,7 @@ public void UnwrappedCursorPosition_Event () Assert.False (tv.WordWrap); Assert.Equal (Point.Empty, tv.CursorPosition); Assert.Equal (Point.Empty, cp); - GraphViewTests.AssertDriverContentsWithFrameAre (@" + TestHelpers.AssertDriverContentsWithFrameAre (@" This is the first line. This is the second line. ", output); @@ -5963,7 +5963,7 @@ This is the second line. tv.Redraw (tv.Bounds); Assert.Equal (new Point (12, 0), tv.CursorPosition); Assert.Equal (new Point (12, 0), cp); - GraphViewTests.AssertDriverContentsWithFrameAre (@" + TestHelpers.AssertDriverContentsWithFrameAre (@" This is the first line. This is the second line. ", output); @@ -5972,7 +5972,7 @@ This is the second line. tv.Redraw (tv.Bounds); Assert.Equal (new Point (4, 2), tv.CursorPosition); Assert.Equal (new Point (12, 0), cp); - GraphViewTests.AssertDriverContentsWithFrameAre (@" + TestHelpers.AssertDriverContentsWithFrameAre (@" This is the @@ -5991,7 +5991,7 @@ This is the second line. tv.Redraw (tv.Bounds); Assert.Equal (new Point (0, 3), tv.CursorPosition); Assert.Equal (new Point (12, 0), cp); - GraphViewTests.AssertDriverContentsWithFrameAre (@" + TestHelpers.AssertDriverContentsWithFrameAre (@" This is the @@ -6010,7 +6010,7 @@ This is the second line. tv.Redraw (tv.Bounds); Assert.Equal (new Point (1, 3), tv.CursorPosition); Assert.Equal (new Point (13, 0), cp); - GraphViewTests.AssertDriverContentsWithFrameAre (@" + TestHelpers.AssertDriverContentsWithFrameAre (@" This is the @@ -6029,7 +6029,7 @@ This is the second line. tv.Redraw (tv.Bounds); Assert.Equal (new Point (0, 3), tv.CursorPosition); Assert.Equal (new Point (12, 0), cp); - GraphViewTests.AssertDriverContentsWithFrameAre (@" + TestHelpers.AssertDriverContentsWithFrameAre (@" This is the @@ -6061,7 +6061,7 @@ public void DeleteTextBackwards_WordWrap_False_Return_Undo () Assert.False (tv.WordWrap); Assert.Equal (Point.Empty, tv.CursorPosition); - GraphViewTests.AssertDriverContentsWithFrameAre (@" + TestHelpers.AssertDriverContentsWithFrameAre (@" This is the first line. This is the second line. ", output); @@ -6071,7 +6071,7 @@ This is the second line. Assert.True (tv.ProcessKey (new KeyEvent (Key.Backspace, new KeyModifiers ()))); tv.Redraw (tv.Bounds); Assert.Equal (new Point (2, 0), tv.CursorPosition); - GraphViewTests.AssertDriverContentsWithFrameAre (@" + TestHelpers.AssertDriverContentsWithFrameAre (@" Ths is the first line. This is the second line. ", output); @@ -6081,14 +6081,14 @@ This is the second line. Assert.True (tv.ProcessKey (new KeyEvent (Key.Backspace, new KeyModifiers ()))); tv.Redraw (tv.Bounds); Assert.Equal (new Point (22, 0), tv.CursorPosition); - GraphViewTests.AssertDriverContentsWithFrameAre (@" + TestHelpers.AssertDriverContentsWithFrameAre (@" Ths is the first line.This is the second line. ", output); Assert.True (tv.ProcessKey (new KeyEvent (Key.Enter, new KeyModifiers ()))); tv.Redraw (tv.Bounds); Assert.Equal (new Point (0, 1), tv.CursorPosition); - GraphViewTests.AssertDriverContentsWithFrameAre (@" + TestHelpers.AssertDriverContentsWithFrameAre (@" Ths is the first line. This is the second line. ", output); @@ -6118,7 +6118,7 @@ public void DeleteTextBackwards_WordWrap_True_Return_Undo () Assert.True (tv.WordWrap); Assert.Equal (Point.Empty, tv.CursorPosition); - GraphViewTests.AssertDriverContentsWithFrameAre (@" + TestHelpers.AssertDriverContentsWithFrameAre (@" This is the first line. This is the second line. ", output); @@ -6128,7 +6128,7 @@ This is the second line. Assert.True (tv.ProcessKey (new KeyEvent (Key.Backspace, new KeyModifiers ()))); tv.Redraw (tv.Bounds); Assert.Equal (new Point (2, 0), tv.CursorPosition); - GraphViewTests.AssertDriverContentsWithFrameAre (@" + TestHelpers.AssertDriverContentsWithFrameAre (@" Ths is the first line. This is the second line. ", output); @@ -6138,14 +6138,14 @@ This is the second line. Assert.True (tv.ProcessKey (new KeyEvent (Key.Backspace, new KeyModifiers ()))); tv.Redraw (tv.Bounds); Assert.Equal (new Point (22, 0), tv.CursorPosition); - GraphViewTests.AssertDriverContentsWithFrameAre (@" + TestHelpers.AssertDriverContentsWithFrameAre (@" Ths is the first line.This is the second line. ", output); Assert.True (tv.ProcessKey (new KeyEvent (Key.Enter, new KeyModifiers ()))); tv.Redraw (tv.Bounds); Assert.Equal (new Point (0, 1), tv.CursorPosition); - GraphViewTests.AssertDriverContentsWithFrameAre (@" + TestHelpers.AssertDriverContentsWithFrameAre (@" Ths is the first line. This is the second line. ", output); @@ -6174,7 +6174,7 @@ public void DeleteTextForwards_WordWrap_False_Return_Undo () Assert.False (tv.WordWrap); Assert.Equal (Point.Empty, tv.CursorPosition); - GraphViewTests.AssertDriverContentsWithFrameAre (@" + TestHelpers.AssertDriverContentsWithFrameAre (@" This is the first line. This is the second line. ", output); @@ -6184,7 +6184,7 @@ This is the second line. Assert.True (tv.ProcessKey (new KeyEvent (Key.DeleteChar, new KeyModifiers ()))); tv.Redraw (tv.Bounds); Assert.Equal (new Point (2, 0), tv.CursorPosition); - GraphViewTests.AssertDriverContentsWithFrameAre (@" + TestHelpers.AssertDriverContentsWithFrameAre (@" Ths is the first line. This is the second line. ", output); @@ -6194,14 +6194,14 @@ This is the second line. Assert.True (tv.ProcessKey (new KeyEvent (Key.DeleteChar, new KeyModifiers ()))); tv.Redraw (tv.Bounds); Assert.Equal (new Point (22, 0), tv.CursorPosition); - GraphViewTests.AssertDriverContentsWithFrameAre (@" + TestHelpers.AssertDriverContentsWithFrameAre (@" Ths is the first line.This is the second line. ", output); Assert.True (tv.ProcessKey (new KeyEvent (Key.Enter, new KeyModifiers ()))); tv.Redraw (tv.Bounds); Assert.Equal (new Point (0, 1), tv.CursorPosition); - GraphViewTests.AssertDriverContentsWithFrameAre (@" + TestHelpers.AssertDriverContentsWithFrameAre (@" Ths is the first line. This is the second line. ", output); @@ -6231,7 +6231,7 @@ public void DeleteTextForwards_WordWrap_True_Return_Undo () Assert.True (tv.WordWrap); Assert.Equal (Point.Empty, tv.CursorPosition); - GraphViewTests.AssertDriverContentsWithFrameAre (@" + TestHelpers.AssertDriverContentsWithFrameAre (@" This is the first line. This is the second line. ", output); @@ -6241,7 +6241,7 @@ This is the second line. Assert.True (tv.ProcessKey (new KeyEvent (Key.DeleteChar, new KeyModifiers ()))); tv.Redraw (tv.Bounds); Assert.Equal (new Point (2, 0), tv.CursorPosition); - GraphViewTests.AssertDriverContentsWithFrameAre (@" + TestHelpers.AssertDriverContentsWithFrameAre (@" Ths is the first line. This is the second line. ", output); @@ -6251,14 +6251,14 @@ This is the second line. Assert.True (tv.ProcessKey (new KeyEvent (Key.DeleteChar, new KeyModifiers ()))); tv.Redraw (tv.Bounds); Assert.Equal (new Point (22, 0), tv.CursorPosition); - GraphViewTests.AssertDriverContentsWithFrameAre (@" + TestHelpers.AssertDriverContentsWithFrameAre (@" Ths is the first line.This is the second line. ", output); Assert.True (tv.ProcessKey (new KeyEvent (Key.Enter, new KeyModifiers ()))); tv.Redraw (tv.Bounds); Assert.Equal (new Point (0, 1), tv.CursorPosition); - GraphViewTests.AssertDriverContentsWithFrameAre (@" + TestHelpers.AssertDriverContentsWithFrameAre (@" Ths is the first line. This is the second line. ", output); @@ -6295,7 +6295,7 @@ public void TextView_InsertText_Newline_LF () ((FakeDriver)Application.Driver).SetBufferSize (15, 15); Application.Refresh (); //this passes - var pos = GraphViewTests.AssertDriverContentsWithFrameAre ( + var pos = TestHelpers.AssertDriverContentsWithFrameAre ( @" ┌─────────────┐ │ │ @@ -6321,7 +6321,7 @@ public void TextView_InsertText_Newline_LF () tv.InsertText ("\naaa\nbbb"); Application.Refresh (); - GraphViewTests.AssertDriverContentsWithFrameAre ( + TestHelpers.AssertDriverContentsWithFrameAre ( @" ┌─────────────┐ │ │ @@ -6365,7 +6365,7 @@ public void TextView_InsertText_Newline_CRLF () Application.Refresh (); //this passes - var pos = GraphViewTests.AssertDriverContentsWithFrameAre ( + var pos = TestHelpers.AssertDriverContentsWithFrameAre ( @" ┌─────────────┐ │ │ @@ -6391,7 +6391,7 @@ public void TextView_InsertText_Newline_CRLF () tv.InsertText ("\r\naaa\r\nbbb"); Application.Refresh (); - GraphViewTests.AssertDriverContentsWithFrameAre ( + TestHelpers.AssertDriverContentsWithFrameAre ( @" ┌─────────────┐ │ │ diff --git a/UnitTests/TreeViewTests.cs b/UnitTests/TreeViewTests.cs index 1cdc3ed547..7e47e58d51 100644 --- a/UnitTests/TreeViewTests.cs +++ b/UnitTests/TreeViewTests.cs @@ -748,7 +748,7 @@ public void TestGetObjectOnRow () tv.ColorScheme = new ColorScheme (); tv.Redraw (tv.Bounds); - GraphViewTests.AssertDriverContentsAre ( + TestHelpers.AssertDriverContentsAre ( @"├-normal │ ├─pink │ └─normal @@ -766,7 +766,7 @@ public void TestGetObjectOnRow () tv.Redraw (tv.Bounds); - GraphViewTests.AssertDriverContentsAre ( + TestHelpers.AssertDriverContentsAre ( @"├+normal └─pink ", output); @@ -797,7 +797,7 @@ public void TestGetObjectRow () tv.ColorScheme = new ColorScheme (); tv.Redraw (tv.Bounds); - GraphViewTests.AssertDriverContentsAre ( + TestHelpers.AssertDriverContentsAre ( @"├-normal │ ├─pink │ └─normal @@ -814,7 +814,7 @@ public void TestGetObjectRow () tv.Redraw (tv.Bounds); - GraphViewTests.AssertDriverContentsAre ( + TestHelpers.AssertDriverContentsAre ( @"├+normal └─pink ", output); @@ -830,7 +830,7 @@ public void TestGetObjectRow () tv.Redraw (tv.Bounds); - GraphViewTests.AssertDriverContentsAre ( + TestHelpers.AssertDriverContentsAre ( @"└─pink ", output); Assert.Equal (-1, tv.GetObjectRow (n1)); @@ -861,14 +861,14 @@ public void TestTreeViewColor() tv.Redraw(tv.Bounds); // Normal drawing of the tree view - GraphViewTests.AssertDriverContentsAre( + TestHelpers.AssertDriverContentsAre( @"├-normal │ ├─pink │ └─normal └─pink ",output); // Should all be the same color - GraphViewTests.AssertDriverColorsAre( + TestHelpers.AssertDriverColorsAre( @"00000000 00000000 0000000000 @@ -892,7 +892,7 @@ public void TestTreeViewColor() tv.Redraw(tv.Bounds); // Same text - GraphViewTests.AssertDriverContentsAre( + TestHelpers.AssertDriverContentsAre( @"├-normal │ ├─pink │ └─normal @@ -900,7 +900,7 @@ public void TestTreeViewColor() ",output); // but now the item (only not lines) appear // in pink when they are the word "pink" - GraphViewTests.AssertDriverColorsAre( + TestHelpers.AssertDriverColorsAre( @"00000000 00001111 0000000000 diff --git a/UnitTests/ViewTests.cs b/UnitTests/ViewTests.cs index eeb606d65b..e2a20e80b8 100644 --- a/UnitTests/ViewTests.cs +++ b/UnitTests/ViewTests.cs @@ -1504,7 +1504,7 @@ Hello X Y "; - var pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + var pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new Rect (0, 0, 11, 3), pos); label.AutoSize = false; @@ -1519,7 +1519,7 @@ Hello X Y "; - pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new Rect (0, 0, 11, 3), pos); } @@ -1550,7 +1550,7 @@ H X Y "; - var pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + var pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new Rect (0, 0, 3, 11), pos); label.AutoSize = false; @@ -1573,7 +1573,7 @@ H X Y "; - pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new Rect (0, 0, 3, 11), pos); } @@ -2119,7 +2119,7 @@ public void DrawFrame_With_Positive_Positions () └──────┘ "; - var pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + var pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new Rect (0, 0, 8, 4), pos); } @@ -2141,7 +2141,7 @@ public void DrawFrame_With_Minimum_Size () └┘ "; - var pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + var pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new Rect (0, 0, 2, 2), pos); } @@ -2165,7 +2165,7 @@ public void DrawFrame_With_Negative_Positions () ──────┘ "; - var pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + var pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new Rect (0, 0, 7, 4), pos); view.Frame = new Rect (-1, -1, 8, 4); @@ -2177,7 +2177,7 @@ public void DrawFrame_With_Negative_Positions () ──────┘ "; - pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new Rect (6, 0, 7, 3), pos); view.Frame = new Rect (0, 0, 8, 4); @@ -2190,7 +2190,7 @@ public void DrawFrame_With_Negative_Positions () └────── "; - pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new Rect (0, 0, 7, 4), pos); view.Frame = new Rect (0, 0, 8, 4); @@ -2232,7 +2232,7 @@ public void DrawTextFormatter_Respects_The_Clip_Bounds () └──────────────────┘ "; - var pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + var pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new Rect (1, 1, 21, 14), pos); Assert.True (scrollView.ProcessKey (new KeyEvent (Key.CursorRight, new KeyModifiers ()))); @@ -2255,7 +2255,7 @@ public void DrawTextFormatter_Respects_The_Clip_Bounds () └──────────────────┘ "; - pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new Rect (1, 1, 21, 14), pos); Assert.True (scrollView.ProcessKey (new KeyEvent (Key.CursorRight, new KeyModifiers ()))); @@ -2278,7 +2278,7 @@ public void DrawTextFormatter_Respects_The_Clip_Bounds () └──────────────────┘ "; - pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new Rect (1, 1, 21, 14), pos); Assert.True (scrollView.ProcessKey (new KeyEvent (Key.CursorRight, new KeyModifiers ()))); @@ -2301,7 +2301,7 @@ public void DrawTextFormatter_Respects_The_Clip_Bounds () └──────────────────┘ "; - pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new Rect (1, 1, 21, 14), pos); Assert.True (scrollView.ProcessKey (new KeyEvent (Key.CursorRight, new KeyModifiers ()))); @@ -2324,7 +2324,7 @@ public void DrawTextFormatter_Respects_The_Clip_Bounds () └──────────────────┘ "; - pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new Rect (1, 1, 21, 14), pos); Assert.True (scrollView.ProcessKey (new KeyEvent (Key.CursorRight, new KeyModifiers ()))); @@ -2347,7 +2347,7 @@ public void DrawTextFormatter_Respects_The_Clip_Bounds () └──────────────────┘ "; - pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new Rect (1, 1, 21, 14), pos); Assert.True (scrollView.ProcessKey (new KeyEvent (Key.CursorRight, new KeyModifiers ()))); @@ -2370,7 +2370,7 @@ public void DrawTextFormatter_Respects_The_Clip_Bounds () └──────────────────┘ "; - pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new Rect (1, 1, 21, 14), pos); Assert.True (scrollView.ProcessKey (new KeyEvent (Key.CursorRight, new KeyModifiers ()))); @@ -2393,7 +2393,7 @@ public void DrawTextFormatter_Respects_The_Clip_Bounds () └──────────────────┘ "; - pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new Rect (1, 1, 21, 14), pos); Assert.True (scrollView.ProcessKey (new KeyEvent (Key.CtrlMask | Key.Home, new KeyModifiers ()))); @@ -2417,7 +2417,7 @@ public void DrawTextFormatter_Respects_The_Clip_Bounds () └──────────────────┘ "; - pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new Rect (1, 1, 21, 14), pos); Assert.True (scrollView.ProcessKey (new KeyEvent (Key.CursorDown, new KeyModifiers ()))); @@ -2440,7 +2440,7 @@ public void DrawTextFormatter_Respects_The_Clip_Bounds () └──────────────────┘ "; - pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new Rect (1, 1, 21, 14), pos); Assert.True (scrollView.ProcessKey (new KeyEvent (Key.CursorDown, new KeyModifiers ()))); @@ -2463,7 +2463,7 @@ public void DrawTextFormatter_Respects_The_Clip_Bounds () └──────────────────┘ "; - pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new Rect (1, 1, 21, 14), pos); } @@ -2503,7 +2503,7 @@ public void Clear_Can_Use_Driver_AddRune_Or_AddStr_Methods () └──────────────────┘ "; - var pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + var pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new Rect (0, 0, 20, 10), pos); view.Clear (); @@ -2511,7 +2511,7 @@ public void Clear_Can_Use_Driver_AddRune_Or_AddStr_Methods () expected = @" "; - pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (Rect.Empty, pos); } @@ -2551,7 +2551,7 @@ public void Clear_Bounds_Can_Use_Driver_AddRune_Or_AddStr_Methods () └──────────────────┘ "; - var pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + var pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new Rect (0, 0, 20, 10), pos); view.Clear (view.Bounds); @@ -2559,7 +2559,7 @@ public void Clear_Bounds_Can_Use_Driver_AddRune_Or_AddStr_Methods () expected = @" "; - pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (Rect.Empty, pos); } @@ -2626,7 +2626,7 @@ public void Width_Height_SetMinWidthHeight_Narrow_Wide_Runes () └──────────────────────────────┘ "; - var pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + var pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new Rect (0, 0, 32, 32), pos); verticalView.Text = $"最初の行{Environment.NewLine}二行目"; @@ -2667,7 +2667,7 @@ public void Width_Height_SetMinWidthHeight_Narrow_Wide_Runes () └──────────────────────────────┘ "; - pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new Rect (0, 0, 32, 32), pos); } @@ -2714,7 +2714,7 @@ public void TextDirection_Toggle () └────────────────────┘ "; - var pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + var pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new Rect (0, 0, 22, 22), pos); view.Text = "Hello World"; @@ -2751,7 +2751,7 @@ public void TextDirection_Toggle () └────────────────────┘ "; - pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new Rect (0, 0, 22, 22), pos); view.AutoSize = true; @@ -2788,7 +2788,7 @@ public void TextDirection_Toggle () └────────────────────┘ "; - pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new Rect (0, 0, 22, 22), pos); view.TextDirection = TextDirection.TopBottom_LeftRight; @@ -2824,7 +2824,7 @@ public void TextDirection_Toggle () └────────────────────┘ "; - pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new Rect (0, 0, 22, 22), pos); view.AutoSize = false; @@ -2861,7 +2861,7 @@ public void TextDirection_Toggle () └────────────────────┘ "; - pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new Rect (0, 0, 22, 22), pos); view.PreserveTrailingSpaces = true; @@ -2897,7 +2897,7 @@ public void TextDirection_Toggle () └────────────────────┘ "; - pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new Rect (0, 0, 22, 22), pos); view.PreserveTrailingSpaces = false; @@ -2937,7 +2937,7 @@ public void TextDirection_Toggle () └────────────────────┘ "; - pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new Rect (0, 0, 22, 22), pos); view.AutoSize = true; @@ -2973,7 +2973,7 @@ public void TextDirection_Toggle () └────────────────────┘ "; - pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new Rect (0, 0, 22, 22), pos); } @@ -3042,7 +3042,7 @@ public void Width_Height_AutoSize_True_Stay_True_If_TextFormatter_Size_Fit () └────────────────────┘ "; - var pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + var pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new Rect (0, 0, 22, 22), pos); verticalView.Text = $"最初_の行二行目"; @@ -3080,7 +3080,7 @@ public void Width_Height_AutoSize_True_Stay_True_If_TextFormatter_Size_Fit () └────────────────────┘ "; - pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new Rect (0, 0, 22, 22), pos); } @@ -3113,7 +3113,7 @@ public void AutoSize_Stays_True_Center_HotKeySpecifier () └────────────────────────────┘ "; - GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + TestHelpers.AssertDriverContentsWithFrameAre (expected, output); Assert.True (btn.AutoSize); btn.Text = "Say He_llo 你 changed"; @@ -3127,7 +3127,7 @@ public void AutoSize_Stays_True_Center_HotKeySpecifier () └────────────────────────────┘ "; - GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + TestHelpers.AssertDriverContentsWithFrameAre (expected, output); } [Fact] @@ -3500,7 +3500,7 @@ public void AutoSize_Layout_Absolute_With_Add_Horizontal_Narrow () Assert.False (view.AutoSize); Assert.Equal (new Rect (0, 0, 10, 1), view.Frame); Assert.Equal ("Test", view.TextFormatter.Text); - GraphViewTests.AssertDriverContentsWithFrameAre (@" + TestHelpers.AssertDriverContentsWithFrameAre (@" Test ", output); @@ -3509,7 +3509,7 @@ public void AutoSize_Layout_Absolute_With_Add_Horizontal_Narrow () Assert.Equal (new Rect (0, 0, 10, 1), view.Frame); Assert.Equal ("First line\nSecond line", view.TextFormatter.Text); Application.Refresh (); - GraphViewTests.AssertDriverContentsWithFrameAre (@" + TestHelpers.AssertDriverContentsWithFrameAre (@" First line ", output); @@ -3518,7 +3518,7 @@ First line Assert.Equal (new Rect (0, 0, 11, 2), view.Frame); Assert.Equal ("First line\nSecond line", view.TextFormatter.Text); Application.Refresh (); - GraphViewTests.AssertDriverContentsWithFrameAre (@" + TestHelpers.AssertDriverContentsWithFrameAre (@" First line Second line ", output); @@ -3528,7 +3528,7 @@ Second line Assert.Equal (new Rect (0, 0, 10, 1), view.Frame); Assert.Equal ("First line\nSecond line", view.TextFormatter.Text); Application.Refresh (); - GraphViewTests.AssertDriverContentsWithFrameAre (@" + TestHelpers.AssertDriverContentsWithFrameAre (@" First line ", output); } @@ -3576,7 +3576,7 @@ public void AutoSize_Layout_Absolute_With_Add_Vertical_Narrow () Assert.False (view.AutoSize); Assert.Equal (new Rect (0, 0, 1, 10), view.Frame); Assert.Equal ("Test", view.TextFormatter.Text); - GraphViewTests.AssertDriverContentsWithFrameAre (@" + TestHelpers.AssertDriverContentsWithFrameAre (@" T e s @@ -3588,7 +3588,7 @@ public void AutoSize_Layout_Absolute_With_Add_Vertical_Narrow () Assert.Equal (new Rect (0, 0, 1, 10), view.Frame); Assert.Equal ("First line\nSecond line", view.TextFormatter.Text); Application.Refresh (); - GraphViewTests.AssertDriverContentsWithFrameAre (@" + TestHelpers.AssertDriverContentsWithFrameAre (@" F i r @@ -3606,7 +3606,7 @@ public void AutoSize_Layout_Absolute_With_Add_Vertical_Narrow () Assert.Equal (new Rect (0, 0, 2, 11), view.Frame); Assert.Equal ("First line\nSecond line", view.TextFormatter.Text); Application.Refresh (); - GraphViewTests.AssertDriverContentsWithFrameAre (@" + TestHelpers.AssertDriverContentsWithFrameAre (@" FS ie rc @@ -3625,7 +3625,7 @@ public void AutoSize_Layout_Absolute_With_Add_Vertical_Narrow () Assert.Equal (new Rect (0, 0, 1, 10), view.Frame); Assert.Equal ("First line\nSecond line", view.TextFormatter.Text); Application.Refresh (); - GraphViewTests.AssertDriverContentsWithFrameAre (@" + TestHelpers.AssertDriverContentsWithFrameAre (@" F i r @@ -3680,7 +3680,7 @@ public void AutoSize_Layout_Absolute_With_Add_Horizontal_Wide () Assert.False (view.AutoSize); Assert.Equal (new Rect (0, 0, 10, 1), view.Frame); Assert.Equal ("Test 你", view.TextFormatter.Text); - GraphViewTests.AssertDriverContentsWithFrameAre (@" + TestHelpers.AssertDriverContentsWithFrameAre (@" Test 你 ", output); @@ -3689,7 +3689,7 @@ public void AutoSize_Layout_Absolute_With_Add_Horizontal_Wide () Assert.Equal (new Rect (0, 0, 10, 1), view.Frame); Assert.Equal ("First line 你\nSecond line 你", view.TextFormatter.Text); Application.Refresh (); - GraphViewTests.AssertDriverContentsWithFrameAre (@" + TestHelpers.AssertDriverContentsWithFrameAre (@" First line ", output); @@ -3698,7 +3698,7 @@ First line Assert.Equal (new Rect (0, 0, 14, 2), view.Frame); Assert.Equal ("First line 你\nSecond line 你", view.TextFormatter.Text); Application.Refresh (); - GraphViewTests.AssertDriverContentsWithFrameAre (@" + TestHelpers.AssertDriverContentsWithFrameAre (@" First line 你 Second line 你 ", output); @@ -3708,7 +3708,7 @@ Second line 你 Assert.Equal (new Rect (0, 0, 10, 1), view.Frame); Assert.Equal ("First line 你\nSecond line 你", view.TextFormatter.Text); Application.Refresh (); - GraphViewTests.AssertDriverContentsWithFrameAre (@" + TestHelpers.AssertDriverContentsWithFrameAre (@" First line ", output); } @@ -3758,7 +3758,7 @@ public void AutoSize_Layout_Absolute_With_Add_Vertical_Wide () // SetMinWidthHeight ensuring the minimum width for the wide char Assert.Equal (new Rect (0, 0, 2, 10), view.Frame); Assert.Equal ("Test 你", view.TextFormatter.Text); - GraphViewTests.AssertDriverContentsWithFrameAre (@" + TestHelpers.AssertDriverContentsWithFrameAre (@" T e s @@ -3772,7 +3772,7 @@ public void AutoSize_Layout_Absolute_With_Add_Vertical_Wide () Assert.Equal (new Rect (0, 0, 2, 10), view.Frame); Assert.Equal ("First line 你\nSecond line 你", view.TextFormatter.Text); Application.Refresh (); - GraphViewTests.AssertDriverContentsWithFrameAre (@" + TestHelpers.AssertDriverContentsWithFrameAre (@" F i r @@ -3790,7 +3790,7 @@ public void AutoSize_Layout_Absolute_With_Add_Vertical_Wide () Assert.Equal (new Rect (0, 0, 4, 13), view.Frame); Assert.Equal ("First line 你\nSecond line 你", view.TextFormatter.Text); Application.Refresh (); - GraphViewTests.AssertDriverContentsWithFrameAre (@" + TestHelpers.AssertDriverContentsWithFrameAre (@" F S i e r c @@ -3811,7 +3811,7 @@ e n Assert.Equal (new Rect (0, 0, 2, 10), view.Frame); Assert.Equal ("First line 你\nSecond line 你", view.TextFormatter.Text); Application.Refresh (); - GraphViewTests.AssertDriverContentsWithFrameAre (@" + TestHelpers.AssertDriverContentsWithFrameAre (@" F i r @@ -3837,7 +3837,7 @@ public void Visible_Clear_The_View_Output () Assert.True (label.Visible); ((FakeDriver)Application.Driver).SetBufferSize (30, 5); - GraphViewTests.AssertDriverContentsWithFrameAre (@" + TestHelpers.AssertDriverContentsWithFrameAre (@" ┌────────────────────────────┐ │Testing visibility. │ │ │ @@ -3846,7 +3846,7 @@ public void Visible_Clear_The_View_Output () ", output); label.Visible = false; - GraphViewTests.AssertDriverContentsWithFrameAre (@" + TestHelpers.AssertDriverContentsWithFrameAre (@" ┌────────────────────────────┐ │ │ │ │ @@ -3869,7 +3869,7 @@ public void ClearOnVisibleFalse_Gets_Sets () Application.Begin (Application.Top); Assert.True (sbv.Visible); - GraphViewTests.AssertDriverContentsWithFrameAre (@" + TestHelpers.AssertDriverContentsWithFrameAre (@" This is a tes▲ This is a tes┬ This is a tes┴ @@ -3881,7 +3881,7 @@ This is a tes▼ sbv.Visible = false; Assert.False (sbv.Visible); Application.Top.Redraw (Application.Top.Bounds); - GraphViewTests.AssertDriverContentsWithFrameAre (@" + TestHelpers.AssertDriverContentsWithFrameAre (@" This is a test This is a test This is a test @@ -3893,7 +3893,7 @@ This is a test sbv.Visible = true; Assert.True (sbv.Visible); Application.Top.Redraw (Application.Top.Bounds); - GraphViewTests.AssertDriverContentsWithFrameAre (@" + TestHelpers.AssertDriverContentsWithFrameAre (@" This is a tes▲ This is a tes┬ This is a tes┴ @@ -3905,7 +3905,7 @@ This is a tes▼ sbv.ClearOnVisibleFalse = true; sbv.Visible = false; Assert.False (sbv.Visible); - GraphViewTests.AssertDriverContentsWithFrameAre (@" + TestHelpers.AssertDriverContentsWithFrameAre (@" This is a tes This is a tes This is a tes diff --git a/UnitTests/WizardTests.cs b/UnitTests/WizardTests.cs index 8d629e91c4..aad4ae94bb 100644 --- a/UnitTests/WizardTests.cs +++ b/UnitTests/WizardTests.cs @@ -127,7 +127,7 @@ public void ZeroStepWizard_Shows () var wizard = new Wizard (title) { Width = width, Height = height }; Application.End (Application.Begin (wizard)); - GraphViewTests.AssertDriverContentsWithFrameAre ($"{topRow}\n{row2}\n{row3}\n{separatorRow}\n{buttonRow}\n{bottomRow}", output); + TestHelpers.AssertDriverContentsWithFrameAre ($"{topRow}\n{row2}\n{row3}\n{separatorRow}\n{buttonRow}\n{bottomRow}", output); } [Fact, AutoInitShutdown] @@ -164,7 +164,7 @@ public void OneStepWizard_Shows () var runstate = Application.Begin (wizard); Application.RunMainLoopIteration (ref runstate, true, ref firstIteration); - GraphViewTests.AssertDriverContentsWithFrameAre ($"{topRow}\n{row2}\n{row3}\n{row4}\n{separatorRow}\n{buttonRow}\n{bottomRow}", output); + TestHelpers.AssertDriverContentsWithFrameAre ($"{topRow}\n{row2}\n{row3}\n{row4}\n{separatorRow}\n{buttonRow}\n{bottomRow}", output); Application.End (runstate); } @@ -231,7 +231,7 @@ public void Setting_Title_Works () wizard.AddStep (new Wizard.WizardStep ("ABCD")); Application.End (Application.Begin (wizard)); - GraphViewTests.AssertDriverContentsWithFrameAre ($"{topRow}\n{separatorRow}\n{buttonRow}\n{bottomRow}", output); + TestHelpers.AssertDriverContentsWithFrameAre ($"{topRow}\n{separatorRow}\n{buttonRow}\n{bottomRow}", output); } [Fact, AutoInitShutdown]