예제 #1
0
        public void CreateTestStubForMethodTest()
        {
            CodeMemberMethod codeMemberMethod = null; // TODO: Initialize to an appropriate value

            CodeMethodComposer.CreateTestStubForMethod(codeMemberMethod);
            Assert.Inconclusive("A method that does not return a value cannot be verified.");
        }
예제 #2
0
        public void CreateTestStubForMethodTest()
        {
            var method = new CodeMemberMethod();

            method.Name = "TheMethodName";
            CodeMethodComposer.CreateTestStubForMethod(method);
            var expectedComment = "TODO: Implement unit test for TheMethodName";

            AssertEx.That(
                method.ContainsComment(expectedComment),
                "Comment '{0}' not found in: {1}",
                expectedComment,
                method.ContainsCommentMsg());
            AssertEx.That(
                method.ContainsAttribute("Test"), "Attribute 'Test' not found in: {0}", method.ContainsAttributeMsg());
            AssertEx.That(method.HasReturnTypeOf(typeof(void)));
        }
예제 #3
0
        /// <summary>
        /// Creates a constructor test method.
        /// </summary>
        /// <param name="context">The build context of the test method member.</param>
        /// <param name="methodName">Name of the method.</param>
        /// <param name="testObjectName">Name of the test object.</param>
        /// <param name="createExpr">A <see cref="CodeObjectCreateExpression"/> building the test object.</param>
        /// <returns>A new test method, forming the constructor test.</returns>
        private CodeMemberMethod CreateConstructorTest(
            IMemberBuildContext context,
            string methodName,
            string testObjectName,
            out CodeObjectCreateExpression createExpr)
        {
            var cm = new CustomConstructorCodeMemberMethod
            {
                Name       = methodName,
                Attributes = MemberAttributes.Public | MemberAttributes.Final
            };

            CodeMethodComposer.CreateTestStubForMethod(cm);
            createExpr = this.BuildTestObject(context.TestObjectType.Name, testObjectName, cm);
            context.TestClassDeclaration.Members.Add(cm);
            context.BuildResult.ClassMethodsToAdd.Add(cm);
            return(cm);
        }
예제 #4
0
        public void CreateTestStubForMethodWithEmptyNameThrows()
        {
            var method = new CodeMemberMethod();

            Assert.Throws <ArgumentException>(() => CodeMethodComposer.CreateTestStubForMethod(method));
        }