Пример #1
0
        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());
        }
Пример #2
0
 public void TestDocumentRenderingVarExpression()
 {
     var rendered = new DocumentRenderer().Render("{{var first FirstName!}}Hi {{first!}}{{clearvar first!}}", new { FirstName="Adam" });
     Assert.AreEqual("Hi Adam", rendered.ToString());
 }
Пример #3
0
 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());
 }
Пример #4
0
 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);
 }
Пример #5
0
 public void TestDocumentRenderingWithNoReplacements()
 {
     var rendered = new DocumentRenderer().Render("Hi", 1);
     Assert.AreEqual("Hi", rendered.ToString());
 }
Пример #6
0
 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());
 }