示例#1
0
        /// <summary>
        /// Gets the test members for the specified class.
        /// </summary>
        TestMemberCollection GetTestMembers(IClass c)
        {
            TestMemberCollection testMembers = new TestMemberCollection();

            foreach (var member in testFrameworks.GetTestMembersFor(c))
            {
                if (!testMembers.Contains(member.Name))
                {
                    testMembers.Add(member);
                }
            }

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

            while (c.BaseClass != null)
            {
                foreach (var testMember in testFrameworks.GetTestMembersFor(c.BaseClass))
                {
                    BaseTestMember baseTestMethod = new BaseTestMember(declaringType, testMember.Member);
                    TestMember     testMethod     = new TestMember(c.BaseClass, baseTestMethod);
                    if (testMember.Member.IsVirtual)
                    {
                        if (!testMembers.Contains(testMember.Name))
                        {
                            testMembers.Add(testMethod);
                        }
                    }
                    else
                    {
                        if (!testMembers.Contains(testMethod.Name))
                        {
                            testMembers.Add(testMethod);
                        }
                    }
                }
                c = c.BaseClass;
            }

            baseClassesFQNames.Clear();
            foreach (var memberDeclaringClass in testMembers.Select(member => member.DeclaringType).Distinct())
            {
                if (memberDeclaringClass.CompareTo(declaringType) != 0)
                {
                    baseClassesFQNames.Add(memberDeclaringClass.FullyQualifiedName);
                }
            }
            return(testMembers);
        }
示例#2
0
        /// <summary>
        /// Updates the members and class based on the new class
        /// information that has been parsed.
        /// </summary>
        public void UpdateClass(IClass c)
        {
            this.c = c.GetCompoundClass();

            // Remove missing members.
            TestMemberCollection newTestMembers      = GetTestMembers(this.c);
            TestMemberCollection existingTestMembers = TestMembers;

            for (int i = existingTestMembers.Count - 1; i >= 0; --i)
            {
                TestMember member = existingTestMembers[i];
                if (newTestMembers.Contains(member.Name))
                {
                    member.Update(newTestMembers[member.Name].Member);
                }
                else
                {
                    existingTestMembers.RemoveAt(i);
                }
            }

            // Add new members.
            foreach (TestMember member in newTestMembers)
            {
                if (existingTestMembers.Contains(member.Name))
                {
                }
                else
                {
                    existingTestMembers.Add(member);
                }
            }
        }