mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2025-12-26 15:57:56 +01:00
Fixed unit test warnings
This commit is contained in:
@@ -267,8 +267,6 @@ public class ApplicationTests
|
||||
{
|
||||
Application.Init (new FakeDriver ());
|
||||
|
||||
Toplevel topLevel = null;
|
||||
|
||||
Assert.Throws<InvalidOperationException> (
|
||||
() =>
|
||||
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<InvalidOperationException> (() => Application.Init (new FakeDriver ()));
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace Terminal.Gui.DialogTests;
|
||||
|
||||
public class WizardTests (ITestOutputHelper output)
|
||||
public class WizardTests ()
|
||||
{
|
||||
// =========== Wizard Tests
|
||||
[Fact]
|
||||
|
||||
@@ -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> (color);
|
||||
|
||||
@@ -4,21 +4,22 @@ using Xunit.Abstractions;
|
||||
namespace Terminal.Gui.ViewTests;
|
||||
|
||||
/// <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>
|
||||
/// <param name="output"></param>
|
||||
[Trait("Category","Output")]
|
||||
public class DiagnosticTests (ITestOutputHelper output)
|
||||
[Trait ("Category", "Output")]
|
||||
public class DiagnosticTests ()
|
||||
{
|
||||
/// <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]
|
||||
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);
|
||||
|
||||
@@ -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]
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -10,8 +10,6 @@ namespace Terminal.Gui.ViewTests;
|
||||
/// </summary>
|
||||
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)]
|
||||
|
||||
@@ -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 ();
|
||||
|
||||
|
||||
@@ -1394,7 +1394,7 @@ oot two
|
||||
|
||||
Assert.True (accepted);
|
||||
Assert.False (activated);
|
||||
Assert.Equal (null, selectedObject);
|
||||
Assert.Null (selectedObject);
|
||||
|
||||
return;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user