From 43e34c3e702a16d9c07706cc04077ad957b39bf3 Mon Sep 17 00:00:00 2001 From: Tig Date: Thu, 30 May 2024 07:23:37 -0600 Subject: [PATCH] Fixed ComboBoxTests --- UnitTests/Views/ColorPickerTests.cs | 8 ++++---- UnitTests/Views/ComboBoxTests.cs | 27 ++++++++++++++++----------- 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/UnitTests/Views/ColorPickerTests.cs b/UnitTests/Views/ColorPickerTests.cs index ec171bdea..bc9410a62 100644 --- a/UnitTests/Views/ColorPickerTests.cs +++ b/UnitTests/Views/ColorPickerTests.cs @@ -13,7 +13,7 @@ public class ColorPickerTests colorPicker.BeginInit (); colorPicker.EndInit (); colorPicker.LayoutSubviews (); - Assert.Equal (new Rectangle (0, 0, 32, 4), colorPicker.Frame); + Assert.Equal (new (0, 0, 32, 4), colorPicker.Frame); } [Fact] @@ -51,9 +51,9 @@ public class ColorPickerTests top.Add (colorPicker); Application.Begin (top); - Assert.False (colorPicker.NewMouseEvent (new MouseEvent ())); + Assert.False (colorPicker.NewMouseEvent (new ())); - Assert.True (colorPicker.NewMouseEvent (new MouseEvent { Position = new (4, 1), Flags = MouseFlags.Button1Clicked })); + Assert.True (colorPicker.NewMouseEvent (new() { Position = new (4, 1), Flags = MouseFlags.Button1Clicked })); Assert.Equal (ColorName.Blue, colorPicker.SelectedColor); top.Dispose (); } @@ -70,7 +70,7 @@ public class ColorPickerTests Assert.Equal (0, colorPicker.Cursor.X); Assert.Equal (0, colorPicker.Cursor.Y); - colorPicker.Cursor = new Point (7, 1); + colorPicker.Cursor = new (7, 1); Assert.Equal (ColorName.White, colorPicker.SelectedColor); colorPicker.Cursor = Point.Empty; diff --git a/UnitTests/Views/ComboBoxTests.cs b/UnitTests/Views/ComboBoxTests.cs index d47742d7e..ec06d012b 100644 --- a/UnitTests/Views/ComboBoxTests.cs +++ b/UnitTests/Views/ComboBoxTests.cs @@ -2,13 +2,9 @@ namespace Terminal.Gui.ViewsTests; -public class ComboBoxTests +public class ComboBoxTests (ITestOutputHelper output) { - private readonly ITestOutputHelper _output; - public ComboBoxTests (ITestOutputHelper output) { _output = output; } - [Fact] - [AutoInitShutdown] public void Constructor_With_Source_Initialize_With_The_Passed_SelectedItem () { var cb = new ComboBox @@ -73,7 +69,6 @@ public class ComboBoxTests } [Fact] - [AutoInitShutdown] public void EnsureKeyEventsDoNotCauseExceptions () { var comboBox = new ComboBox { Text = "0" }; @@ -120,6 +115,7 @@ public class ComboBoxTests Assert.False (cb.IsShow); Assert.Equal (-1, cb.SelectedItem); Assert.Equal ("", cb.Text); + top.Dispose (); } [Fact] @@ -174,6 +170,7 @@ public class ComboBoxTests Assert.False (cb.IsShow); Assert.Equal (1, cb.SelectedItem); Assert.Equal ("", cb.Text); + top.Dispose (); } [Fact] @@ -209,6 +206,7 @@ public class ComboBoxTests Assert.False (cb.IsShow); Assert.Equal (1, cb.SelectedItem); Assert.Equal ("Two", cb.Text); + top.Dispose (); } [Fact] @@ -268,6 +266,7 @@ public class ComboBoxTests Assert.False (cb.IsShow); Assert.Equal (1, cb.SelectedItem); Assert.Equal ("Two", cb.Text); + top.Dispose (); } [Fact] @@ -369,6 +368,7 @@ public class ComboBoxTests Assert.False (cb.IsShow); Assert.Equal (0, cb.SelectedItem); Assert.Equal ("One", cb.Text); + top.Dispose (); } [Fact] @@ -487,6 +487,7 @@ public class ComboBoxTests Assert.False (cb.IsShow); Assert.Equal (-1, cb.SelectedItem); Assert.Equal ("", cb.Text); + top.Dispose (); } [Fact] @@ -523,7 +524,7 @@ public class ComboBoxTests One Two Three ", - _output + output ); Attribute [] attributes = @@ -644,6 +645,7 @@ Three ", Assert.False (cb.IsShow); Assert.Equal (2, cb.SelectedItem); Assert.Equal ("Three", cb.Text); + top.Dispose (); } [Fact] @@ -706,6 +708,7 @@ Three ", Assert.False (cb.IsShow); Assert.Equal (-1, cb.SelectedItem); Assert.Equal ("", cb.Text); + top.Dispose (); } [Fact] @@ -763,6 +766,7 @@ Three ", Assert.False (cb.IsShow); Assert.Equal (1, cb.SelectedItem); Assert.Equal ("Two", cb.Text); + top.Dispose (); } [Fact] @@ -798,6 +802,7 @@ Three ", Assert.False (cb.IsShow); Assert.Equal (-1, cb.SelectedItem); Assert.Equal ("", cb.Text); + top.Dispose (); } [Fact] @@ -876,7 +881,7 @@ Three ", One ▼ One ", - _output + output ); Assert.True (cb.NewKeyDownEvent (Key.PageDown)); @@ -890,7 +895,7 @@ One Two ▼ Two ", - _output + output ); Assert.True (cb.NewKeyDownEvent (Key.PageDown)); @@ -904,7 +909,7 @@ Two Three ▼ Three ", - _output + output ); Assert.True (cb.NewKeyDownEvent (Key.PageUp)); Assert.True (cb.IsShow); @@ -958,10 +963,10 @@ Three Assert.Equal (-1, cb.SelectedItem); Assert.Equal ("", cb.Text); Assert.Equal (3, cb.Source.Count); + top.Dispose (); } [Fact] - [AutoInitShutdown] public void Source_Equal_Null_Or_Count_Equal_Zero_Sets_SelectedItem_Equal_To_Minus_One () { var cb = new ComboBox ();