Revert "Add more unit tests to LineCanvas."

This reverts commit 66bc6f514e.
This commit is contained in:
BDisp
2023-11-23 21:59:15 +00:00
parent 042e180206
commit 2e5a658d16

View File

@@ -247,55 +247,23 @@ namespace Terminal.Gui.DrawingTests {
TestHelpers.AssertEqual (output, expected, $"{lc}");
}
[InlineData (Orientation.Horizontal, "╥", false)]
[InlineData (Orientation.Vertical, "╞", false)]
[InlineData (Orientation.Horizontal, "╥", true)]
[InlineData (Orientation.Vertical, "╞", true)]
[InlineData (Orientation.Horizontal, "╥")]
[InlineData (Orientation.Vertical, "╞")]
[Theory, SetupFakeDriver]
public void Length_Zero_NextTo_Opposite_Is_T (Orientation orientation, string expected, bool zeroLengthFirst)
public void Length_Zero_NextTo_Opposite_Is_T (Orientation orientation, string expected)
{
var lc = new LineCanvas ();
if (zeroLengthFirst) {
// Add a line at 0, 0 that's has length of 0
lc.AddLine (new Point (0, 0), 0, orientation, LineStyle.Single);
}
// Add line with length of 1 in opposite orientation starting at same location
if (orientation == Orientation.Horizontal) {
lc.AddLine (new Point (0, 0), 1, Orientation.Vertical, LineStyle.Double);
} else {
lc.AddLine (new Point (0, 0), 1, Orientation.Horizontal, LineStyle.Double);
}
if (!zeroLengthFirst) {
// Add a line at 0, 0 that's has length of 0
lc.AddLine (new Point (0, 0), 0, orientation, LineStyle.Single);
}
TestHelpers.AssertEqual (output, expected, $"{lc}");
}
[InlineData (Orientation.Horizontal, "╨", false)]
[InlineData (Orientation.Vertical, "╡", false)]
[InlineData (Orientation.Horizontal, "╨", true)]
[InlineData (Orientation.Vertical, "╡", true)]
[Theory, SetupFakeDriver]
public void Length_Zero_NextTo_Negative_Opposite_Is_Opposite_T (Orientation orientation, string expected, bool zeroLengthFirst)
{
var lc = new LineCanvas ();
}
if (zeroLengthFirst) {
// Add a line at 0, 0 that's has length of 0
lc.AddLine (new Point (0, 0), 0, orientation, LineStyle.Single);
}
// Add line with length of 1 in opposite orientation starting at same location
if (orientation == Orientation.Horizontal) {
lc.AddLine (new Point (0, 0), -1, Orientation.Vertical, LineStyle.Double);
} else {
lc.AddLine (new Point (0, 0), -1, Orientation.Horizontal, LineStyle.Double);
}
if (!zeroLengthFirst) {
// Add a line at 0, 0 that's has length of 0
lc.AddLine (new Point (0, 0), 0, orientation, LineStyle.Single);
}
// Add a line at 0, 0 that's has length of 0
lc.AddLine (new Point (0, 0), 0, orientation, LineStyle.Single);
TestHelpers.AssertEqual (output, expected, $"{lc}");
}
@@ -827,33 +795,30 @@ namespace Terminal.Gui.DrawingTests {
TestHelpers.AssertEqual (output, looksLike, $"{Environment.NewLine}{canvas}");
}
[Fact, SetupFakeDriver]
public void LeaveMargin_Top1_Left1 ()
{
var canvas = new LineCanvas ();
// [Fact, SetupFakeDriver]
// public void LeaveMargin_Top1_Left1 ()
// {
// var canvas = new LineCanvas ();
// Upper box
canvas.AddLine (new Point (0, 0), 9, Orientation.Horizontal, LineStyle.Single);
canvas.AddLine (new Point (8, 0), 3, Orientation.Vertical, LineStyle.Single);
canvas.AddLine (new Point (8, 2), -9, Orientation.Horizontal, LineStyle.Single);
canvas.AddLine (new Point (0, 2), -3, Orientation.Vertical, LineStyle.Single);
// // Upper box
// canvas.AddLine (new Point (0, 0), 9, Orientation.Horizontal, LineStyle.Single);
// canvas.AddLine (new Point (8, 0), 3, Orientation.Vertical, LineStyle.Single);
// canvas.AddLine (new Point (8, 3), -9, Orientation.Horizontal, LineStyle.Single);
// canvas.AddLine (new Point (0, 2), -3, Orientation.Vertical, LineStyle.Single);
// Lower Box
canvas.AddLine (new Point (0, 2), 9, Orientation.Horizontal, LineStyle.Single);
canvas.AddLine (new Point (8, 2), 2, Orientation.Vertical, LineStyle.Single);
canvas.AddLine (new Point (8, 3), -9, Orientation.Horizontal, LineStyle.Single);
canvas.AddLine (new Point (0, 3), -2, Orientation.Vertical, LineStyle.Single);
// // Lower Box
// canvas.AddLine (new Point (5, 0), 2, Orientation.Vertical, LineStyle.Single);
// canvas.AddLine (new Point (0, 2), 9, Orientation.Horizontal, LineStyle.Single);
// Middle vertical line
canvas.AddLine (new Point (5, 0), 4, Orientation.Vertical, LineStyle.Single);
string looksLike = @"
──────
│ │ │
├────┼──┤
└────┴──┘";
TestHelpers.AssertEqual (output, looksLike, $"{Environment.NewLine}{canvas}");
}
// string looksLike =
//@"
//┌────┬──┐
//│ │ │
//├──────
//└────┴──┘
//";
// Assert.Equal (looksLike, $"{Environment.NewLine}{canvas}");
// }
[InlineData (0, 0, 0, Orientation.Horizontal, LineStyle.Double, "═")]
[InlineData (0, 0, 0, Orientation.Vertical, LineStyle.Double, "║")]
@@ -1021,174 +986,5 @@ namespace Terminal.Gui.DrawingTests {
return v;
}
[Fact, SetupFakeDriver]
public void TabWindow ()
{
var canvas = new LineCanvas ();
// Outer frame
canvas.AddLine (new Point (0, 0), 10, Orientation.Horizontal, LineStyle.Single);
canvas.AddLine (new Point (9, 0), 6, Orientation.Vertical, LineStyle.Single);
canvas.AddLine (new Point (9, 5), -10, Orientation.Horizontal, LineStyle.Single);
canvas.AddLine (new Point (0, 5), -6, Orientation.Vertical, LineStyle.Single);
// Tab frame
canvas.AddLine (new Point (1, 2), -2, Orientation.Vertical, LineStyle.Single);
canvas.AddLine (new Point (1, 1), 4, Orientation.Horizontal, LineStyle.Single);
canvas.AddLine (new Point (4, 1), 2, Orientation.Vertical, LineStyle.Single);
// Inner frame
canvas.AddLine (new Point (4, 2), 5, Orientation.Horizontal, LineStyle.Single);
canvas.AddLine (new Point (8, 2), 3, Orientation.Vertical, LineStyle.Single);
canvas.AddLine (new Point (8, 4), -8, Orientation.Horizontal, LineStyle.Single);
canvas.AddLine (new Point (1, 4), -3, Orientation.Vertical, LineStyle.Single);
string looksLike = @"
┌────────┐
│┌──┐ │
││ └───┐│
││ ││
│└──────┘│
└────────┘";
TestHelpers.AssertEqual (output, looksLike, $"{Environment.NewLine}{canvas}");
}
[Fact, SetupFakeDriver]
public void TabWindow_With_Border ()
{
var canvas = new LineCanvas ();
// Outer frame
canvas.AddLine (new Point (0, 0), 10, Orientation.Horizontal, LineStyle.Single);
canvas.AddLine (new Point (9, 0), 6, Orientation.Vertical, LineStyle.Single);
canvas.AddLine (new Point (9, 5), -10, Orientation.Horizontal, LineStyle.Single);
canvas.AddLine (new Point (0, 5), -6, Orientation.Vertical, LineStyle.Single);
// Tab frame
canvas.AddLine (new Point (1, 2), -2, Orientation.Vertical, LineStyle.Single);
canvas.AddLine (new Point (1, 1), 4, Orientation.Horizontal, LineStyle.Single);
canvas.AddLine (new Point (4, 1), 2, Orientation.Vertical, LineStyle.Single);
// Inner frame
canvas.AddLine (new Point (1, 2), 8, Orientation.Horizontal, LineStyle.Single);
canvas.AddLine (new Point (8, 2), 3, Orientation.Vertical, LineStyle.Single);
canvas.AddLine (new Point (8, 4), -8, Orientation.Horizontal, LineStyle.Single);
canvas.AddLine (new Point (1, 4), -3, Orientation.Vertical, LineStyle.Single);
string looksLike = @"
┌────────┐
│┌──┐ │
│├──┴───┐│
││ ││
│└──────┘│
└────────┘";
TestHelpers.AssertEqual (output, looksLike, $"{Environment.NewLine}{canvas}");
}
[Fact, SetupFakeDriver]
public void Test_Incomplete_Frame_Start_Left ()
{
var canvas = new LineCanvas ();
canvas.AddLine (new Point (0, 0), 1, Orientation.Vertical, LineStyle.Single);
canvas.AddLine (new Point (0, 0), 1, Orientation.Horizontal, LineStyle.Single);
canvas.AddLine (new Point (1, 0), 9, Orientation.Horizontal, LineStyle.Single);
canvas.AddLine (new Point (9, 0), 5, Orientation.Vertical, LineStyle.Single);
canvas.AddLine (new Point (9, 4), -10, Orientation.Horizontal, LineStyle.Single);
canvas.AddLine (new Point (0, 4), -2, Orientation.Vertical, LineStyle.Single);
string looksLike = @"
┌────────┐
│ │
└────────┘";
TestHelpers.AssertEqual (output, looksLike, $"{Environment.NewLine}{canvas}");
}
[Fact, SetupFakeDriver]
public void Test_Incomplete_Frame_Start_Top ()
{
var canvas = new LineCanvas ();
canvas.AddLine (new Point (0, 0), 1, Orientation.Horizontal, LineStyle.Single);
canvas.AddLine (new Point (5, 0), 5, Orientation.Horizontal, LineStyle.Single);
canvas.AddLine (new Point (9, 0), 5, Orientation.Vertical, LineStyle.Single);
canvas.AddLine (new Point (9, 4), -10, Orientation.Horizontal, LineStyle.Single);
canvas.AddLine (new Point (0, 4), -5, Orientation.Vertical, LineStyle.Single);
string looksLike = @"
┌ ────┐
│ │
│ │
│ │
└────────┘";
TestHelpers.AssertEqual (output, looksLike, $"{Environment.NewLine}{canvas}");
}
[Fact, SetupFakeDriver]
public void Test_Incomplete_Frame_Start_Right ()
{
var canvas = new LineCanvas ();
canvas.AddLine (new Point (0, 0), 10, Orientation.Horizontal, LineStyle.Single);
canvas.AddLine (new Point (9, 0), 1, Orientation.Vertical, LineStyle.Single);
canvas.AddLine (new Point (9, 3), 2, Orientation.Vertical, LineStyle.Single);
canvas.AddLine (new Point (9, 4), -10, Orientation.Horizontal, LineStyle.Single);
canvas.AddLine (new Point (0, 4), -5, Orientation.Vertical, LineStyle.Single);
string looksLike = @"
┌────────┐
│ │
└────────┘";
TestHelpers.AssertEqual (output, looksLike, $"{Environment.NewLine}{canvas}");
}
[Fact, SetupFakeDriver]
public void Test_Incomplete_Frame_Start_Bottom ()
{
var canvas = new LineCanvas ();
canvas.AddLine (new Point (9, 4), -1, Orientation.Vertical, LineStyle.Single);
canvas.AddLine (new Point (9, 4), -1, Orientation.Horizontal, LineStyle.Single);
canvas.AddLine (new Point (4, 4), -5, Orientation.Horizontal, LineStyle.Single);
canvas.AddLine (new Point (0, 4), -5, Orientation.Vertical, LineStyle.Single);
canvas.AddLine (new Point (0, 0), 10, Orientation.Horizontal, LineStyle.Single);
canvas.AddLine (new Point (9, 0), 5, Orientation.Vertical, LineStyle.Single);
string looksLike = @"
┌────────┐
│ │
│ │
│ │
└──── ┘";
TestHelpers.AssertEqual (output, looksLike, $"{Environment.NewLine}{canvas}");
}
[Theory]
[InlineData (0, 0, 1, Orientation.Vertical, 0, 0, 1, "┌")]
[InlineData (0, 0, 1, Orientation.Vertical, 0, 0, -1, "┐")]
[InlineData (0, 0, -1, Orientation.Vertical, 0, 0, 1, "└")]
[InlineData (0, 0, -1, Orientation.Vertical, 0, 0, -1, "┘")]
[InlineData (0, 0, 1, Orientation.Horizontal, 0, 0, 1, "┌")]
[InlineData (0, 0, -1, Orientation.Horizontal, 0, 0, 1, "┐")]
[InlineData (0, 0, 1, Orientation.Horizontal, 0, 0, -1, "└")]
[InlineData (0, 0, -1, Orientation.Horizontal, 0, 0, -1, "┘")]
public void Corner_Tests (int x, int y, int length, Orientation orientation, int x1, int y1, int length1, string looksLike)
{
var canvas = new LineCanvas ();
if (orientation == Orientation.Vertical) {
canvas.AddLine (new Point (x, y), length, Orientation.Vertical, LineStyle.Single);
canvas.AddLine (new Point (x1, y1), length1, Orientation.Horizontal, LineStyle.Single);
} else {
canvas.AddLine (new Point (x, y), length, Orientation.Horizontal, LineStyle.Single);
canvas.AddLine (new Point (x1, y1), length1, Orientation.Vertical, LineStyle.Single);
}
TestHelpers.AssertEqual (output, looksLike, $"{canvas}");
}
}
}