Ejemplo n.º 1
0
        public void GetLinesFromOneOrMoreBlockTest()
        {
            int patternLength = 4;
            var pattern = new string('\0', patternLength);
            LineBuilder builder = new LineBuilder(pattern, null);
            string text = "a";
            var textBlock = new TextBlock(text);
            OneOrMoreBlock oneOrMoreBlock = new OneOrMoreBlock(textBlock);

            List<string> lines = builder.GetLinesFromOneOrMoreBlock(0, oneOrMoreBlock).ToList();

            Assert.AreEqual(patternLength, lines.Count);
            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < patternLength; i++)
            {
                sb.Append(text);
                Assert.AreEqual(sb.ToString(), lines[i]);
            }

            TextBlock aBlock = new TextBlock("a");
            TextBlock bBlock = new TextBlock("b");
            OrGroupBlock orGroupBlock = new OrGroupBlock(new[] { aBlock, bBlock });
            oneOrMoreBlock = new OneOrMoreBlock(orGroupBlock);
            lines = builder.GetLinesFromOneOrMoreBlock(0, oneOrMoreBlock).ToList();
            Assert.AreEqual(30, lines.Count);
        }