internal static string Generate(ParametrizedNode methodToCall, TypeDeclaration parentType, string returnVariableName) { var template = new MethodCallStub(methodToCall, parentType, returnVariableName); var text = template.TransformText(); return text; }
internal static string GenerateConstructorCall(TypeDeclaration parentType) { var instanceVariableName = DetermineInstanceVariableName(parentType); var constructor = DetermineConstructor(parentType); var result = MethodCallStub.Generate(constructor, parentType, instanceVariableName); return(result); }
internal static string Generate(ParametrizedNode methodToCall, TypeDeclaration parentType, string returnVariableName) { var template = new MethodCallStub(methodToCall, parentType, returnVariableName); var text = template.TransformText(); return(text); }
/// <summary> /// Generates the text output of the transformation. /// </summary> /// /// <returns> /// A string representing the generated text output of the text template transformation process. /// </returns> /// /// <remarks> /// The text template transformation process has two steps. In the first step, the text template transformation /// engine creates a class that is named the generated transformation class. In the second step, the engine /// compiles and executes the generated transformation class, to produce the generated text output. The engine /// calls <see cref="TransformText"/> on the compiled generated transformation class to execute the text /// template and generate the text output. /// </remarks> public override string TransformText() { #line 4 "TestMethod.tt" this.Write(" /// <summary>\r\n /// Tests the <c>"); #line default #line hidden #line 5 "TestMethod.tt" this.Write(Method.Name); #line default #line hidden #line 5 "TestMethod.tt" this.Write("</c> method with\r\n /// TODO: write about scenario\r\n /// </summary>\r" + "\n [Test()]\r\n public void "); #line default #line hidden #line 9 "TestMethod.tt" this.Write(Method.Name); #line default #line hidden #line 9 "TestMethod.tt" this.Write("_TODO()\r\n {\r\n"); #line default #line hidden #line 11 "TestMethod.tt" if (NeedsInstance) { #line default #line hidden #line 12 "TestMethod.tt" this.Write(GenerateConstructorCall(ParentType)); #line default #line hidden #line 12 "TestMethod.tt" this.Write("\r\n"); #line default #line hidden #line 13 "TestMethod.tt" } #line default #line hidden #line 14 "TestMethod.tt" this.Write(" Assert.Fail(\"TODO: initialize variable(s)"); #line default #line hidden #line 14 "TestMethod.tt" if (HasReturnValue) { #line default #line hidden #line 15 "TestMethod.tt" this.Write(" and expected value"); #line default #line hidden #line 15 "TestMethod.tt" } #line default #line hidden #line 16 "TestMethod.tt" this.Write("\");\r\n"); #line default #line hidden #line 17 "TestMethod.tt" this.Write(MethodCallStub.Generate(Method, ParentType, "actual")); #line default #line hidden #line 17 "TestMethod.tt" this.Write("\r\n"); #line default #line hidden #line 18 "TestMethod.tt" if (HasReturnValue) { #line default #line hidden #line 19 "TestMethod.tt" this.Write(" "); #line default #line hidden #line 19 "TestMethod.tt" this.Write(DetermineDeclarationForType(ReturnValue)); #line default #line hidden #line 19 "TestMethod.tt" this.Write(" expected = "); #line default #line hidden #line 19 "TestMethod.tt" this.Write(DefaultValue(ReturnValue)); #line default #line hidden #line 19 "TestMethod.tt" this.Write(";\r\n Assert.AreEqual(expected, actual);\r\n"); #line default #line hidden #line 21 "TestMethod.tt" } #line default #line hidden #line 22 "TestMethod.tt" this.Write(" }\r\n"); #line default #line hidden return(this.GenerationEnvironment.ToString()); }