|
|
@@ -15,113 +15,6 @@ public class TextFormatterTests
|
|
|
public static IEnumerable<object []> CMGlyphs =>
|
|
|
new List<object []> { new object [] { $"{Glyphs.LeftBracket} Say Hello 你 {Glyphs.RightBracket}", 16, 15 } };
|
|
|
|
|
|
- [SetupFakeDriver]
|
|
|
- [Theory]
|
|
|
- [InlineData ("A", 0, "")]
|
|
|
- [InlineData ("A", 1, "A")]
|
|
|
- [InlineData ("A", 2, "A")]
|
|
|
- [InlineData ("A", 3, " A")]
|
|
|
- [InlineData ("AB", 1, "A")]
|
|
|
- [InlineData ("AB", 2, "AB")]
|
|
|
- [InlineData ("ABC", 3, "ABC")]
|
|
|
- [InlineData ("ABC", 4, "ABC")]
|
|
|
- [InlineData ("ABC", 5, " ABC")]
|
|
|
- [InlineData ("ABC", 6, " ABC")]
|
|
|
- [InlineData ("ABC", 9, " ABC")]
|
|
|
- public void Draw_Horizontal_Centered (string text, int width, string expectedText)
|
|
|
- {
|
|
|
- TextFormatter tf = new ()
|
|
|
- {
|
|
|
- Text = text,
|
|
|
- Alignment = Alignment.Center
|
|
|
- };
|
|
|
-
|
|
|
- tf.ConstrainToWidth = width;
|
|
|
- tf.ConstrainToHeight = 1;
|
|
|
- tf.Draw (new (0, 0, width, 1), Attribute.Default, Attribute.Default);
|
|
|
-
|
|
|
- DriverAssert.AssertDriverContentsWithFrameAre (expectedText, _output);
|
|
|
- }
|
|
|
-
|
|
|
- [SetupFakeDriver]
|
|
|
- [Theory]
|
|
|
- [InlineData ("A", 0, "")]
|
|
|
- [InlineData ("A", 1, "A")]
|
|
|
- [InlineData ("A", 2, "A")]
|
|
|
- [InlineData ("A B", 3, "A B")]
|
|
|
- [InlineData ("A B", 1, "A")]
|
|
|
- [InlineData ("A B", 2, "A")]
|
|
|
- [InlineData ("A B", 4, "A B")]
|
|
|
- [InlineData ("A B", 5, "A B")]
|
|
|
- [InlineData ("A B", 6, "A B")]
|
|
|
- [InlineData ("A B", 10, "A B")]
|
|
|
- [InlineData ("ABC ABC", 10, "ABC ABC")]
|
|
|
- public void Draw_Horizontal_Justified (string text, int width, string expectedText)
|
|
|
- {
|
|
|
- TextFormatter tf = new ()
|
|
|
- {
|
|
|
- Text = text,
|
|
|
- Alignment = Alignment.Fill
|
|
|
- };
|
|
|
-
|
|
|
- tf.ConstrainToWidth = width;
|
|
|
- tf.ConstrainToHeight = 1;
|
|
|
- tf.Draw (new (0, 0, width, 1), Attribute.Default, Attribute.Default);
|
|
|
-
|
|
|
- DriverAssert.AssertDriverContentsWithFrameAre (expectedText, _output);
|
|
|
- }
|
|
|
-
|
|
|
- [SetupFakeDriver]
|
|
|
- [Theory]
|
|
|
- [InlineData ("A", 0, "")]
|
|
|
- [InlineData ("A", 1, "A")]
|
|
|
- [InlineData ("A", 2, "A")]
|
|
|
- [InlineData ("AB", 1, "A")]
|
|
|
- [InlineData ("AB", 2, "AB")]
|
|
|
- [InlineData ("ABC", 3, "ABC")]
|
|
|
- [InlineData ("ABC", 4, "ABC")]
|
|
|
- [InlineData ("ABC", 6, "ABC")]
|
|
|
- public void Draw_Horizontal_Left (string text, int width, string expectedText)
|
|
|
-
|
|
|
- {
|
|
|
- TextFormatter tf = new ()
|
|
|
- {
|
|
|
- Text = text,
|
|
|
- Alignment = Alignment.Start
|
|
|
- };
|
|
|
-
|
|
|
- tf.ConstrainToWidth = width;
|
|
|
- tf.ConstrainToHeight = 1;
|
|
|
- tf.Draw (new (0, 0, width, 1), Attribute.Default, Attribute.Default);
|
|
|
-
|
|
|
- DriverAssert.AssertDriverContentsWithFrameAre (expectedText, _output);
|
|
|
- }
|
|
|
-
|
|
|
- [SetupFakeDriver]
|
|
|
- [Theory]
|
|
|
- [InlineData ("A", 0, "")]
|
|
|
- [InlineData ("A", 1, "A")]
|
|
|
- [InlineData ("A", 2, " A")]
|
|
|
- [InlineData ("AB", 1, "B")]
|
|
|
- [InlineData ("AB", 2, "AB")]
|
|
|
- [InlineData ("ABC", 3, "ABC")]
|
|
|
- [InlineData ("ABC", 4, " ABC")]
|
|
|
- [InlineData ("ABC", 6, " ABC")]
|
|
|
- public void Draw_Horizontal_Right (string text, int width, string expectedText)
|
|
|
- {
|
|
|
- TextFormatter tf = new ()
|
|
|
- {
|
|
|
- Text = text,
|
|
|
- Alignment = Alignment.End
|
|
|
- };
|
|
|
-
|
|
|
- tf.ConstrainToWidth = width;
|
|
|
- tf.ConstrainToHeight = 1;
|
|
|
-
|
|
|
- tf.Draw (new (Point.Empty, new (width, 1)), Attribute.Default, Attribute.Default);
|
|
|
- DriverAssert.AssertDriverContentsWithFrameAre (expectedText, _output);
|
|
|
- }
|
|
|
-
|
|
|
[SetupFakeDriver]
|
|
|
[Theory]
|
|
|
[InlineData ("A", 1, 0, "")]
|