public void tryToCreateCSharpCodeWith_Class_Method_WithMethodText() { Assert.IsEmpty(csharpFastCompiler.invocationParameters()); Assert.IsTrue(csharpFastCompiler.resolveInvocationParametersType()); var codeSnippet1 = "return 2+2;"; var codeSnippet2 = "return 2+2; BAD CODE"; var codeSnippet3 = "return parameterName;"; var codeSnippet4 = "var a = 2+2; a.str().info();"; //Compile with no Invocation parameters var cSharpCode1 = csharpFastCompiler.tryToCreateCSharpCodeWith_Class_Method_WithMethodText(codeSnippet1).assert_Valid(); var cSharpCode2 = csharpFastCompiler.tryToCreateCSharpCodeWith_Class_Method_WithMethodText(codeSnippet2).assert_Not_Valid(); var cSharpCode3 = csharpFastCompiler.tryToCreateCSharpCodeWith_Class_Method_WithMethodText(codeSnippet3).assert_Valid(); var cSharpCode4 = csharpFastCompiler.tryToCreateCSharpCodeWith_Class_Method_WithMethodText(codeSnippet4).assert_Valid(); csharpFastCompiler.compileSourceCode_Sync(cSharpCode1).assert_Not_Null(); csharpFastCompiler.compileSourceCode_Sync(cSharpCode2).assert_Null(); csharpFastCompiler.compileSourceCode_Sync(cSharpCode3).assert_Null(); csharpFastCompiler.compileSourceCode_Sync(cSharpCode4).assert_Not_Null(); //Check invocation parameters csharpFastCompiler.invocationParameters().Add("parameterName", "parameterValue"); var cSharpCode5 = csharpFastCompiler.tryToCreateCSharpCodeWith_Class_Method_WithMethodText(codeSnippet3); var assembly4 = csharpFastCompiler.compileSourceCode_Sync(cSharpCode5); var firstMethod = assembly4.firstMethod(); var methodParameters = firstMethod.parameters(); var firstParameter = methodParameters.first(); var parameterName = firstParameter.Name; var parameterType = firstParameter.ParameterType.fullName(); Assert.IsTrue(cSharpCode5.valid()); Assert.IsNotNull(assembly4); Assert.IsNotNull(firstMethod); Assert.AreEqual(methodParameters.size(), 1); Assert.IsNotNull(firstParameter); Assert.AreEqual(parameterName, "parameterName"); Assert.AreEqual(parameterType, "System.String"); //Check that return doesn't exist when the last line is a return }