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()); } }
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()); } }
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()); } }
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()); } }
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()); } } }
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()); } } }
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()); } }
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()); } } }
public void EmptyProgramCSharp() { using (var template = new Template(new CSharp(), "", new[] { "using System;" })) { var output = new StringWriter(); { template.Render(output); Assert.AreEqual("", output.ToString()); } } }
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()); } } }
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()); } } }
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()); } } }
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()); } } }
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()); } } }
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()); } } }
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()); } } }
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()); } } }
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()); } } }
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()); } } }
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()); } } }
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()); } } }
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()); } } }
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()); } } }
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()); } } }
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()); } } }
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()); } } }
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()); } } }
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()); } } }
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()); } } }
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()); } } }