public void TestDocumentRenderingWithConditionalReplacement() { var rendered = new DocumentRenderer().Render("{{if GoodMood}}Hi {{Name!}}!{{if}}", new { Name = "Adam", GoodMood = true }); Assert.AreEqual("Hi Adam", rendered.ToString()); rendered = new DocumentRenderer().Render("{{if GoodMood}}Hi {{Name!}}!{{if}}", new { Name = "Adam", GoodMood = false }); Assert.AreEqual("", rendered.ToString()); }
public void TestDocumentRenderingVarExpression() { var rendered = new DocumentRenderer().Render("{{var first FirstName!}}Hi {{first!}}{{clearvar first!}}", new { FirstName="Adam" }); Assert.AreEqual("Hi Adam", rendered.ToString()); }
public void TestUsagePrimitive() { CommandLineArgumentsDefinition def = new CommandLineArgumentsDefinition(typeof(TestArgs)); var rendered = new DocumentRenderer().Render("Your program has {{Arguments.Count!}} arguments", def); Assert.AreEqual("Your program has 2 arguments", rendered.ToString()); }
public void TestDocumentRenderingWithSimpleReplacement() { var rendered = new DocumentRenderer().Render("Hi {{Name Red!}}! Sup?", new { Name = "Adam" }); Assert.AreEqual("Hi Adam! Sup?", rendered.ToString()); Assert.AreEqual(new ConsoleCharacter('a').ForegroundColor, rendered[0].ForegroundColor); Assert.AreEqual(ConsoleColor.Red, rendered[3].ForegroundColor); Assert.AreEqual(new ConsoleCharacter('a').ForegroundColor, rendered[rendered.Length - 1].ForegroundColor); }
public void TestDocumentRenderingWithNoReplacements() { var rendered = new DocumentRenderer().Render("Hi", 1); Assert.AreEqual("Hi", rendered.ToString()); }
public void TestDocumentRenderingWithEachReplacement() { var rendered = new DocumentRenderer().Render("{{each number in Numbers}}{{number!}}!{{each}}", new { Numbers = new int[] { 1, 2, 3, 4 } }); Assert.AreEqual("1234", rendered.ToString()); }