public CSharp() { parser = new CSharpTemplateParser(); compiler = new CSharpCodeCompiler(); ArgumentType.SetCSharpTypes(); }
public void Can_Add_CSharp_Assemblies_In_Code() { var code = "StringBuilder sb = new StringBuilder(\"test\");" + "sb.Remove(3,1);output.Write(sb.ToString());"; using(var compiler = new CSharpCodeCompiler()) using(var output = new StringWriter()) { compiler.Compile(code, output, new String[1] { "System.Text" }); Assert.AreEqual("tes", output.ToString()); } }
public void If_Add_Non_Existent_Assembly() { using(var compiler = new CSharpCodeCompiler()) using(var output = new StringWriter()) { compiler.Compile("output.Write(\"s\"", output, new String[] { "ololo" }); } }
public void If_Code_For_Compiler_Is_Incorrect() { using(var compiler = new CSharpCodeCompiler()) using(var output = new StringWriter()) { compiler.Compile("INCORRECT;", output, new String[0]); } }
public void Can_Compile_CSharp_Code() { using(var compiler = new CSharpCodeCompiler()) using(var output = new StringWriter()) { compiler.Compile("output.Write(\"hi\");", output, new String[0], new Variable[0]); Assert.AreEqual("hi", output.ToString()); } }