Ejemplo n.º 1
0
 public void TestMethod2()
 {
     using (var template = new Template(new CSharp(), "[% for%][%(int i = 0; i < 5; i++){ %] *[%}%]", new String[0]))
     using (var output = new StringWriter())
     {
         template.Render(output);
         Assert.AreEqual(" * * * * *", output.ToString());
     }
 }
Ejemplo n.º 2
0
 public void TestMethod4()
 {
     using (var template = new Template(new CSharp(), "[%@n%] <[%@ n + m %] *[%@%] >[%@%]", new String[0], new Variable("n", ArgumentType.Int32), new Variable("m", ArgumentType.Int32)))
     using (var output = new StringWriter())
     {
         template.Render(output, 2, 1);
         Assert.AreEqual(" < * * * > < * * * >", output.ToString());
     }
 }
Ejemplo n.º 3
0
 public void TestMethod1()
 {
     using (var template = new Template(new CSharp(), "abcd", new String[0]))
     using (var output = new StringWriter())
     {
         template.Render(output);
         Assert.AreEqual("abcd", output.ToString());
     }
 }
Ejemplo n.º 4
0
 public void TestMethod5()
 {
     using (var template = new Template(new CSharp(), @"[%?s.Equals(""TEST"")%]TRUE[%@3%] ![%@%][%?%]", new String[0], new Variable("s", ArgumentType.String)))
     using (var output = new StringWriter())
     {
         template.Render(output, "TEST");
          Assert.AreEqual("TRUE ! ! !", output.ToString());
     }
 }
Ejemplo n.º 5
0
        public void TextSurroundsConstructionJava()
        {
            using (var template = new Template(new Java(), "Text1 [% System.out.println(m); %] Text2", new[] { "import java.lang.System;" }, new Variable("m", ArgumentType.String)))
            {
                var output = new StringWriter();
                {
                    template.Render(output, "Hello!");

                    Assert.AreEqual("Text1 Hello!\r\n Text2", output.ToString());
                }
            }
        }
Ejemplo n.º 6
0
        public void EmptyProgramJava()
        {
            using (var template = new Template(new Java(), "", new[] { "import java.lang.System;" }))
            {
                var output = new StringWriter();
                {
                    template.Render(output);

                    Assert.AreEqual("", output.ToString());
                }
            }
        }
Ejemplo n.º 7
0
 public void TestLongUnicodeString()
 {
     var buffer = new StringBuilder();
     for (int i = Char.MinValue; i <= Char.MaxValue; i++) buffer.Append((char)i);
     var text = String.Join("", Enumerable.Repeat(buffer.ToString(), 4));
     using (var template = new Template(new CSharp(), text, new String[0]))
     using (var output = new StringWriter())
     {
         template.Render(output);
         Assert.AreEqual(text, output.ToString());
     }
 }
Ejemplo n.º 8
0
        public void CheckingForNestingWithoutTextJava()
        {
            using (var template = new Template(new Java(), "Text1 [% System.out.println(m); %] text2 [%= 1 + 5 %]   [%= 7 + 5 %]", new[] { "import java.lang.System;" }, new Variable("m", ArgumentType.String)))
            {
                var output = new StringWriter();
                {
                    template.Render(output, "Hello!");

                    Assert.AreEqual("Text1 Hello!\r\n text2 612", output.ToString());
                }
            }
        }
Ejemplo n.º 9
0
        public void EmptyProgramCSharp()
        {
            using (var template = new Template(new CSharp(), "", new[] { "using System;" }))
            {
                var output = new StringWriter();
                {
                    template.Render(output);

                    Assert.AreEqual("", output.ToString());
                }
            }
        }
Ejemplo n.º 10
0
        public void CheckingMoreLogicalConstructionsWithTextCSharp()
        {
            using (var template = new Template(new CSharp(), "[%? 10 > 2 %] hello [%? 1 < 2 %] yes", new[] { "using System;" }))
            {
                var output = new StringWriter();
                {
                    template.Render(output);

                    Assert.AreEqual(" hello  yes", output.ToString());
                }
            }
        }
Ejemplo n.º 11
0
        public void CheckingLogicalConstructionsCSharp()
        {
            using (var template = new Template(new CSharp(), "[%? true %] hello", new[] { "using System;" }))
            {
                var output = new StringWriter();
                {
                    template.Render(output);

                    Assert.AreEqual(" hello", output.ToString());
                }
            }
        }
Ejemplo n.º 12
0
        public void WorkExpressionsCSharp()
        {
            using (var template = new Template(new CSharp(), "[%= 2 + 1 %]", new[] { "using System;" }))
            {
                var output = new StringWriter();
                {
                    template.Render(output);

                    Assert.AreEqual("3", output.ToString());
                }
            }
        }
Ejemplo n.º 13
0
        public void CheckLoopWithVariablesJava()
        {
            using (var template = new Template(new Java(), "[%@n%] < [%@ n + m %] *", new[] { "import java.lang.System;" }, new Variable("n", ArgumentType.@int), new Variable("m", ArgumentType.@int)))
            {
                var output = new StringWriter();
                {
                    template.Render(output, 2, 1);

                    Assert.AreEqual(" <  <  * * *", output.ToString());
                }
            }
        }
Ejemplo n.º 14
0
        public void CheckTypeDoubleCSharp()
        {
            using (var template = new Template(new CSharp(), "[% System.Console.Write(n); %]", new[] { "using System;" }, new Variable("n", ArgumentType.Double)))
            {
                var output = new StringWriter();
                {
                    template.Render(output, 1.2345);

                    Assert.AreEqual("1,2345", output.ToString());
                }
            }
        }
Ejemplo n.º 15
0
        public void CheckLoopWithVariablesCSharp()
        {
            using (var template = new Template(new CSharp(), "[%@n%] < [%@ n + m %] *", new[] { "using System;" }, new Variable("n", ArgumentType.Int32), new Variable("m", ArgumentType.Int32)))
            {
                var output = new StringWriter();
                {
                    template.Render(output, 2, 1);

                    Assert.AreEqual(" <  <  * * *", output.ToString());
                }
            }
        }
Ejemplo n.º 16
0
        public void CheckMoreExpressionsWithVariablesCSharp()
        {
            using (var template = new Template(new CSharp(), "[%@ a + b %] [% System.Console.Write(a + b); %]", new[] { "using System;" }, new Variable("a", ArgumentType.Int32), new Variable("b", ArgumentType.Int32)))
            {
                var output = new StringWriter();
                {
                    template.Render(output, 1, 2);

                    Assert.AreEqual("333", output.ToString());
                }
            }
        }
Ejemplo n.º 17
0
        public void CheckingForNestingWithoutTextCSharp()
        {
            using (var template = new Template(new CSharp(), "Text1 [% System.Console.WriteLine(m); %] text2 [%= 1 + 5 %]   [%= 7 + 5 %]", new[] { "using System;" }, new Variable("m", ArgumentType.String)))
            {
                var output = new StringWriter();
                {
                    template.Render(output, "Hello!");

                    Assert.AreEqual("Text1 Hello!\r\n text2 612", output.ToString());
                }
            }
        }
Ejemplo n.º 18
0
        public void CheckForKeyDesignCodeJava()
        {
            using (var template = new Template(new Java(), "[% System.out.print(\"[%\"); %]", new[] { "import java.lang.System;" }))
            {
                var output = new StringWriter();
                {
                    template.Render(output);

                    Assert.AreEqual("[%", output.ToString());
                }
            }
        }
Ejemplo n.º 19
0
        public void CheckTypeBooleanJava()
        {
            using (var template = new Template(new Java(), "[% System.out.print(n); %]", new[] { "import java.lang.System;" }, new Variable("n", ArgumentType.@boolean)))
            {
                var output = new StringWriter();
                {
                    template.Render(output, true);

                    Assert.AreEqual("true", output.ToString());
                }
            }
        }
Ejemplo n.º 20
0
        public void ChackOutputTextJava()
        {
            using (var template = new Template(new Java(), "Hello!!!", new[] { "import java.lang.System;" }))
            {
                var output = new StringWriter();
                {
                    template.Render(output);

                    Assert.AreEqual("Hello!!!", output.ToString());
                }
            }
        }
Ejemplo n.º 21
0
        public void CheckStructureInteractionCSharp()
        {
            using (var template = new Template(new CSharp(), "test [% System.Console.Write(a + b); %] [%@ a + b %] [%@ a + b + 2 %] [% System.Console.Write(a + b); %]", new[] { "using System;" }, new Variable("a", ArgumentType.Int32), new Variable("b", ArgumentType.Int32)))
            {
                var output = new StringWriter();
                {
                    template.Render(output, 1, 2);

                    Assert.AreEqual("test 3333333333333333", output.ToString());
                }
            }
        }
Ejemplo n.º 22
0
        public void CheckForKeyDesignCodeCSharp()
        {
            using (var template = new Template(new CSharp(), "[% System.Console.Write(\"[%\"); %]", new[] { "using System;" }))
            {
                var output = new StringWriter();
                {
                    template.Render(output);

                    Assert.AreEqual("[%", output.ToString());
                }
            }
        }
Ejemplo n.º 23
0
        public void ChackOutputTextCSharp()
        {
            using (var template = new Template(new CSharp(), "Hello!!!", new[] { "using System;" }))
            {
                var output = new StringWriter();
                {
                    template.Render(output);

                    Assert.AreEqual("Hello!!!", output.ToString());
                }
            }
        }
Ejemplo n.º 24
0
        public void CheckTypeBooleanCSharp()
        {
            using (var template = new Template(new CSharp(), "[% System.Console.Write(n); %]", new[] { "using System;" }, new Variable("n", ArgumentType.Boolean)))
            {
                var output = new StringWriter();
                {
                    template.Render(output, true);

                    Assert.AreEqual("True", output.ToString());
                }
            }
        }
Ejemplo n.º 25
0
        public void CheckingForMultipleKeyStructuresInTheCodeCSharp()
        {
            using (var template = new Template(new CSharp(), "[% System.Console.Write(\"[%\"); %] [% System.Console.Write(\"[%\"); %]", new[] { "using System;" }))
            {
                var output = new StringWriter();
                {
                    template.Render(output);

                    Assert.AreEqual("[%[%", output.ToString());
                }
            }
        }
Ejemplo n.º 26
0
        public void CheckStructureInteractionJava()
        {
            using (var template = new Template(new Java(), "test [% System.out.print(a + b); %] [%@ a + b %] [%@ a + b + 2 %] [% System.out.print(a + b); %]", new[] { "import java.lang.System;" }, new Variable("a", ArgumentType.@int), new Variable("b", ArgumentType.@int)))
            {
                var output = new StringWriter();
                {
                    template.Render(output, 1, 2);

                    Assert.AreEqual("test 3333333333333333", output.ToString());
                }
            }
        }
Ejemplo n.º 27
0
        public void CheckForSingleLoopCSharp()
        {
            using (var template = new Template(new CSharp(), "[%@3 %][% System.Console.Write(\"Hello!\"); %]", new[] { "using System;" }))
            {
                var output = new StringWriter();
                {
                    template.Render(output);

                    Assert.AreEqual("Hello!Hello!Hello!", output.ToString());
                }
            }
        }
Ejemplo n.º 28
0
        public void MultipleLoopsCodeCSharp()
        {
            using (var template = new Template(new CSharp(), "[%@ 2 + 1 %] text [% System.Console.Write(\"Hello!\"); %] [%@2 + 2 %] end", new[] { "using System;" }))
            {
                var output = new StringWriter();
                {
                    template.Render(output);

                    Assert.AreEqual(" text  text  text Hello! end end end end", output.ToString());
                }
            }
        }
Ejemplo n.º 29
0
        public void CheckingTypicalConstructionCSharp()
        {
            using (var template = new Template(new CSharp(), "Text1 [% System.Console.WriteLine(m); %]", new[] { "using System;" }, new Variable("m", ArgumentType.String)))
            {
                var output = new StringWriter();
                {
                    template.Render(output, "Hello!");

                    Assert.AreEqual("Text1 Hello!\r\n", output.ToString());
                }
            }
        }
Ejemplo n.º 30
0
        public void CheckMoreExpressionsWithVariablesJava()
        {
            using (var template = new Template(new Java(), "[%@ a + b %] [% System.out.print(a + b); %]", new[] { "import java.lang.System;" }, new Variable("a", ArgumentType.@int), new Variable("b", ArgumentType.@int)))
            {
                var output = new StringWriter();
                {
                    template.Render(output, 1, 2);

                    Assert.AreEqual("333", output.ToString());
                }
            }
        }