Fixed unit test warnings

This commit is contained in:
Tig
2024-05-30 11:46:04 -06:00
parent f32df9ab3f
commit dde1fe435c
10 changed files with 33 additions and 41 deletions

View File

@@ -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);

View File

@@ -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]

View File

@@ -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");

View File

@@ -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);

View File

@@ -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)]