Example #1
0
        /// <summary>
        /// Updates the methods and class based on the new class
        /// information that has been parsed.
        /// </summary>
        public void UpdateClass(IClass c)
        {
            this.c = c.GetCompoundClass();

            // Remove missing methods.
            TestMethodCollection newTestMethods      = GetTestMethods(this.c);
            TestMethodCollection existingTestMethods = TestMethods;

            for (int i = existingTestMethods.Count - 1; i >= 0; --i)
            {
                TestMethod method = existingTestMethods[i];
                if (newTestMethods.Contains(method.Name))
                {
                    method.Update(newTestMethods[method.Name].Method);
                }
                else
                {
                    existingTestMethods.RemoveAt(i);
                }
            }

            // Add new methods.
            foreach (TestMethod method in newTestMethods)
            {
                if (existingTestMethods.Contains(method.Name))
                {
                }
                else
                {
                    existingTestMethods.Add(method);
                }
            }
        }
Example #2
0
        /// <summary>
        /// Gets the test methods for the specified class.
        /// </summary>
        TestMethodCollection GetTestMethods(IClass c)
        {
            TestMethodCollection testMethods = new TestMethodCollection();

            foreach (IMethod method in c.Methods)
            {
                if (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 (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);
        }