Browse Source

Fixed Frameviewtest

Tig 1 year ago
parent
commit
7c34751400

+ 1 - 1
UnitTests/Views/DateFieldTests.cs

@@ -30,7 +30,7 @@ public class DateFieldTests
 
     [Fact]
     [TestDate]
-    [AutoInitShutdown]
+    [SetupFakeDriver]
     public void Copy_Paste ()
     {
         var df1 = new DateField (DateTime.Parse ("12/12/1971"));

+ 3 - 1
UnitTests/Views/DatePickerTests.cs

@@ -50,7 +50,7 @@ public class DatePickerTests
         var datePicker = new DatePicker (date);
 
         var top = new Toplevel ();
-       top.Add (datePicker);
+        top.Add (datePicker);
         Application.Begin (top);
 
         // Set focus to next month button
@@ -65,6 +65,7 @@ public class DatePickerTests
         // Date should not change as next month button is disabled
         Assert.False (datePicker.NewKeyDownEvent (Key.Enter));
         Assert.Equal (12, datePicker.Date.Month);
+        top.Dispose ();
     }
 
     [Fact]
@@ -90,5 +91,6 @@ public class DatePickerTests
         // Date should not change as previous month button is disabled
         Assert.False (datePicker.NewKeyDownEvent (Key.Enter));
         Assert.Equal (1, datePicker.Date.Month);
+        top.Dispose ();
     }
 }

+ 15 - 17
UnitTests/Views/FrameViewTests.cs

@@ -2,11 +2,8 @@
 
 namespace Terminal.Gui.ViewsTests;
 
-public class FrameViewTests
+public class FrameViewTests (ITestOutputHelper output)
 {
-    private readonly ITestOutputHelper _output;
-    public FrameViewTests (ITestOutputHelper output) { _output = output; }
-
     [Fact]
     public void Constructors_Defaults ()
     {
@@ -15,12 +12,12 @@ public class FrameViewTests
         Assert.Equal (string.Empty, fv.Text);
         Assert.Equal (LineStyle.Single, fv.BorderStyle);
 
-        fv = new FrameView { Title = "Test" };
+        fv = new() { Title = "Test" };
         Assert.Equal ("Test", fv.Title);
         Assert.Equal (string.Empty, fv.Text);
         Assert.Equal (LineStyle.Single, fv.BorderStyle);
 
-        fv = new FrameView
+        fv = new()
         {
             X = 1,
             Y = 2,
@@ -33,7 +30,7 @@ public class FrameViewTests
         fv.BeginInit ();
         fv.EndInit ();
         Assert.Equal (LineStyle.Single, fv.BorderStyle);
-        Assert.Equal (new Rectangle (1, 2, 10, 20), fv.Frame);
+        Assert.Equal (new (1, 2, 10, 20), fv.Frame);
     }
 
     [Fact]
@@ -47,12 +44,12 @@ public class FrameViewTests
         var top = new Toplevel ();
         top.Add (fv);
         Application.Begin (top);
-        Assert.Equal (new Rectangle (0, 0, 0, 0), fv.Frame);
-        TestHelpers.AssertDriverContentsWithFrameAre (@"", _output);
+        Assert.Equal (new (0, 0, 0, 0), fv.Frame);
+        TestHelpers.AssertDriverContentsWithFrameAre (@"", output);
 
         fv.Height = 5;
         fv.Width = 5;
-        Assert.Equal (new Rectangle (0, 0, 5, 5), fv.Frame);
+        Assert.Equal (new (0, 0, 5, 5), fv.Frame);
         Application.Refresh ();
 
         TestHelpers.AssertDriverContentsWithFrameAre (
@@ -62,12 +59,12 @@ public class FrameViewTests
 │   │
 │   │
 └───┘",
-                                                      _output
+                                                      output
                                                      );
 
         fv.X = 1;
         fv.Y = 2;
-        Assert.Equal (new Rectangle (1, 2, 5, 5), fv.Frame);
+        Assert.Equal (new (1, 2, 5, 5), fv.Frame);
         Application.Refresh ();
 
         TestHelpers.AssertDriverContentsWithFrameAre (
@@ -77,12 +74,12 @@ public class FrameViewTests
  │   │
  │   │
  └───┘",
-                                                      _output
+                                                      output
                                                      );
 
         fv.X = -1;
         fv.Y = -2;
-        Assert.Equal (new Rectangle (-1, -2, 5, 5), fv.Frame);
+        Assert.Equal (new (-1, -2, 5, 5), fv.Frame);
         Application.Refresh ();
 
         TestHelpers.AssertDriverContentsWithFrameAre (
@@ -90,19 +87,20 @@ public class FrameViewTests
 ───┘",
-                                                      _output
+                                                      output
                                                      );
 
         fv.X = 7;
         fv.Y = 8;
-        Assert.Equal (new Rectangle (7, 8, 5, 5), fv.Frame);
+        Assert.Equal (new (7, 8, 5, 5), fv.Frame);
         Application.Refresh ();
 
         TestHelpers.AssertDriverContentsWithFrameAre (
                                                       @"
        ┌──
        │  ",
-                                                      _output
+                                                      output
                                                      );
+        top.Dispose ();
     }
 }