Esempio n. 1
0
        public void BreaksTheRightWayWithMultipleParagraphs()
        {
            var breaker = new Breaker(@"This is the first line.

This is the second line, which is actually a paragraph, which happens to be pretty long, although it might/might not have correct punctuation.

The third line is also fairly long, and it has a bunch of CAPITALIZED FILL WORDS: BLA BLA BLA BLA BLA.");

            const int maxWidth = 50;
            var       lines    = breaker.GetLines(maxWidth).ToList();

            PrintLines(lines, maxWidth);

            Assert.That(lines, Is.EqualTo(new[]
            {
                "This is the first line.",
                "",
                "This is the second line, which is actually a",
                "paragraph, which happens to be pretty long,",
                "although it might/might not have correct",
                "punctuation.",
                "",
                "The third line is also fairly long, and it has a",
                "bunch of CAPITALIZED FILL WORDS: BLA BLA BLA BLA",
                "BLA."
            }));
        }
Esempio n. 2
0
        public void DoesNotBreakWhenThereIsNoNeed()
        {
            var breaker = new Breaker("this is a short line");

            var lines = breaker.GetLines(100).ToList();

            Assert.That(lines, Is.EqualTo(new[] { "this is a short line" }));
        }
Esempio n. 3
0
        public void CanBreakBetweenWords()
        {
            //                         0          10         20
            var breaker = new Breaker("this is a short line");

            var lines = breaker.GetLines(10).ToList();

            Assert.That(lines, Is.EqualTo(new[]
            {
                "this is a",
                "short line"
            }));
        }
Esempio n. 4
0
        public void Rearrange(Column column)
        {
            var maxLineLength = column.Width - 2 * column.Padding;

            Lines = Lines
                    .SelectMany(line =>
            {
                var breaker = new Breaker(line);

                return(breaker.GetLines(maxLineLength));
            })
                    .ToArray();
        }
Esempio n. 5
0
        public void WorksWhenTooLongWordIsFirstAndItIsFollowedByAnotherWord()
        {
            var breaker = new Breaker("THISISJUSTTOOLONGTOFITONA LINE");

            const int maxWidth = 20;
            var       lines    = breaker.GetLines(maxWidth).ToList();

            PrintLines(lines, maxWidth);

            Assert.That(lines, Is.EqualTo(new[]
            {
                "THISISJUSTTOOLONGTOF",
                "ITONA LINE"
            }));
        }
Esempio n. 6
0
        public void BreaksTheRightWayWhenWordIsJustTooLong()
        {
            var breaker = new Breaker(@"This is the first line.

This is a line with an artificial too-long word: huifhueihfwiufewlfehwfeliwhfuilewhfuilehwfuilehwfulehwuflewufilehwufilehwuilfhewuifhwe.

This is the third line.");

            const int maxWidth = 60;
            var       lines    = breaker.GetLines(maxWidth).ToList();

            PrintLines(lines, maxWidth);

            Assert.That(lines, Is.EqualTo(new[]
            {
                "This is the first line.",
                "",
                "This is a line with an artificial too-long word:",
                "huifhueihfwiufewlfehwfeliwhfuilewhfuilehwfuilehwfulehwuflewu",
                "filehwufilehwuilfhewuifhwe.",
                "",
                "This is the third line."
            }));
        }