diff --git a/UnitTests/Application/ApplicationTests.cs b/UnitTests/Application/ApplicationTests.cs index 9aa655cab..1910df0be 100644 --- a/UnitTests/Application/ApplicationTests.cs +++ b/UnitTests/Application/ApplicationTests.cs @@ -267,8 +267,6 @@ public class ApplicationTests { Application.Init (new FakeDriver ()); - Toplevel topLevel = null; - Assert.Throws ( () => Application.InternalInit ( @@ -282,7 +280,6 @@ public class ApplicationTests Assert.Null (Application.Driver); // Now try the other way - topLevel = null; Application.InternalInit (new FakeDriver ()); Assert.Throws (() => Application.Init (new FakeDriver ())); diff --git a/UnitTests/Dialogs/WizardTests.cs b/UnitTests/Dialogs/WizardTests.cs index fca7f641d..65594c276 100644 --- a/UnitTests/Dialogs/WizardTests.cs +++ b/UnitTests/Dialogs/WizardTests.cs @@ -2,7 +2,7 @@ namespace Terminal.Gui.DialogTests; -public class WizardTests (ITestOutputHelper output) +public class WizardTests () { // =========== Wizard Tests [Fact] diff --git a/UnitTests/Drawing/ColorTests.ParsingAndFormatting.cs b/UnitTests/Drawing/ColorTests.ParsingAndFormatting.cs index ab2e80a35..2f32d7b6c 100644 --- a/UnitTests/Drawing/ColorTests.ParsingAndFormatting.cs +++ b/UnitTests/Drawing/ColorTests.ParsingAndFormatting.cs @@ -84,7 +84,7 @@ public partial class ColorTests )] 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.Null (color); } @@ -94,9 +94,9 @@ public partial class ColorTests nameof (ColorTestsTheoryDataGenerators.TryParse_string_Returns_True_For_Valid_Inputs), 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.NotNull (color); Assert.IsType (color); diff --git a/UnitTests/View/DiagnosticsTests.cs b/UnitTests/View/DiagnosticsTests.cs index 87eaaf0ad..2c5172569 100644 --- a/UnitTests/View/DiagnosticsTests.cs +++ b/UnitTests/View/DiagnosticsTests.cs @@ -4,21 +4,22 @@ using Xunit.Abstractions; namespace Terminal.Gui.ViewTests; /// -/// Tests static property and enum. +/// Tests static property and enum. /// /// -[Trait("Category","Output")] -public class DiagnosticTests (ITestOutputHelper output) +[Trait ("Category", "Output")] +public class DiagnosticTests () { /// - /// /// Tests static property and enum. - /// /// + /// /// Tests static property and enum. + /// /// + /// [Fact] public void Diagnostics_Sets () { // View.Diagnostics is a static property that returns the current diagnostic flags. Assert.Equal (ViewDiagnosticFlags.Off, View.Diagnostics); - + // View.Diagnostics can be set to a new value. View.Diagnostics = ViewDiagnosticFlags.Padding; Assert.Equal (ViewDiagnosticFlags.Padding, View.Diagnostics); diff --git a/UnitTests/View/DrawTests.cs b/UnitTests/View/DrawTests.cs index eac9b9434..46c791ab4 100644 --- a/UnitTests/View/DrawTests.cs +++ b/UnitTests/View/DrawTests.cs @@ -155,12 +155,9 @@ public class DrawTests (ITestOutputHelper _output) _output); } - [Theory] - [InlineData (0, 0, 1, 1)] - [InlineData (0, 0, 2, 2)] - [InlineData (-1, -1, 2, 2)] + [Fact] [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 () }; @@ -193,12 +190,9 @@ public class DrawTests (ITestOutputHelper _output) _output); } - [Theory] - [InlineData (0, 0, 1, 1)] - [InlineData (0, 0, 2, 2)] - [InlineData (-1, -1, 2, 2)] + [Fact] [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 () }; @@ -388,7 +382,7 @@ public class DrawTests (ITestOutputHelper _output) 0 """, Application.Driver, - Colors.ColorSchemes ["Base"].Normal + Colors.ColorSchemes ["Base"]!.Normal ); 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??? - void Top_LayoutComplete (object sender, LayoutEventArgs e) { Application.Driver.Clip = container.Frame; } - top.LayoutComplete += Top_LayoutComplete; Application.Begin (top); @@ -732,6 +724,10 @@ public class DrawTests (ITestOutputHelper _output) Application.Refresh (); TestHelpers.AssertDriverContentsWithFrameAre ("", _output); top.Dispose (); + + return; + + void Top_LayoutComplete (object? sender, LayoutEventArgs e) { Application.Driver.Clip = container.Frame; } } [Fact] diff --git a/UnitTests/View/InitTests.cs b/UnitTests/View/InitTests.cs index b62c94edf..4fe482652 100644 --- a/UnitTests/View/InitTests.cs +++ b/UnitTests/View/InitTests.cs @@ -125,11 +125,11 @@ public class InitTests var superView = new 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 (superView.IsInitialized, "SuperView should not be initialized"); diff --git a/UnitTests/View/Layout/Pos.CombineTests.cs b/UnitTests/View/Layout/Pos.CombineTests.cs index 030ceb354..2dc576438 100644 --- a/UnitTests/View/Layout/Pos.CombineTests.cs +++ b/UnitTests/View/Layout/Pos.CombineTests.cs @@ -66,7 +66,6 @@ public class PosCombineTests (ITestOutputHelper output) [SetupFakeDriver] public void PosCombine_DimCombine_View_With_SubViews () { - var clicked = false; Toplevel top = new Toplevel () { Width = 80, Height = 25 }; var win1 = new Window { Id = "win1", Width = 20, Height = 10 }; 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 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 }; view2.Add (view3); diff --git a/UnitTests/View/TextTests.cs b/UnitTests/View/TextTests.cs index f12f12ab6..3bd6cfb23 100644 --- a/UnitTests/View/TextTests.cs +++ b/UnitTests/View/TextTests.cs @@ -10,8 +10,6 @@ namespace Terminal.Gui.ViewTests; /// public class TextTests (ITestOutputHelper output) { - private readonly ITestOutputHelper _output = output; - // TextFormatter.Size should be empty unless DimAuto is set or ContentSize is set [Theory] [InlineData ("", 0, 0)] diff --git a/UnitTests/Views/ButtonTests.cs b/UnitTests/Views/ButtonTests.cs index 48e379ebd..d4d9c9cd0 100644 --- a/UnitTests/Views/ButtonTests.cs +++ b/UnitTests/Views/ButtonTests.cs @@ -50,7 +50,6 @@ public class ButtonTests (ITestOutputHelper output) [InlineData ("0_12你", 0, 1, 0, 1)] [InlineData ("0_12你", 1, 1, 1, 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) { var btn1 = new Button @@ -567,11 +566,11 @@ public class ButtonTests (ITestOutputHelper output) } [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 (); diff --git a/UnitTests/Views/TreeViewTests.cs b/UnitTests/Views/TreeViewTests.cs index 161492ced..7efdd58b9 100644 --- a/UnitTests/Views/TreeViewTests.cs +++ b/UnitTests/Views/TreeViewTests.cs @@ -1394,7 +1394,7 @@ oot two Assert.True (accepted); Assert.False (activated); - Assert.Equal (null, selectedObject); + Assert.Null (selectedObject); return;