Files
Terminal.Gui/Tests/UnitTests/Drawing/RulerTests.cs
Copilot ed64f5773e Fixes #4282 - Migrate tests from UnitTests to UnitTests.Parallelizable (67 tests migrated + comprehensive documentation) (#4293)
* Initial plan

* Add 31 parallelizable LineCanvas unit tests

Co-authored-by: tig <585482+tig@users.noreply.github.com>

* Add 4 parallelizable Ruler unit tests

Co-authored-by: tig <585482+tig@users.noreply.github.com>

* Complete Category A migration - 35 tests migrated

Co-authored-by: tig <585482+tig@users.noreply.github.com>

* Remove duplicate tests from UnitTests after migration to Parallelizable

Co-authored-by: tig <585482+tig@users.noreply.github.com>

* Migrate 6 pure unit tests from ColorPicker and DatePicker to Parallelizable

Co-authored-by: tig <585482+tig@users.noreply.github.com>

* Fix duplicate test names between UnitTests and Parallelizable

Co-authored-by: tig <585482+tig@users.noreply.github.com>

* Migrate 11 Label tests to Parallelizable (52 tests total)

Co-authored-by: tig <585482+tig@users.noreply.github.com>

* Fix documentation: SetupFakeDriver tests CAN be parallelized

Co-authored-by: tig <585482+tig@users.noreply.github.com>

* Add comprehensive parallelization rules to documentation

Co-authored-by: tig <585482+tig@users.noreply.github.com>

* Update README and start migrating Button/CheckBox/RadioGroup tests

Co-authored-by: tig <585482+tig@users.noreply.github.com>

* Remove duplicate Button tests from UnitTests

Co-authored-by: tig <585482+tig@users.noreply.github.com>

* Migrate 5 CheckBox unit tests to Parallelizable (27 with Theory expansion)

Co-authored-by: tig <585482+tig@users.noreply.github.com>

* Migrate 4 more CheckBox tests to Parallelizable (67 tests total, 9,478 passing)

Co-authored-by: tig <585482+tig@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: tig <585482+tig@users.noreply.github.com>
Co-authored-by: Tig <tig@users.noreply.github.com>
2025-10-19 19:04:43 -06:00

143 lines
2.7 KiB
C#

using UnitTests;
using Xunit.Abstractions;
namespace Terminal.Gui.DrawingTests;
public class RulerTests
{
private readonly ITestOutputHelper _output;
public RulerTests (ITestOutputHelper output) { _output = output; }
[Fact]
[AutoInitShutdown]
public void Draw_Default ()
{
AutoInitShutdownAttribute.FakeResize(new Size(25, 25));
var r = new Ruler ();
r.Draw (Point.Empty);
DriverAssert.AssertDriverContentsWithFrameAre (@"", _output);
}
[Fact]
[SetupFakeDriver]
public void Draw_Horizontal ()
{
var len = 15;
var r = new Ruler ();
Assert.Equal (Orientation.Horizontal, r.Orientation);
r.Length = len;
r.Draw (Point.Empty);
DriverAssert.AssertDriverContentsWithFrameAre (
@"
|123456789|1234",
_output
);
// Postive offset
r.Draw (new (1, 1));
DriverAssert.AssertDriverContentsAre (
@"
|123456789|1234
|123456789|1234
",
_output
);
// Negative offset
r.Draw (new (-1, 3));
DriverAssert.AssertDriverContentsAre (
@"
|123456789|1234
|123456789|1234
123456789|1234
",
_output
);
}
[Fact]
[SetupFakeDriver]
public void Draw_Vertical ()
{
var len = 15;
var r = new Ruler ();
r.Orientation = Orientation.Vertical;
r.Length = len;
r.Draw (Point.Empty);
DriverAssert.AssertDriverContentsWithFrameAre (
@"
-
1
2
3
4
5
6
7
8
9
-
1
2
3
4",
_output
);
r.Draw (new (1, 1));
DriverAssert.AssertDriverContentsWithFrameAre (
@"
-
1-
21
32
43
54
65
76
87
98
-9
1-
21
32
43
4",
_output
);
// Negative offset
r.Draw (new (2, -1));
DriverAssert.AssertDriverContentsWithFrameAre (
@"
- 1
1-2
213
324
435
546
657
768
879
98-
-91
1-2
213
324
43
4 ",
_output
);
}
}