public void TextProcessing_TestCase_001() { const string text = "0123456789\n0123456789"; var sut = new ConControls.Controls.Text.ConsoleTextController { Width = 5, WrapMode = WrapMode.SimpleWrap, Text = text }; sut.BufferLineCount.Should().Be(6); sut.MaxLineLength.Should().Be(5); sut.Text.Should().Be(text); sut.Width.Should().Be(5); sut.WrapMode.Should().Be(WrapMode.SimpleWrap); sut.GetLineLength(-1).Should().Be(0); sut.GetLineLength(0).Should().Be(5); sut.GetLineLength(1).Should().Be(5); sut.GetLineLength(2).Should().Be(0); sut.GetLineLength(3).Should().Be(5); sut.GetLineLength(4).Should().Be(5); sut.GetLineLength(5).Should().Be(0); sut.GetCharacters(new Rectangle(Point.Empty, new Size(5, 6))) .Should() .Equal( '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '\0', '\0', '\0', '\0', '\0', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '\0', '\0', '\0', '\0', '\0'); sut.GetCharacters(new Rectangle(2, 2, 7, 2)) .Should() .Equal( '\0', '\0', '\0', '\0', '\0', '\0', '\0', '2', '3', '4', '\0', '\0', '\0', '\0'); sut.WrapMode = WrapMode.NoWrap; sut.Width = 4; sut.BufferLineCount.Should().Be(2); sut.MaxLineLength.Should().Be(10); sut.Text.Should().Be(text); sut.Width.Should().Be(4); sut.WrapMode.Should().Be(WrapMode.NoWrap); sut.GetLineLength(-1).Should().Be(0); sut.GetLineLength(0).Should().Be(10); sut.GetLineLength(1).Should().Be(10); sut.GetLineLength(2).Should().Be(0); sut.GetCharacters(new Rectangle(3, 1, 10, 2)) .Should() .Equal( '3', '4', '5', '6', '7', '8', '9', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0'); }
public void Append_TestCase_001() { const string text = "01234\r\n56\n\r\n789\n012345678"; var sut = new ConControls.Controls.Text.ConsoleTextController { Width = 5, WrapMode = WrapMode.SimpleWrap, Text = text }; sut.BufferLineCount.Should().Be(7); sut.GetLineLength(0).Should().Be(5); sut.GetLineLength(1).Should().Be(0); sut.GetLineLength(2).Should().Be(2); sut.GetLineLength(3).Should().Be(0); sut.GetLineLength(4).Should().Be(3); sut.GetLineLength(5).Should().Be(5); sut.GetLineLength(6).Should().Be(4); sut.Append(text); sut.Text.Should().Be(text + text); sut.BufferLineCount.Should().Be(13); sut.MaxLineLength.Should().Be(5); sut.GetLineLength(0).Should().Be(5); sut.GetLineLength(1).Should().Be(0); sut.GetLineLength(2).Should().Be(2); sut.GetLineLength(3).Should().Be(0); sut.GetLineLength(4).Should().Be(3); sut.GetLineLength(5).Should().Be(5); sut.GetLineLength(6).Should().Be(5); sut.GetLineLength(7).Should().Be(4); sut.GetLineLength(8).Should().Be(2); sut.GetLineLength(9).Should().Be(0); sut.GetLineLength(10).Should().Be(3); sut.GetLineLength(11).Should().Be(5); sut.GetLineLength(12).Should().Be(4); sut.GetCharacters(new Rectangle(Point.Empty, new Size(5, 13))) .Should() .Equal( '0', '1', '2', '3', '4', '\0', '\0', '\0', '\0', '\0', '5', '6', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '7', '8', '9', '\0', '\0', '0', '1', '2', '3', '4', '5', '6', '7', '8', '0', '1', '2', '3', '4', '\0', '5', '6', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '7', '8', '9', '\0', '\0', '0', '1', '2', '3', '4', '5', '6', '7', '8', '\0' ); }
public void TextProcessing_RequestingAreaWithNegativeSize_Empty() { const string text = "01234\r\n01234"; var sut = new ConControls.Controls.Text.ConsoleTextController { Width = 5, WrapMode = WrapMode.SimpleWrap, Text = text }; sut.GetCharacters(new Rectangle(Point.Empty, new Size(-1, 1))) .Should() .BeEmpty(); sut.GetCharacters(new Rectangle(Point.Empty, new Size(1, -1))) .Should() .BeEmpty(); sut.GetCharacters(new Rectangle(Point.Empty, new Size(-1, -1))) .Should() .BeEmpty(); }
public void TextProcessing_TestCase_002() { const string text = "01234\r\n01234"; var sut = new ConControls.Controls.Text.ConsoleTextController { Width = 5, WrapMode = WrapMode.SimpleWrap, Text = text }; sut.GetCharacters(new Rectangle(Point.Empty, new Size(6, 4))) .Should() .Equal( '0', '1', '2', '3', '4', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '0', '1', '2', '3', '4', '\0', '\0', '\0', '\0', '\0', '\0', '\0'); }