Fix warnings

This commit is contained in:
Tig
2024-05-11 09:28:58 -06:00
parent 56cd7b036b
commit cd2df54c97
10 changed files with 90 additions and 97 deletions

View File

@@ -228,7 +228,6 @@ public class AlignerTests (ITestOutputHelper output)
[InlineData (Alignment.FirstLeftRestRight, new [] { 10, 20, 30 }, 101, new [] { 0, 50, 71 })]
[InlineData (Alignment.FirstLeftRestRight, new [] { 10, 20, 30, 40 }, 101, new [] { 0, 10, 30, 61 })]
[InlineData (Alignment.FirstLeftRestRight, new [] { 10, 20, 30, 40, 50 }, 151, new [] { 0, 10, 30, 60, 101 })]
[InlineData (Alignment.FirstLeftRestRight, new [] { 3, 3, 3 }, 21, new [] { 0, 14, 18 })]
[InlineData (Alignment.FirstLeftRestRight, new [] { 3, 4, 5 }, 21, new [] { 0, 11, 16 })]
public void Alignment_SpaceBetweenItems (Alignment alignment, int [] sizes, int containerSize, int [] expected)
{

View File

@@ -3260,7 +3260,6 @@ ssb
[InlineData ("A B", 3, false, "A B")]
[InlineData ("A B", 1, false, "A")]
[InlineData ("A B", 2, false, "A")]
[InlineData ("A B", 3, false, "A B")]
[InlineData ("A B", 4, false, "A B")]
[InlineData ("A B", 5, false, "A B")]
[InlineData ("A B", 6, false, "A B")]
@@ -3270,7 +3269,6 @@ ssb
[InlineData ("A", 0, true, "")]
[InlineData ("A", 1, true, "A")]
[InlineData ("A", 2, true, "A")]
[InlineData ("A B", 3, true, "A B")]
[InlineData ("A B", 1, true, "A")]
[InlineData ("A B", 2, true, "A")]
[InlineData ("A B", 3, true, "A B")]

View File

@@ -893,7 +893,6 @@ public class DimAutoTests (ITestOutputHelper output)
[Theory]
[InlineData (0, 15, 15)]
[InlineData (1, 15, 16)]
[InlineData (0, 15, 15)]
[InlineData (-1, 15, 14)]
public void DimAuto_With_Subview_Using_DimAbsolute (int subViewOffset, int dimAbsoluteSize, int expectedSize)
{

View File

@@ -7,8 +7,6 @@ namespace Terminal.Gui.PosDimTests;
public class DimPercentTests
{
private readonly ITestOutputHelper _output;
[Fact]
public void DimFactor_Calculate_ReturnsCorrectValue ()
{

View File

@@ -355,8 +355,8 @@ public class DimTests
Assert.Equal (99, dimFill.Anchor (100));
var dimCombine = new Dim.DimCombine (true, dimFactor, dimAbsolute);
Assert.Equal (dimCombine._left, dimFactor);
Assert.Equal (dimCombine._right, dimAbsolute);
Assert.Equal (dimCombine.Left, dimFactor);
Assert.Equal (dimCombine.Right, dimAbsolute);
Assert.Equal (20, dimCombine.Anchor (100));
var view = new View { Frame = new Rectangle (20, 10, 20, 1) };

View File

@@ -4,13 +4,13 @@ using static Terminal.Gui.Pos;
namespace Terminal.Gui.PosDimTests;
public class PosAlignTests (ITestOutputHelper output)
public class PosAlignTests ()
{
[Fact]
public void PosAlign_Constructor ()
{
var PosAlign = new PosAlign (Alignment.Justified);
Assert.NotNull (PosAlign);
var posAlign = new PosAlign (Alignment.Justified);
Assert.NotNull (posAlign);
}
[Theory]
@@ -30,20 +30,20 @@ public class PosAlignTests (ITestOutputHelper output)
[Fact]
public void PosAlign_ToString ()
{
var PosAlign = new PosAlign (Alignment.Justified);
var posAlign = new PosAlign (Alignment.Justified);
var expectedString = "Align(groupId=0, alignment=Justified)";
Assert.Equal (expectedString, PosAlign.ToString ());
Assert.Equal (expectedString, posAlign.ToString ());
}
[Fact]
public void PosAlign_Anchor ()
{
var PosAlign = new PosAlign (Alignment.Left);
var posAlign = new PosAlign (Alignment.Left);
var width = 50;
var expectedAnchor = -width;
Assert.Equal (expectedAnchor, PosAlign.Anchor (width));
Assert.Equal (expectedAnchor, posAlign.Anchor (width));
}
[Fact]

View File

@@ -4,7 +4,7 @@ using static Terminal.Gui.Pos;
namespace Terminal.Gui.PosDimTests;
public class PosTests (ITestOutputHelper output)
public class PosTests ()
{
// Was named AutoSize_Pos_Validation_Do_Not_Throws_If_NewValue_Is_PosAbsolute_And_OldValue_Is_Another_Type_After_Sets_To_LayoutStyle_Absolute ()
// but doesn't actually have anything to do with AutoSize.
@@ -110,7 +110,7 @@ public class PosTests (ITestOutputHelper output)
{
Application.Init (new FakeDriver ());
Toplevel t = new Toplevel();
Toplevel t = new Toplevel ();
var w = new Window { X = Pos.Left (t) + 2, Y = Pos.Top (t) + 2 };
var f = new FrameView ();
@@ -225,13 +225,13 @@ public class PosTests (ITestOutputHelper output)
Assert.Equal (10, posAbsolute.Anchor (0));
var posCombine = new Pos.PosCombine (true, posFactor, posAbsolute);
Assert.Equal (posCombine.Left, posFactor);
Assert.Equal (posCombine.Right, posAbsolute);
Assert.Equal (posCombine.LeftPos, posFactor);
Assert.Equal (posCombine.RightPos, posAbsolute);
Assert.Equal (20, posCombine.Anchor (100));
posCombine = new (true, posAbsolute, posFactor);
Assert.Equal (posCombine.Left, posAbsolute);
Assert.Equal (posCombine.Right, posFactor);
Assert.Equal (posCombine.LeftPos, posAbsolute);
Assert.Equal (posCombine.RightPos, posFactor);
Assert.Equal (20, posCombine.Anchor (100));
var view = new View { Frame = new (20, 10, 20, 1) };
@@ -255,7 +255,7 @@ public class PosTests (ITestOutputHelper output)
public void LeftTopBottomRight_Win_ShouldNotThrow ()
{
// Setup Fake driver
(Toplevel top, Window win, Button button) setup ()
(Toplevel top, Window win, Button button) Setup ()
{
Application.Init (new FakeDriver ());
Application.Iteration += (s, a) => { Application.RequestStop (); };
@@ -271,7 +271,7 @@ public class PosTests (ITestOutputHelper output)
RunState rs;
void cleanup (RunState rs)
void Cleanup (RunState rs)
{
// Cleanup
Application.End (rs);
@@ -283,53 +283,53 @@ public class PosTests (ITestOutputHelper output)
}
// Test cases:
(Toplevel top, Window win, Button button) app = setup ();
(Toplevel top, Window win, Button button) app = Setup ();
app.button.Y = Pos.Left (app.win);
rs = Application.Begin (app.top);
// If Application.RunState is used then we must use Application.RunLoop with the rs parameter
Application.RunLoop (rs);
cleanup (rs);
Cleanup (rs);
app = setup ();
app = Setup ();
app.button.Y = Pos.X (app.win);
rs = Application.Begin (app.top);
// If Application.RunState is used then we must use Application.RunLoop with the rs parameter
Application.RunLoop (rs);
cleanup (rs);
Cleanup (rs);
app = setup ();
app = Setup ();
app.button.Y = Pos.Top (app.win);
rs = Application.Begin (app.top);
// If Application.RunState is used then we must use Application.RunLoop with the rs parameter
Application.RunLoop (rs);
cleanup (rs);
Cleanup (rs);
app = setup ();
app = Setup ();
app.button.Y = Pos.Y (app.win);
rs = Application.Begin (app.top);
// If Application.RunState is used then we must use Application.RunLoop with the rs parameter
Application.RunLoop (rs);
cleanup (rs);
Cleanup (rs);
app = setup ();
app = Setup ();
app.button.Y = Pos.Bottom (app.win);
rs = Application.Begin (app.top);
// If Application.RunState is used then we must use Application.RunLoop with the rs parameter
Application.RunLoop (rs);
cleanup (rs);
Cleanup (rs);
app = setup ();
app = Setup ();
app.button.Y = Pos.Right (app.win);
rs = Application.Begin (app.top);
// If Application.RunState is used then we must use Application.RunLoop with the rs parameter
Application.RunLoop (rs);
cleanup (rs);
Cleanup (rs);
}
[Fact]
@@ -548,15 +548,15 @@ public class PosTests (ITestOutputHelper output)
pos = Pos.Left (new ());
Assert.Equal ($"View(side={side},target=View(){testRect})", pos.ToString ());
pos = Pos.Left (new() { Frame = testRect });
pos = Pos.Left (new () { Frame = testRect });
Assert.Equal ($"View(side={side},target=View(){testRect})", pos.ToString ());
testRect = new (1, 2, 3, 4);
pos = Pos.Left (new() { Frame = testRect });
pos = Pos.Left (new () { Frame = testRect });
Assert.Equal ($"View(side={side},target=View(){testRect})", pos.ToString ());
// Pos.Left(win) + 0
pos = Pos.Left (new() { Frame = testRect }) + testInt;
pos = Pos.Left (new () { Frame = testRect }) + testInt;
Assert.Equal (
$"Combine(View(side={side},target=View(){testRect}){(testInt < 0 ? '-' : '+')}Absolute({testInt}))",
@@ -566,7 +566,7 @@ public class PosTests (ITestOutputHelper output)
testInt = 1;
// Pos.Left(win) +1
pos = Pos.Left (new() { Frame = testRect }) + testInt;
pos = Pos.Left (new () { Frame = testRect }) + testInt;
Assert.Equal (
$"Combine(View(side={side},target=View(){testRect}){(testInt < 0 ? '-' : '+')}Absolute({testInt}))",
@@ -576,7 +576,7 @@ public class PosTests (ITestOutputHelper output)
testInt = -1;
// Pos.Left(win) -1
pos = Pos.Left (new() { Frame = testRect }) - testInt;
pos = Pos.Left (new () { Frame = testRect }) - testInt;
Assert.Equal (
$"Combine(View(side={side},target=View(){testRect}){(testInt < 0 ? '-' : '+')}Absolute({testInt}))",
@@ -590,15 +590,15 @@ public class PosTests (ITestOutputHelper output)
pos = Pos.X (new ());
Assert.Equal ($"View(side={side},target=View(){testRect})", pos.ToString ());
pos = Pos.X (new() { Frame = testRect });
pos = Pos.X (new () { Frame = testRect });
Assert.Equal ($"View(side={side},target=View(){testRect})", pos.ToString ());
testRect = new (1, 2, 3, 4);
pos = Pos.X (new() { Frame = testRect });
pos = Pos.X (new () { Frame = testRect });
Assert.Equal ($"View(side={side},target=View(){testRect})", pos.ToString ());
// Pos.X(win) + 0
pos = Pos.X (new() { Frame = testRect }) + testInt;
pos = Pos.X (new () { Frame = testRect }) + testInt;
Assert.Equal (
$"Combine(View(side={side},target=View(){testRect}){(testInt < 0 ? '-' : '+')}Absolute({testInt}))",
@@ -608,7 +608,7 @@ public class PosTests (ITestOutputHelper output)
testInt = 1;
// Pos.X(win) +1
pos = Pos.X (new() { Frame = testRect }) + testInt;
pos = Pos.X (new () { Frame = testRect }) + testInt;
Assert.Equal (
$"Combine(View(side={side},target=View(){testRect}){(testInt < 0 ? '-' : '+')}Absolute({testInt}))",
@@ -618,7 +618,7 @@ public class PosTests (ITestOutputHelper output)
testInt = -1;
// Pos.X(win) -1
pos = Pos.X (new() { Frame = testRect }) - testInt;
pos = Pos.X (new () { Frame = testRect }) - testInt;
Assert.Equal (
$"Combine(View(side={side},target=View(){testRect}){(testInt < 0 ? '-' : '+')}Absolute({testInt}))",
@@ -632,15 +632,15 @@ public class PosTests (ITestOutputHelper output)
pos = Pos.Top (new ());
Assert.Equal ($"View(side={side},target=View(){testRect})", pos.ToString ());
pos = Pos.Top (new() { Frame = testRect });
pos = Pos.Top (new () { Frame = testRect });
Assert.Equal ($"View(side={side},target=View(){testRect})", pos.ToString ());
testRect = new (1, 2, 3, 4);
pos = Pos.Top (new() { Frame = testRect });
pos = Pos.Top (new () { Frame = testRect });
Assert.Equal ($"View(side={side},target=View(){testRect})", pos.ToString ());
// Pos.Top(win) + 0
pos = Pos.Top (new() { Frame = testRect }) + testInt;
pos = Pos.Top (new () { Frame = testRect }) + testInt;
Assert.Equal (
$"Combine(View(side={side},target=View(){testRect}){(testInt < 0 ? '-' : '+')}Absolute({testInt}))",
@@ -650,7 +650,7 @@ public class PosTests (ITestOutputHelper output)
testInt = 1;
// Pos.Top(win) +1
pos = Pos.Top (new() { Frame = testRect }) + testInt;
pos = Pos.Top (new () { Frame = testRect }) + testInt;
Assert.Equal (
$"Combine(View(side={side},target=View(){testRect}){(testInt < 0 ? '-' : '+')}Absolute({testInt}))",
@@ -660,7 +660,7 @@ public class PosTests (ITestOutputHelper output)
testInt = -1;
// Pos.Top(win) -1
pos = Pos.Top (new() { Frame = testRect }) - testInt;
pos = Pos.Top (new () { Frame = testRect }) - testInt;
Assert.Equal (
$"Combine(View(side={side},target=View(){testRect}){(testInt < 0 ? '-' : '+')}Absolute({testInt}))",
@@ -674,15 +674,15 @@ public class PosTests (ITestOutputHelper output)
pos = Pos.Y (new ());
Assert.Equal ($"View(side={side},target=View(){testRect})", pos.ToString ());
pos = Pos.Y (new() { Frame = testRect });
pos = Pos.Y (new () { Frame = testRect });
Assert.Equal ($"View(side={side},target=View(){testRect})", pos.ToString ());
testRect = new (1, 2, 3, 4);
pos = Pos.Y (new() { Frame = testRect });
pos = Pos.Y (new () { Frame = testRect });
Assert.Equal ($"View(side={side},target=View(){testRect})", pos.ToString ());
// Pos.Y(win) + 0
pos = Pos.Y (new() { Frame = testRect }) + testInt;
pos = Pos.Y (new () { Frame = testRect }) + testInt;
Assert.Equal (
$"Combine(View(side={side},target=View(){testRect}){(testInt < 0 ? '-' : '+')}Absolute({testInt}))",
@@ -692,7 +692,7 @@ public class PosTests (ITestOutputHelper output)
testInt = 1;
// Pos.Y(win) +1
pos = Pos.Y (new() { Frame = testRect }) + testInt;
pos = Pos.Y (new () { Frame = testRect }) + testInt;
Assert.Equal (
$"Combine(View(side={side},target=View(){testRect}){(testInt < 0 ? '-' : '+')}Absolute({testInt}))",
@@ -702,7 +702,7 @@ public class PosTests (ITestOutputHelper output)
testInt = -1;
// Pos.Y(win) -1
pos = Pos.Y (new() { Frame = testRect }) - testInt;
pos = Pos.Y (new () { Frame = testRect }) - testInt;
Assert.Equal (
$"Combine(View(side={side},target=View(){testRect}){(testInt < 0 ? '-' : '+')}Absolute({testInt}))",
@@ -716,15 +716,15 @@ public class PosTests (ITestOutputHelper output)
pos = Pos.Bottom (new ());
Assert.Equal ($"View(side={side},target=View(){testRect})", pos.ToString ());
pos = Pos.Bottom (new() { Frame = testRect });
pos = Pos.Bottom (new () { Frame = testRect });
Assert.Equal ($"View(side={side},target=View(){testRect})", pos.ToString ());
testRect = new (1, 2, 3, 4);
pos = Pos.Bottom (new() { Frame = testRect });
pos = Pos.Bottom (new () { Frame = testRect });
Assert.Equal ($"View(side={side},target=View(){testRect})", pos.ToString ());
// Pos.Bottom(win) + 0
pos = Pos.Bottom (new() { Frame = testRect }) + testInt;
pos = Pos.Bottom (new () { Frame = testRect }) + testInt;
Assert.Equal (
$"Combine(View(side={side},target=View(){testRect}){(testInt < 0 ? '-' : '+')}Absolute({testInt}))",
@@ -734,7 +734,7 @@ public class PosTests (ITestOutputHelper output)
testInt = 1;
// Pos.Bottom(win) +1
pos = Pos.Bottom (new() { Frame = testRect }) + testInt;
pos = Pos.Bottom (new () { Frame = testRect }) + testInt;
Assert.Equal (
$"Combine(View(side={side},target=View(){testRect}){(testInt < 0 ? '-' : '+')}Absolute({testInt}))",
@@ -744,7 +744,7 @@ public class PosTests (ITestOutputHelper output)
testInt = -1;
// Pos.Bottom(win) -1
pos = Pos.Bottom (new() { Frame = testRect }) - testInt;
pos = Pos.Bottom (new () { Frame = testRect }) - testInt;
Assert.Equal (
$"Combine(View(side={side},target=View(){testRect}){(testInt < 0 ? '-' : '+')}Absolute({testInt}))",
@@ -878,7 +878,6 @@ public class PosTests (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
@@ -887,10 +886,9 @@ public class PosTests (ITestOutputHelper output)
Width = Auto (DimAutoStyle.Text),
Height = Auto (DimAutoStyle.Text)
};
};
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 view3 = new View { Id = "view3", Width = Dim.Fill (1), Height = 1, CanFocus = true };
view2.Add (view3);

View File

@@ -5,7 +5,7 @@ using Xunit.Abstractions;
namespace Terminal.Gui.ViewTests;
[Trait("Category","Output")]
public class NeedsDisplayTests (ITestOutputHelper output)
public class NeedsDisplayTests ()
{
[Fact]
public void NeedsDisplay_False_If_Width_Height_Zero ()