Ejemplo n.º 1
0
 /// <summary>
 /// Convenience method to create an instance of <see cref="TestMethod"/> initialized with the provided
 /// <paramref name="methodToTest"/> and then execute the template to produce the string representation of the
 /// unit test method.
 /// </summary>
 /// 
 /// <param name="methodToTest">
 /// The <see cref="ParametrizedNode"/> representing the method or constructor for which tests are to be written.
 /// </param>
 /// 
 /// <returns>
 /// The string representation of the source code of the generated method to test
 /// <paramref name="methodToTest"/>.
 /// </returns>
 public static string Generate (ParametrizedNode methodToTest)
 {
     var testMethodGenerator = new TestMethod(methodToTest, (TypeDeclaration)methodToTest.Parent);
     var testMethodCode = testMethodGenerator.TransformText();
     return testMethodCode;
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Generates a string representation of a C# unit test method that tests <paramref name="methodToTest"/>.
 /// </summary>
 /// 
 /// <param name="methodToTest">
 /// A <see cref="ParametrizedNode"/> representing the method for which a test is to be written.
 /// </param>
 /// 
 /// <param name="classUnderTest">
 /// The class in which the method to test is located.
 /// </param>
 /// 
 /// <returns>
 /// A C# NUnit test method stub.
 /// </returns>
 public static string GenerateTestMethod (ParametrizedNode methodToTest, TypeDeclaration classUnderTest)
 {
     var template = new TestMethod (methodToTest, classUnderTest);
     return template.TransformText();
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Generates a string representation of a C# unit test method that tests <paramref name="methodToTest"/>.
        /// </summary>
        ///
        /// <param name="methodToTest">
        /// A <see cref="ParametrizedNode"/> representing the method for which a test is to be written.
        /// </param>
        ///
        /// <param name="classUnderTest">
        /// The class in which the method to test is located.
        /// </param>
        ///
        /// <returns>
        /// A C# NUnit test method stub.
        /// </returns>
        public static string GenerateTestMethod(ParametrizedNode methodToTest, TypeDeclaration classUnderTest)
        {
            var template = new TestMethod(methodToTest, classUnderTest);

            return(template.TransformText());
        }