public void TestRendererCreator() { var p = new TestDfmRendererPartProvider(); var renderer = CustomizedRendererCreator.CreateRenderer( new DfmRenderer(), new[] { p }, null); var engine = DocfxFlavoredMarked .CreateBuilder(".") .CreateDfmEngine(renderer); var result = engine.Markup(@"```cs public void TestRendererCreator() ``` ```cs-x public void TestRendererCreator() ```", "a.md"); Assert.Equal(@"<pre><code class=""lang-cs"">public void TestRendererCreator() </code></pre><pre class=""x""><code class=""lang-cs"">public void TestRendererCreator() </code></pre>".Replace("\r\n", "\n"), result); (renderer as IDisposable).Dispose(); Assert.True(p.CodeRendererPartInstance.Disposed); }
public void TestRendererCreator() { var content = @"namespace ConsoleApplication1 { // <namespace> using System; using System.Collections.Generic; using System.IO; // </namespace> // <snippetprogram> class Program { static void Main(string[] args) { string s = ""\ntest""; int i = 100; } } // </snippetprogram> #region Helper internal static class Helper { #region Foo public static void Foo() { } #endregion Foo } #endregion }"; File.WriteAllText("Program.csdocfx", content.Replace("\r\n", "\n")); var p = new TestDfmRendererPartProvider(); var renderer = CustomizedRendererCreator.CreateRenderer( new DfmRenderer(), new[] { p }, null); var engine = DocfxFlavoredMarked .CreateBuilder(".") .CreateDfmEngine(renderer); var result = engine.Markup(@"```cs public void TestRendererCreator() ``` ```cs-x public void TestRendererCreator() ``` [!code-csdocfx[Main](Program.csdocfx#namespace ""This is root"")] [!code-cs-xyz[](Program.csdocfx#Foo)]", "a.md"); Assert.Equal(@"<pre><code class=""lang-cs"">public void TestRendererCreator() </code></pre><pre class=""x""><code class=""lang-cs"">public void TestRendererCreator() </code></pre><pre><code class=""lang-csdocfx"" name=""Main"" title=""This is root"">using System; using System.Collections.Generic; using System.IO; </code></pre><pre><code class=""lang-cs-xyz"">public static void Foo() { } </code></pre>".Replace("\r\n", "\n"), result); (renderer as IDisposable).Dispose(); Assert.True(p.CodeRendererPartInstance.Disposed); if (File.Exists("Program.csdocfx")) { File.Delete("Program.csdocfx"); } }