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); }
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()); }
public void TestStringLineGroupWithModifiedStart() { var line1 = new StringSlice(" ABC"); line1.NextChar(); line1.NextChar(); var line2 = new StringSlice(" DEF "); line2.Trim(); var text = new StringLineGroup(4) {line1, line2}; var result = ToString(text.ToCharIterator()); TextAssert.AreEqual("ABC\nDEF", result); }
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()); }
public static void TestSpec(string inputText, string expectedOutputText, MarkdownPipeline pipeline) { // Uncomment this line to get more debug information for process inlines. //pipeline.DebugLog = Console.Out; var result = Markdown.ToHtml(inputText, pipeline); result = Compact(result); expectedOutputText = Compact(expectedOutputText); Console.WriteLine("```````````````````Source"); Console.WriteLine(DisplaySpaceAndTabs(inputText)); Console.WriteLine("```````````````````Result"); Console.WriteLine(DisplaySpaceAndTabs(result)); Console.WriteLine("```````````````````Expected"); Console.WriteLine(DisplaySpaceAndTabs(expectedOutputText)); Console.WriteLine("```````````````````"); Console.WriteLine(); TextAssert.AreEqual(expectedOutputText, result); }
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); }
public void TestStringLineGroupWithTrim() { var line1 = new StringSlice(" ABC ", NewLine.LineFeed); 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); }
public static void TestSpec(string inputText, string expectedOutputText, string extensions = null) { foreach (var pipeline in GetPipeline(extensions)) { Console.WriteLine($"Pipeline configured with extensions: {pipeline.Key}"); // Uncomment this line to get more debug information for process inlines. //pipeline.DebugLog = Console.Out; var result = Markdown.ToHtml(inputText, pipeline.Value); result = Compact(result); expectedOutputText = Compact(expectedOutputText); Console.WriteLine("```````````````````Source"); Console.WriteLine(DisplaySpaceAndTabs(inputText)); Console.WriteLine("```````````````````Result"); Console.WriteLine(DisplaySpaceAndTabs(result)); Console.WriteLine("```````````````````Expected"); Console.WriteLine(DisplaySpaceAndTabs(expectedOutputText)); Console.WriteLine("```````````````````"); Console.WriteLine(); TextAssert.AreEqual(expectedOutputText, result); } }