public bool IsValid(object caller, Condition condition)
        {
            IMember m = GetMember(caller);

            if (m != null)
            {
                return(TestMethod.IsTestMethod(m));
            }
            IClass c = GetClass(caller);

            if (c == null || c.ProjectContent == null || c.ProjectContent.Project == null)
            {
                return(false);
            }
            return(TestClass.IsTestClass(c));
        }
Beispiel #2
0
        /// <summary>
        /// Gets the test methods for the specified class.
        /// </summary>
        static TestMethodCollection GetTestMethods(IClass c)
        {
            TestMethodCollection testMethods = new TestMethodCollection();

            foreach (IMethod method in c.Methods)
            {
                if (TestMethod.IsTestMethod(method))
                {
                    if (!testMethods.Contains(method.Name))
                    {
                        testMethods.Add(new TestMethod(method));
                    }
                }
            }

            // Add base class test methods.
            IClass declaringType = c;

            while (c.BaseClass != null)
            {
                foreach (IMethod method in c.BaseClass.Methods)
                {
                    if (TestMethod.IsTestMethod(method))
                    {
                        BaseTestMethod baseTestMethod = new BaseTestMethod(declaringType, method);
                        TestMethod     testMethod     = new TestMethod(c.BaseClass.Name, baseTestMethod);
                        if (method.IsVirtual)
                        {
                            if (!testMethods.Contains(method.Name))
                            {
                                testMethods.Add(testMethod);
                            }
                        }
                        else
                        {
                            if (!testMethods.Contains(testMethod.Name))
                            {
                                testMethods.Add(testMethod);
                            }
                        }
                    }
                }
                c = c.BaseClass;
            }
            return(testMethods);
        }