Ejemplo n.º 1
0
        /// <summary>
        /// Updates the test class methods based on the newly parsed class
        /// information.
        /// </summary>
        void UpdateTestClass(IClass c)
        {
            if (TestClasses.Contains(c.DotNetName))
            {
                if (IsTestClass(c))
                {
                    TestClass testClass = TestClasses[c.DotNetName];
                    testClass.UpdateClass(c);
                }
                else
                {
                    // TestFixture attribute has been removed so
                    // remove the class from the set of TestClasses.
                    TestClasses.Remove(c.DotNetName);
                }
            }
            else
            {
                // TestFixture attribute may have been recently added to
                // this class so call AddNewTestClass. No need to
                // check if the class is actually a test class since
                // AddNewTestClass does this anyway.
                AddNewTestClass(c);
            }

            var derivedTestClasses = GetTestClassesDerivedFrom(c);

            if (derivedTestClasses.Any())
            {
                UpdateClassesFromProjectContent(derivedTestClasses);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Updates the classes and methods based on the new parse information.
        /// </summary>
        /// <param name="oldUnit">The old compiliation unit
        /// (ParseInformationEventArgs.ParseInformation.BestCompilationUnit as ICompilationUnit)</param>
        /// <param name="newUnit">The new compilation unit
        /// (ParseInformationEventArgs.CompilationUnit).</param>
        public void UpdateParseInfo(ICompilationUnit oldUnit, ICompilationUnit newUnit)
        {
            if (!IsParseInfoForThisProject(oldUnit, newUnit))
            {
                return;
            }

            RemovedClasses removedClasses = new RemovedClasses();

            if (oldUnit != null)
            {
                removedClasses.Add(oldUnit.Classes);
            }
            if (newUnit != null)
            {
                foreach (IClass c in newUnit.Classes)
                {
                    UpdateTestClass(c);
                    foreach (IClass innerClass in new InnerClassEnumerator(c))
                    {
                        UpdateTestClass(innerClass);
                        removedClasses.Remove(innerClass);
                    }
                    removedClasses.Remove(c);
                }
            }

            // Remove missing classes.
            foreach (IClass c in removedClasses.GetMissingClasses())
            {
                IClass existingClass = GetExistingTestClassInProject(c);
                if (existingClass != null)
                {
                    UpdateTestClass(existingClass);
                }
                else
                {
                    TestClasses.Remove(c.DotNetName);
                }
            }
        }