Beispiel #1
0
        protected MSTestElementBase(IUnitTestProvider provider, MSTestElementBase 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;
        }
Beispiel #2
0
            public void ProcessBeforeInterior(IElement element)
            {
                var declaration = element as IDeclaration;

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

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

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

                    if (!myFixtures.ContainsKey(typeElement))
                    {
                        fixtureElement = new MSTestFixtureElement(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)
                    {
                        MSTestFixtureElement fixtureElement = myFixtures[type];
                        if (fixtureElement != null)
                        {
                            int order = myOrders[type] + 1;
                            myOrders[type] = order;
                            testElement    = new MSTestElement(myProvider, fixtureElement, myProject, type.CLRName,
                                                               typeMember.ShortName, order);
                        }
                    }
                }

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

                myConsumer(disposition);
            }