소스 검색

Fixed ComboBoxTests

Tig 1 년 전
부모
커밋
43e34c3e70
2개의 변경된 파일20개의 추가작업 그리고 15개의 파일을 삭제
  1. 4 4
      UnitTests/Views/ColorPickerTests.cs
  2. 16 11
      UnitTests/Views/ComboBoxTests.cs

+ 4 - 4
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;

+ 16 - 11
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 ();