Example #1
0
 public static void PrintAssertExpected(string source, string result, string expected)
 {
     Console.WriteLine("```````````````````Source");
     Console.WriteLine(DisplaySpaceAndTabs(source));
     Console.WriteLine("```````````````````Result");
     Console.WriteLine(DisplaySpaceAndTabs(result));
     Console.WriteLine("```````````````````Expected");
     Console.WriteLine(DisplaySpaceAndTabs(expected));
     Console.WriteLine("```````````````````");
     Console.WriteLine();
     TextAssert.AreEqual(expected, result);
 }
Example #2
0
        public void TestStringLineGroupSimple()
        {
            var text = new StringLineGroup(4)
            {
                new StringSlice("ABC"),
                new StringSlice("E"),
                new StringSlice("F")
            };

            var iterator = text.ToCharIterator();

            Assert.AreEqual("ABC\nE\nF".Length, iterator.End - iterator.Start + 1);

            var chars = ToString(text.ToCharIterator());

            TextAssert.AreEqual("ABC\nE\nF", chars.ToString());
        }
Example #3
0
        private static void Check(string text, string expectedResult, string extensions = null)
        {
            var pipelineBuilder = new MarkdownPipelineBuilder().UsePreciseSourceLocation();

            if (extensions != null)
            {
                pipelineBuilder.Configure(extensions);
            }
            var pipeline = pipelineBuilder.Build();

            var document = Markdown.Parse(text, pipeline);

            var build = new StringBuilder();

            foreach (var val in document.Descendants())
            {
                var name = GetTypeName(val.GetType());
                build.Append($"{name,-12} ({val.Line,2},{val.Column,2}) {val.Span.Start,2}-{val.Span.End}\n");
                var attributes = val.TryGetAttributes();
                if (attributes != null)
                {
                    build.Append($"{"attributes",-12} ({attributes.Line,2},{attributes.Column,2}) {attributes.Span.Start,2}-{attributes.Span.End}\n");
                }
            }
            var result = build.ToString().Trim();

            expectedResult = expectedResult.Trim();
            expectedResult = expectedResult.Replace("\r\n", "\n").Replace("\r", "\n");

            if (expectedResult != result)
            {
                Console.WriteLine("```````````````````Source");
                Console.WriteLine(TestParser.DisplaySpaceAndTabs(text));
                Console.WriteLine("```````````````````Result");
                Console.WriteLine(result);
                Console.WriteLine("```````````````````Expected");
                Console.WriteLine(expectedResult);
                Console.WriteLine("```````````````````");
                Console.WriteLine();
            }

            TextAssert.AreEqual(expectedResult, result);
        }
Example #4
0
        public void TestStringLineGroupWithTrim()
        {
            var line1 = new StringSlice("  ABC  ");

            line1.NextChar();
            line1.NextChar();

            var line2 = new StringSlice("  DEF ");

            var text = new StringLineGroup(4)
            {
                line1, line2
            }.ToCharIterator();

            text.TrimStart();

            var result = ToString(text);

            TextAssert.AreEqual("ABC  \n  DEF ", result);
        }
Example #5
0
        public void TestStringLineGroupWithSlices()
        {
            var text = new StringLineGroup(4)
            {
                new StringSlice("XABC")
                {
                    Start = 1
                },
                new StringSlice("YYE")
                {
                    Start = 2
                },
                new StringSlice("ZZZF")
                {
                    Start = 3
                }
            };

            var chars = ToString(text.ToCharIterator());

            TextAssert.AreEqual("ABC\nE\nF", chars.ToString());
        }