Esempio n. 1
0
            public void ProcessBeforeInterior(IElement element)
            {
                var declaration = element as IDeclaration;

                if (declaration == null)
                {
                    return;
                }
                CSUnitElementBase testElement = null;

                var declaredElement = declaration.DeclaredElement;
                var typeElement     = declaredElement as ITypeElement;

                if (typeElement != null && IsTestFixture(typeElement))
                {
                    CSUnitTestFixtureElement fixtureElement;

                    if (!myFixtures.ContainsKey(typeElement))
                    {
                        fixtureElement = new CSUnitTestFixtureElement(myProvider, myProject, typeElement.CLRName, myAssemblyPath);
                        myFixtures.Add(typeElement, fixtureElement);
                        myOrders.Add(typeElement, 0);
                    }
                    else
                    {
                        fixtureElement = myFixtures[typeElement];
                    }

                    testElement = fixtureElement;
                    int order = 0;
                    AppendTests(fixtureElement, typeElement.GetSuperTypes(), ref order);
                }


                var typeMember = declaredElement as ITypeMember;

                if (typeMember != null && IsTestMethod(typeMember))
                {
                    ITypeElement type = typeMember.GetContainingType();
                    if (type != null)
                    {
                        CSUnitTestFixtureElement fixtureElement = myFixtures.TryGetValue(type);
                        if (fixtureElement != null)
                        {
                            int order = myOrders.TryGetValue(type) + 1;
                            myOrders[type] = order;
                            testElement    = new CSUnitTestElement(myProvider, fixtureElement, myProject, type.CLRName, typeMember.ShortName, order);
                        }
                    }
                }

                if (testElement == null)
                {
                    return;
                }
                var disposition = new UnitTestElementDisposition(testElement, myFile.ProjectFile, declaration.GetNameDocumentRange().TextRange, declaration.GetDocumentRange().TextRange);

                myConsumer(disposition);
            }
        protected CSUnitElementBase(IUnitTestProvider provider, CSUnitElementBase parent, IProject project, string typeName)
            : base(provider, parent)
        {
            if (project == null && !Shell.Instance.IsTestShell)
            {
                throw new ArgumentNullException("project");
            }
            if (typeName == null)
            {
                throw new ArgumentNullException("typeName");
            }

            if (project != null)
            {
                myProject = new ProjectModelElementEnvoy(project);
            }
            myTypeName = typeName;
        }