فهرست منبع

Fixed unit test warnings

Tig 1 سال پیش
والد
کامیت
dde1fe435c

+ 0 - 3
UnitTests/Application/ApplicationTests.cs

@@ -267,8 +267,6 @@ public class ApplicationTests
     {
     {
         Application.Init (new FakeDriver ());
         Application.Init (new FakeDriver ());
 
 
-        Toplevel topLevel = null;
-
         Assert.Throws<InvalidOperationException> (
         Assert.Throws<InvalidOperationException> (
                                                   () =>
                                                   () =>
                                                       Application.InternalInit (
                                                       Application.InternalInit (
@@ -282,7 +280,6 @@ public class ApplicationTests
         Assert.Null (Application.Driver);
         Assert.Null (Application.Driver);
 
 
         // Now try the other way
         // Now try the other way
-        topLevel = null;
         Application.InternalInit (new FakeDriver ());
         Application.InternalInit (new FakeDriver ());
 
 
         Assert.Throws<InvalidOperationException> (() => Application.Init (new FakeDriver ()));
         Assert.Throws<InvalidOperationException> (() => Application.Init (new FakeDriver ()));

+ 1 - 1
UnitTests/Dialogs/WizardTests.cs

@@ -2,7 +2,7 @@
 
 
 namespace Terminal.Gui.DialogTests;
 namespace Terminal.Gui.DialogTests;
 
 
-public class WizardTests (ITestOutputHelper output)
+public class WizardTests ()
 {
 {
     // =========== Wizard Tests
     // =========== Wizard Tests
     [Fact]
     [Fact]

+ 3 - 3
UnitTests/Drawing/ColorTests.ParsingAndFormatting.cs

@@ -84,7 +84,7 @@ public partial class ColorTests
                 )]
                 )]
     public void TryParse_string_Returns_False_For_Invalid_Inputs (string? input)
     public void TryParse_string_Returns_False_For_Invalid_Inputs (string? input)
     {
     {
-        bool tryParseStatus = Color.TryParse (input, out Color? color);
+        bool tryParseStatus = Color.TryParse (input ?? string.Empty, out Color? color);
         Assert.False (tryParseStatus);
         Assert.False (tryParseStatus);
         Assert.Null (color);
         Assert.Null (color);
     }
     }
@@ -94,9 +94,9 @@ public partial class ColorTests
                     nameof (ColorTestsTheoryDataGenerators.TryParse_string_Returns_True_For_Valid_Inputs),
                     nameof (ColorTestsTheoryDataGenerators.TryParse_string_Returns_True_For_Valid_Inputs),
                     MemberType = typeof (ColorTestsTheoryDataGenerators)
                     MemberType = typeof (ColorTestsTheoryDataGenerators)
                 )]
                 )]
-    public void TryParse_string_Returns_True_For_Valid_Inputs (string input, int expectedColorArgb)
+    public void TryParse_string_Returns_True_For_Valid_Inputs (string? input, int expectedColorArgb)
     {
     {
-        bool tryParseStatus = Color.TryParse (input, out Color? color);
+        bool tryParseStatus = Color.TryParse (input ?? string.Empty, out Color? color);
         Assert.True (tryParseStatus);
         Assert.True (tryParseStatus);
         Assert.NotNull (color);
         Assert.NotNull (color);
         Assert.IsType<Color> (color);
         Assert.IsType<Color> (color);

+ 7 - 6
UnitTests/View/DiagnosticsTests.cs

@@ -4,21 +4,22 @@ using Xunit.Abstractions;
 namespace Terminal.Gui.ViewTests;
 namespace Terminal.Gui.ViewTests;
 
 
 /// <summary>
 /// <summary>
-/// Tests <see cref="View.Diagnostics"/> static property and <see cref="ViewDiagnosticFlags"/> enum.
+///     Tests <see cref="View.Diagnostics"/> static property and <see cref="ViewDiagnosticFlags"/> enum.
 /// </summary>
 /// </summary>
 /// <param name="output"></param>
 /// <param name="output"></param>
-[Trait("Category","Output")]
-public class DiagnosticTests (ITestOutputHelper output)
+[Trait ("Category", "Output")]
+public class DiagnosticTests ()
 {
 {
     /// <summary>
     /// <summary>
-    ///    /// Tests <see cref="View.Diagnostics"/> static property and <see cref="ViewDiagnosticFlags"/> enum.
-    ///    /// </summary>
+    ///     /// Tests <see cref="View.Diagnostics"/> static property and <see cref="ViewDiagnosticFlags"/> enum.
+    ///     ///
+    /// </summary>
     [Fact]
     [Fact]
     public void Diagnostics_Sets ()
     public void Diagnostics_Sets ()
     {
     {
         // View.Diagnostics is a static property that returns the current diagnostic flags.
         // View.Diagnostics is a static property that returns the current diagnostic flags.
         Assert.Equal (ViewDiagnosticFlags.Off, View.Diagnostics);
         Assert.Equal (ViewDiagnosticFlags.Off, View.Diagnostics);
-    
+
         // View.Diagnostics can be set to a new value.
         // View.Diagnostics can be set to a new value.
         View.Diagnostics = ViewDiagnosticFlags.Padding;
         View.Diagnostics = ViewDiagnosticFlags.Padding;
         Assert.Equal (ViewDiagnosticFlags.Padding, View.Diagnostics);
         Assert.Equal (ViewDiagnosticFlags.Padding, View.Diagnostics);

+ 9 - 13
UnitTests/View/DrawTests.cs

@@ -155,12 +155,9 @@ public class DrawTests (ITestOutputHelper _output)
                                                       _output);
                                                       _output);
     }
     }
 
 
-    [Theory]
-    [InlineData (0, 0, 1, 1)]
-    [InlineData (0, 0, 2, 2)]
-    [InlineData (-1, -1, 2, 2)]
+    [Fact]
     [SetupFakeDriver]
     [SetupFakeDriver]
-    public void Clear_ClearsEntireViewport (int x, int y, int width, int height)
+    public void Clear_ClearsEntireViewport ()
     {
     {
         var superView = new View { Width = Dim.Fill (), Height = Dim.Fill () };
         var superView = new View { Width = Dim.Fill (), Height = Dim.Fill () };
 
 
@@ -193,12 +190,9 @@ public class DrawTests (ITestOutputHelper _output)
                                                       _output);
                                                       _output);
     }
     }
 
 
-    [Theory]
-    [InlineData (0, 0, 1, 1)]
-    [InlineData (0, 0, 2, 2)]
-    [InlineData (-1, -1, 2, 2)]
+    [Fact]
     [SetupFakeDriver]
     [SetupFakeDriver]
-    public void Clear_WithClearVisibleContentOnly_ClearsVisibleContentOnly (int x, int y, int width, int height)
+    public void Clear_WithClearVisibleContentOnly_ClearsVisibleContentOnly ()
     {
     {
         var superView = new View { Width = Dim.Fill (), Height = Dim.Fill () };
         var superView = new View { Width = Dim.Fill (), Height = Dim.Fill () };
 
 
@@ -388,7 +382,7 @@ public class DrawTests (ITestOutputHelper _output)
                                                0
                                                0
                                                """,
                                                """,
                                                Application.Driver,
                                                Application.Driver,
-                                               Colors.ColorSchemes ["Base"].Normal
+                                               Colors.ColorSchemes ["Base"]!.Normal
                                               );
                                               );
         top.Dispose ();
         top.Dispose ();
     }
     }
@@ -686,8 +680,6 @@ public class DrawTests (ITestOutputHelper _output)
 
 
         // BUGBUG: v2 - it's bogus to reference .Frame before BeginInit. And why is the clip being set anyway???
         // BUGBUG: v2 - it's bogus to reference .Frame before BeginInit. And why is the clip being set anyway???
 
 
-        void Top_LayoutComplete (object sender, LayoutEventArgs e) { Application.Driver.Clip = container.Frame; }
-
         top.LayoutComplete += Top_LayoutComplete;
         top.LayoutComplete += Top_LayoutComplete;
         Application.Begin (top);
         Application.Begin (top);
 
 
@@ -732,6 +724,10 @@ public class DrawTests (ITestOutputHelper _output)
         Application.Refresh ();
         Application.Refresh ();
         TestHelpers.AssertDriverContentsWithFrameAre ("", _output);
         TestHelpers.AssertDriverContentsWithFrameAre ("", _output);
         top.Dispose ();
         top.Dispose ();
+
+        return;
+
+        void Top_LayoutComplete (object? sender, LayoutEventArgs e) { Application.Driver.Clip = container.Frame; }
     }
     }
 
 
     [Fact]
     [Fact]

+ 4 - 4
UnitTests/View/InitTests.cs

@@ -125,11 +125,11 @@ public class InitTests
         var superView = new View ();
         var superView = new View ();
         superView.Add (view);
         superView.Add (view);
 
 
-        var initialized = false;
-        view.Initialized += (s, e) => initialized = true;
+        //var initialized = false;
+        //view.Initialized += (s, e) => initialized = true;
 
 
-        var superViewInitialized = false;
-        superView.Initialized += (s, e) => superViewInitialized = true;
+        //var superViewInitialized = false;
+        //superView.Initialized += (s, e) => superViewInitialized = true;
 
 
         Assert.False (view.IsInitialized, "View should not be initialized");
         Assert.False (view.IsInitialized, "View should not be initialized");
         Assert.False (superView.IsInitialized, "SuperView should not be initialized");
         Assert.False (superView.IsInitialized, "SuperView should not be initialized");

+ 3 - 2
UnitTests/View/Layout/Pos.CombineTests.cs

@@ -66,7 +66,6 @@ public class PosCombineTests (ITestOutputHelper output)
     [SetupFakeDriver]
     [SetupFakeDriver]
     public void PosCombine_DimCombine_View_With_SubViews ()
     public void PosCombine_DimCombine_View_With_SubViews ()
     {
     {
-        var clicked = false;
         Toplevel top = new Toplevel () { Width = 80, Height = 25 };
         Toplevel top = new Toplevel () { Width = 80, Height = 25 };
         var win1 = new Window { Id = "win1", Width = 20, Height = 10 };
         var win1 = new Window { Id = "win1", Width = 20, Height = 10 };
         var view1 = new View
         var view1 = new View
@@ -78,7 +77,9 @@ public class PosCombineTests (ITestOutputHelper output)
         };
         };
         var win2 = new Window { Id = "win2", Y = Pos.Bottom (view1) + 1, Width = 10, Height = 3 };
         var win2 = new Window { Id = "win2", Y = Pos.Bottom (view1) + 1, Width = 10, Height = 3 };
         var view2 = new View { Id = "view2", Width = Dim.Fill (), Height = 1, CanFocus = true };
         var view2 = new View { Id = "view2", Width = Dim.Fill (), Height = 1, CanFocus = true };
-        view2.MouseClick += (sender, e) => clicked = true;
+
+        //var clicked = false;
+        //view2.MouseClick += (sender, e) => clicked = true;
         var view3 = new View { Id = "view3", Width = Dim.Fill (1), Height = 1, CanFocus = true };
         var view3 = new View { Id = "view3", Width = Dim.Fill (1), Height = 1, CanFocus = true };
 
 
         view2.Add (view3);
         view2.Add (view3);

+ 0 - 2
UnitTests/View/TextTests.cs

@@ -10,8 +10,6 @@ namespace Terminal.Gui.ViewTests;
 /// </summary>
 /// </summary>
 public class TextTests (ITestOutputHelper output)
 public class TextTests (ITestOutputHelper output)
 {
 {
-    private readonly ITestOutputHelper _output = output;
-
     // TextFormatter.Size should be empty unless DimAuto is set or ContentSize is set
     // TextFormatter.Size should be empty unless DimAuto is set or ContentSize is set
     [Theory]
     [Theory]
     [InlineData ("", 0, 0)]
     [InlineData ("", 0, 0)]

+ 5 - 6
UnitTests/Views/ButtonTests.cs

@@ -50,7 +50,6 @@ public class ButtonTests (ITestOutputHelper output)
     [InlineData ("0_12你", 0, 1, 0, 1)]
     [InlineData ("0_12你", 0, 1, 0, 1)]
     [InlineData ("0_12你", 1, 1, 1, 1)]
     [InlineData ("0_12你", 1, 1, 1, 1)]
     [InlineData ("0_12你", 10, 1, 10, 1)]
     [InlineData ("0_12你", 10, 1, 10, 1)]
-    [InlineData ("0_12你", 10, 3, 10, 3)]
     public void Button_AbsoluteSize_Text (string text, int width, int height, int expectedWidth, int expectedHeight)
     public void Button_AbsoluteSize_Text (string text, int width, int height, int expectedWidth, int expectedHeight)
     {
     {
         var btn1 = new Button
         var btn1 = new Button
@@ -567,11 +566,11 @@ public class ButtonTests (ITestOutputHelper output)
     }
     }
 
 
     [Theory]
     [Theory]
-    [InlineData (MouseFlags.Button1Pressed, MouseFlags.Button1Released, MouseFlags.Button1Clicked)]
-    [InlineData (MouseFlags.Button2Pressed, MouseFlags.Button2Released, MouseFlags.Button2Clicked)]
-    [InlineData (MouseFlags.Button3Pressed, MouseFlags.Button3Released, MouseFlags.Button3Clicked)]
-    [InlineData (MouseFlags.Button4Pressed, MouseFlags.Button4Released, MouseFlags.Button4Clicked)]
-    public void WantContinuousButtonPressed_True_ButtonPressRelease_Accepts (MouseFlags pressed, MouseFlags released, MouseFlags clicked)
+    [InlineData (MouseFlags.Button1Pressed, MouseFlags.Button1Released)]
+    [InlineData (MouseFlags.Button2Pressed, MouseFlags.Button2Released)]
+    [InlineData (MouseFlags.Button3Pressed, MouseFlags.Button3Released)]
+    [InlineData (MouseFlags.Button4Pressed, MouseFlags.Button4Released)]
+    public void WantContinuousButtonPressed_True_ButtonPressRelease_Accepts (MouseFlags pressed, MouseFlags released)
     {
     {
         var me = new MouseEvent ();
         var me = new MouseEvent ();
 
 

+ 1 - 1
UnitTests/Views/TreeViewTests.cs

@@ -1394,7 +1394,7 @@ oot two
 
 
         Assert.True (accepted);
         Assert.True (accepted);
         Assert.False (activated);
         Assert.False (activated);
-        Assert.Equal (null, selectedObject);
+        Assert.Null (selectedObject);
 
 
         return;
         return;