public void Add_Incorrect_Type_Of_Input_Data_CSharp() { using (var template = new Template(new CSharp(), @"{%while(i > 0){%}*{%i--;}%}", new String[0], new Variable[] { new Variable("i", ArgumentType.Integer) })) using (var output = new StringWriter()) { template.Render(output, "test"); } }
public void Add_Int_Parameter_In_CSharp() { using(var template = new Template(new CSharp(), "{%while(count > 0){%}x{%count--;}%}", new String[0], new Variable[]{ new Variable("count", ArgumentType.Integer)})) using(var output = new StringWriter()) { template.Render(output, 2); Assert.AreEqual("xx", output.ToString()); } }
public void Add_DateTime_Double_In_CSharp() { using(var template = new Template(new CSharp(), @"{%output.Write(n*2);output.Write(time);%}", new String[0], new Variable[] { new Variable("n", ArgumentType.Double), new Variable("time", ArgumentType.DateTime) })) using(var output = new StringWriter()) { template.Render(output, 2.1, DateTime.Now.Date); Assert.AreEqual("4,2" + DateTime.Now.Date.ToString(), output.ToString()); } }
public void Add_Bool_Long_String_Params_In_CSharp() { using(var template = new Template(new CSharp(), @"{%if(action)%}*{%while(count > 0){%}x{%count--;}output.Write(str);%}", new String[0], new Variable[] { new Variable("action", ArgumentType.Boolean), new Variable("count", ArgumentType.Long), new Variable("str", ArgumentType.String) })) using(var output = new StringWriter()) { template.Render(output, true, 2, "test"); Assert.AreEqual("*xxtest", output.ToString()); } }
public void Check_Setting_Of_Parameters_If_Params_Doesnt_Set() { using(var template = new Template(new CSharp(), "", new String[0], new Variable[] {new Variable("n", ArgumentType.Integer)})) using(var output = new StringWriter()) { template.Render(output); } }
public void Can_Pass_Long_Java() { using (var template = new Template(new Java(), @"{%=l%}", new String[0], new Variable("l", ArgumentType.Long))) using (var output = new StringWriter()) { template.Render(output, 301923091203213); Assert.AreEqual("301923091203213", output.ToString()); } }
public void Can_Handle_Simple_Words_In_Java() { using (var template = new Template(new Java(), @"testik", new String[0])) using (var output = new StringWriter()) { template.Render(output); Assert.AreEqual("testik", output.ToString()); } }
public void If_Empty_With_Spaces_Output_For_Variables() { using (var template = new Template(new CSharp(), "{%= %}", new String[0])) using (var output = new StringWriter()) { template.Render(output); } }
public void Can_Identify_Code_Sequence_Java() { using (var template = new Template(new Java(), "{%output.write(String.valueOf(\"From sequence\"));%}", new String[0])) using (var output = new StringWriter()) { template.Render(output); Assert.AreEqual("From sequence", output.ToString()); } }
public void Can_Identify_Two_Boolean_Sequence() { using (var template = new Template(new CSharp(), @"{%?s.Equals(""TEST"")%}TRUE{%?%}{%?test%}!{%?%}", new String[0], new Variable("test", ArgumentType.Boolean), new Variable("s", ArgumentType.String))) using (var output = new StringWriter()) { template.Render(output, true, "TEST"); Assert.AreEqual("TRUE!", output.ToString()); } }
public void If_Empty_Boolean_Sequence() { using (var template = new Template(new CSharp(), @"{%?%}{%?%}", new String[0])) using (var output = new StringWriter()) { template.Render(output); } }
public void Can_Identify_Output_For_Variables() { using (var template = new Template(new CSharp(), "{%=i%} and {%= str %} or {%= time%}", new String[0], new Variable("i", ArgumentType.Integer), new Variable("str", ArgumentType.String), new Variable("time", ArgumentType.DateTime))) using (var output = new StringWriter()) { template.Render(output, 10, "TEST", DateTime.Now.Date); Assert.AreEqual("10 and TEST or " + DateTime.Now.Date, output.ToString()); } }
public void Can_Identify_Simple_String() { using (var template = new Template(new CSharp(), "aba", new String[0])) using (var output = new StringWriter()) { template.Render(output); Assert.AreEqual("aba", output.ToString()); } }
public void Can_Identify_Nested_Loop_Sequence() { using (var template = new Template(new CSharp(), "{%@n%}<{%@ n + m %}*{%@%}>{%@%}", new String[0], new Variable("n", ArgumentType.Integer), new Variable("m", ArgumentType.Integer))) using (var output = new StringWriter()) { template.Render(output, 2, 2); Assert.AreEqual("<****><****>", output.ToString()); } }
public void Can_Identify_Loop_And_Code_Sequences() { using (var template = new Template(new CSharp(), "hi{%if(testBool){%}{%@n%}<>{%@%}{%}%}", new String[0], new Variable("testBool", ArgumentType.Boolean), new Variable("n", ArgumentType.Integer))) using (var output = new StringWriter()) { template.Render(output, true, 1); Assert.AreEqual("hi<>", output.ToString()); } }
public void Can_Identify_False_Loop_Sequence() { using (var template = new Template(new CSharp(), "{%@n%}<{%@ds%}>{%@%}", new String[0], new Variable("n", ArgumentType.Integer), new Variable("ds",ArgumentType.String))) using (var output = new StringWriter()) { template.Render(output, 2, 3); } }
public void Check_Setting_Of_Parameters_If_Variables_Doesnt_Set() { using (var template = new Template(new CSharp(), "", new String[0])) using (var output = new StringWriter()) { template.Render(output, 1); } }
public void Can_Identify_Two_Loop_Sequence() { using (var template = new Template(new CSharp(), "{%@i%}x{%@%} or {%@j%}y{%@%}", new String[0], new Variable("i", ArgumentType.Integer), new Variable("j", ArgumentType.Integer))) using (var output = new StringWriter()) { template.Render(output, 1, 2); Assert.AreEqual("x or yy", output.ToString()); } }
public void Check_That_Code_Doesnt_Contain_False_Code_Sequence() { using(var template = new Template(new CSharp(),"%{%%}%}", new String[0])) using(var output = new StringWriter()) { template.Render(output); } }
public void If_Pass_Empty_String() { using(Template template = new Template(new Java(), "", new String[0])) using(var output = new StringWriter()) { template.Render(output); Assert.AreEqual("", output.ToString()); } }
public void If_Empty_Loop_Sequence() { using (var template = new Template(new CSharp(), "{%@%}{%@%}", new String[0])) using (var output = new StringWriter()) { template.Render(output, true); } }
public void Incorrect_CSharp_Template_Code() { using(var template = new Template(new CSharp(), "{%}", new String[0])) using(var output = new StringWriter()) { template.Render(output); } }
public void If_Loop_Sequence_Has_Input_Params_Without_Declaration() { using (var template = new Template(new CSharp(), "{%@%}sd{%@%}", new String[0], new Variable("n", ArgumentType.Integer))) using (var output = new StringWriter()) { template.Render(output, 1); } }
public void Can_Identify_Bool_Sequence_Java() { using (var template = new Template(new Java(), @"{%?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 If_Pass_False_Argument() { using (var template = new Template(new Java(), @"{%?%}{%?%}", new String[0])) using (var output = new StringWriter()) { template.Render(output, "TEST"); } }
public void Can_Parse_Two_Custom_Texts() { using(var template = new Template(new CSharp(),"hi{%%}test",new String[0])) using(var output = new StringWriter()) { template.Render(output); Assert.AreEqual("hitest", output.ToString()); } }
public void Server_Can_Compile_Sequences() { using (var template = new Template(new Java(), "{% fo%}{%r(int i = 0; i < 5; i++){ %}*{%}%}", new String[0])) using (var output = new StringWriter()) { template.Render(output); Assert.AreEqual("*****", output.ToString()); } }
public void Can_Pass_Boolean_Java() { using (var template = new Template(new Java(), @"{%=b%}", new String[0], new Variable("b", ArgumentType.Boolean))) using (var output = new StringWriter()) { template.Render(output, false); Assert.AreEqual("false", output.ToString()); } }
public void Can_Pass_Double_Java() { using (var template = new Template(new Java(), @"{%=d%}", new String[0], new Variable("d", ArgumentType.Double))) using (var output = new StringWriter()) { template.Render(output, 1.2); Assert.AreEqual("1.2", output.ToString()); } }
public void Can_Handle_Error_Java() { using (var template = new Template(new Java(), @"{%@%}{%@%}", new String[0])) using (var output = new StringWriter()) { template.Render(output); } }