public void Explore(IProject project, IMetadataAssembly assembly, IUnitTestElementsObserver consumer, IMetadataTypeInfo metadataTypeInfo)
        {
            if (!metadataTypeInfo.IsContext())
            {
                return;
            }

            ContextElement contextElement = this._factories.Contexts.CreateContext(project, assembly.Location.FullPath, metadataTypeInfo);

            consumer.OnUnitTestElement(contextElement);

            metadataTypeInfo.GetSpecifications()
            .ForEach(x =>
            {
                var contextSpecificationElement = this._factories.ContextSpecifications.CreateContextSpecification(contextElement, x);
                consumer.OnUnitTestElement(contextSpecificationElement);
            });

            metadataTypeInfo.GetBehaviors().ForEach(x =>
            {
                var behaviorElement = this._factories.Behaviors.CreateBehavior(contextElement, x);
                consumer.OnUnitTestElement(behaviorElement);

                this._factories.BehaviorSpecifications
                .CreateBehaviorSpecificationsFromBehavior(behaviorElement, x)
                .ForEach(consumer.OnUnitTestElement);

                consumer.OnUnitTestElementChanged(behaviorElement);
            });

            consumer.OnUnitTestElementChanged(contextElement);
        }
Example #2
0
        public FileExplorer(MSpecUnitTestProvider provider,
                            ElementFactories factories,
                            IFile file,
                            IUnitTestElementsObserver consumer,
                            Func <bool> interrupted)
        {
            if (file == null)
            {
                throw new ArgumentNullException("file");
            }

            if (provider == null)
            {
                throw new ArgumentNullException("provider");
            }

            this._consumer    = consumer;
            this._file        = file;
            this._interrupted = interrupted;

            var project = file.GetSourceFile().ToProjectFile().GetProject();

            this._assemblyPath = project.GetOutputFilePath().FullPath;

            this._elementHandlers = new List <IElementHandler>
            {
                new ContextElementHandler(factories),
                new ContextSpecificationElementHandler(factories),
                new BehaviorElementHandler(factories)
            };
        }
        public void ExploreProjects(IDictionary<IProject, FileSystemPath> projects, MetadataLoader loader, IUnitTestElementsObserver observer)
        {
            var silverlightProjects = projects.Where(p => p.Key.IsSilverlight()).ToDictionary(p => p.Key, p => p.Value);

            this.metadataElementsSource.ExploreProjects(silverlightProjects, loader, observer, this.ExploreAssembly);
            observer.OnCompleted();
        }
        public FileExplorer(MSpecUnitTestProvider provider,
                            ElementFactories factories,
                            IFile file,
                            IUnitTestElementsObserver consumer,
                            Func<bool> interrupted)
        {
            if (file == null)
            {
                throw new ArgumentNullException("file");
            }

            if (provider == null)
            {
                throw new ArgumentNullException("provider");
            }

            this._consumer = consumer;
            this._file = file;
            this._interrupted = interrupted;

            var project = file.GetSourceFile().ToProjectFile().GetProject();

            this._assemblyPath = project.GetOutputFilePath().FullPath;

            this._elementHandlers = new List<IElementHandler>
                         {
                           new ContextElementHandler(factories),
                           new ContextSpecificationElementHandler(factories),
                           new BehaviorElementHandler(factories)
                         };
        }
Example #5
0
        public void ProcessFile(IFile psiFile, IUnitTestElementsObserver observer, Func <bool> interrupted)
        {
            var factory  = new UnitTestElementFactory();
            var explorer = new FileExplorer(factory, observer, interrupted);

            psiFile.ProcessDescendants(explorer);
        }
Example #6
0
 public MspecPsiFileExplorer(SearchDomainFactory searchDomainFactory, UnitTestElementFactory factory, IUnitTestElementsObserver observer, Func <bool> interrupted)
 {
     _searchDomainFactory = searchDomainFactory;
     _factory             = factory;
     _observer            = observer;
     _interrupted         = interrupted;
 }
        public void Explore(IProject project, IMetadataAssembly assembly, IUnitTestElementsObserver observer, CancellationToken cancellationToken)
        {
            // TODO: ILMerge / embedded reference
            //if (!referencedAssemblies.Any(x => x.StartsWith("TestFx")))
            var frameworkPrefix      = typeof(IRootRunner).Assembly.GetName().Name;
            var referencedAssemblies = assembly.ReferencedAssembliesNames.Select(x => x.Name);

            if (!referencedAssemblies.Any(x => x.StartsWith(frameworkPrefix)))
            {
                return;
            }

            using (ReadLockCookie.Create())
            {
                var testAssembly = assembly.ToTestAssembly(project, notInterrupted: () => !cancellationToken.IsCancellationRequested);
                if (testAssembly == null)
                {
                    return;
                }

                var testElements    = testAssembly.TestMetadatas.Select(_testElementFactory.GetOrCreateClassTestElementRecursively);
                var allTestElements = testElements.SelectMany(x => x.DescendantsAndSelf(y => y.Children)).ToList();
                foreach (var testElement in allTestElements)
                {
                    observer.OnUnitTestElement(testElement);
                    observer.OnUnitTestElementChanged(testElement);
                }
                observer.OnCompleted();
            }
        }
Example #8
0
 public FileExplorer(UnitTestElementFactory factory, IUnitTestElementsObserver observer, Func <bool> interrupted)
 {
     _factory     = factory;
     _observer    = observer;
     _factory     = factory;
     _observer    = observer;
     _interrupted = interrupted;
 }
        public void ExploreFile(IFile psiFile, IUnitTestElementsObserver observer, Func<bool> interrupted)
        {
            if (!IsProjectFile(psiFile)) return;

            var explorer = new MspecTestFileExplorer(_provider, _elementFactories);
            explorer.ExploreFile(psiFile, observer, interrupted);
            observer.OnCompleted();
        }
        public void ExploreFile(IFile psiFile, IUnitTestElementsObserver observer, Func<bool> interrupted)
        {
            if (!IsProjectFile(psiFile)) return;

            var elementFactory = new UnitTestElementFactory(services, observer.OnUnitTestElementChanged);
            psiFile.ProcessDescendants(new XunitPsiFileExplorer(elementFactory, observer, psiFile, interrupted, searchDomainFactory));
            observer.OnCompleted();
        }
 public void ExploreAssembly(IProject project, IMetadataAssembly assembly, IUnitTestElementsObserver consumer)
 {
     using (ReadLockCookie.Create()) //Get a read lock so that it is safe to read the assembly
     {
         foreach (var metadataTypeInfo in GetTypesIncludingNested(assembly.GetTypes()))
             this._assemblyExplorer.Explore(project, assembly, consumer, metadataTypeInfo);
     }
 }
Example #12
0
 public void ExploreProjects(
     [NotNull] IDictionary <IProject, FileSystemPath> projects,
     [NotNull] MetadataLoader loader,
     [NotNull] IUnitTestElementsObserver observer,
     CancellationToken cancellationToken)
 {
     _metadataElementsSource.ExploreProjects(projects, loader, observer, _testMetadataExplorer.Explore, cancellationToken);
     observer.OnCompleted();
 }
 public void ExploreAssembly(
     IProject project, 
     IMetadataAssembly assembly, 
     IUnitTestElementsObserver observer,
     CancellationToken cancellationToken)
 {
     var environment = new ExecutionEnvironment(assembly.Location.FullPath);
     var methodGroups = environment.DiscoverTestMethodGroups(null);
 }
 public void ExploreFile(IFile psiFile, IUnitTestElementsObserver observer, Func<bool> interrupted)
 {
     if (psiFile.GetProject().IsSilverlight())
     {
         if (!string.Equals(psiFile.Language.Name, "CSHARP", StringComparison.Ordinal) && !string.Equals(psiFile.Language.Name, "VBASIC", StringComparison.Ordinal) || psiFile.GetSourceFile().ToProjectFile() == null)
             return;
         this.RunWithElementFactory(elementFactory => psiFile.ProcessDescendants(new MsTestFileExplorer(elementFactory, this.msTestAttributesProvider, observer, psiFile, interrupted)));
     }
 }
        public void ProcessFile(IFile psiFile, IUnitTestElementsObserver observer, Func <bool> interrupted)
        {
            var factory  = new UnitTestElementFactory(_serviceProvider, observer.TargetFrameworkId);
            var explorer = new MspecPsiFileExplorer(_searchDomainFactory, factory, observer, interrupted);

            psiFile.ProcessDescendants(explorer);

            observer.OnCompleted();
        }
Example #16
0
 public UnityTestsExploration(UnitTestAttributeCache unitTestAttributeCache, IProject project,
                              IUnitTestElementsObserver observer, IUnitTestElementIdFactory unitTestElementIdFactory,
                              UnityTestProvider unityTestProvider, IUnitTestElementManager unitTestElementManager, UnityNUnitServiceProvider serviceProvider)
 {
     myUnitTestAttributeCache = unitTestAttributeCache;
     myProject           = project;
     myUnitTestCollector = observer;
     myElementFactory    = new UnityTestElementFactory(unitTestElementIdFactory, unityTestProvider, unitTestElementManager, serviceProvider);
 }
 public void ExploreProjects(
     IDictionary<IProject, FileSystemPath> projects, 
     MetadataLoader loader, 
     IUnitTestElementsObserver observer,
     CancellationToken cancellationToken)
 {
     var explorer = new FixieMetadataExplorer();
     metadataElementsSource.ExploreProjects(projects, loader, observer, explorer.ExploreAssembly, cancellationToken);
     observer.OnCompleted();
 }
Example #18
0
 public void ExploreAssembly(IProject project, IMetadataAssembly assembly, IUnitTestElementsObserver consumer)
 {
     using (ReadLockCookie.Create()) //Get a read lock so that it is safe to read the assembly
     {
         foreach (var metadataTypeInfo in GetTypesIncludingNested(assembly.GetTypes()))
         {
             this._assemblyExplorer.Explore(project, assembly, consumer, metadataTypeInfo);
         }
     }
 }
 public override void ProcessProject(IProject project, FileSystemPath assemblyPath, MetadataLoader loader,
                                     IUnitTestElementsObserver observer, CancellationToken token)
 {
     MetadataElementsSource.ExploreProject(project, assemblyPath, loader, observer, myLogger, token,
                                           metadataAssembly =>
     {
         var exploration = new UnityTestsExploration(myUnitTestAttributeCache, project, observer, myUnitTestElementIdFactory, myUnityTestProvider, myUnitTestElementManager, myServiceProvider);
         exploration.Explore(metadataAssembly, token);
     });
 }
 public UnityTestFileExplorer(IFile file, UnityTestElementFactory factory, UnitTestAttributeCache unitTestAttributeCache,
                              IUnitTestElementsObserver observer, Func <bool> interrupted, IProject project)
 {
     myFile    = file;
     myFactory = factory;
     myUnitTestAttributeCache = unitTestAttributeCache;
     myObserver          = observer;
     myInterrupted       = interrupted;
     myProject           = project;
     myTargetFrameworkId = myProject.GetCurrentTargetFrameworkId();
 }
Example #21
0
 public void Explore(IProject project, IMetadataAssembly assembly, IUnitTestElementsObserver observer)
 {
     Explore(
       project,
       assembly,
       x =>
       {
     observer.OnUnitTestElement(x);
     observer.OnUnitTestElementChanged(x);
       },
       () => true);
 }
        public void ExploreFile(IFile psiFile, IUnitTestElementsObserver observer, Func <bool> interrupted)
        {
            if (!IsProjectFile(psiFile))
            {
                return;
            }

            var elementFactory = new UnitTestElementFactory(services, observer.OnUnitTestElementChanged);

            psiFile.ProcessDescendants(new XunitPsiFileExplorer(elementFactory, observer, psiFile, interrupted, searchDomainFactory));
            observer.OnCompleted();
        }
 public void Explore(IProject project, IMetadataAssembly assembly, IUnitTestElementsObserver observer, CancellationToken cancellationToken)
 {
     Explore(
         project,
         assembly,
         x =>
     {
         observer.OnUnitTestElement(x);
         observer.OnUnitTestElementChanged(x);
     },
         notInterrupted: () => !cancellationToken.IsCancellationRequested);
 }
Example #24
0
 public void Explore(IProject project, IMetadataAssembly assembly, IUnitTestElementsObserver observer)
 {
     Explore(
         project,
         assembly,
         x =>
     {
         observer.OnUnitTestElement(x);
         observer.OnUnitTestElementChanged(x);
     },
         () => true);
 }
 public void Explore(IProject project, IMetadataAssembly assembly, IUnitTestElementsObserver observer, CancellationToken cancellationToken)
 {
     Explore(
       project,
       assembly,
       x =>
       {
     observer.OnUnitTestElement(x);
     observer.OnUnitTestElementChanged(x);
       },
       notInterrupted: () => !cancellationToken.IsCancellationRequested);
 }
Example #26
0
        public void ExploreFile(IFile psiFile, IUnitTestElementsObserver observer, Func <bool> interrupted)
        {
            if (!IsProjectFile(psiFile))
            {
                return;
            }

            var explorer = new MspecTestFileExplorer(_provider, _elementFactories);

            explorer.ExploreFile(psiFile, observer, interrupted);
            observer.OnCompleted();
        }
        public void ExploreAssembly(IProject project, IMetadataAssembly assembly, IUnitTestElementsObserver observer, CancellationToken cancellationToken)
        {
            using (ReadLockCookie.Create())
            {
                foreach (var metadataTypeInfo in GetExportedTypes(assembly.GetTypes()))
                {
                    if (cancellationToken.IsCancellationRequested)
                        break;

                    ExploreType(project, assembly, observer, metadataTypeInfo);
                }
            }
        }
Example #28
0
 public void ProcessFile(IFile psiFile, IUnitTestElementsObserver observer, Func <bool> interrupted)
 {
     _testFileExplorer.Explore(
         psiFile,
         x =>
     {
         // TODO: ask Jenya
         observer.OnUnitTestElementDisposition(x);
         observer.OnUnitTestElementChanged(x.UnitTestElement);
     },
         () => !interrupted());
     observer.OnCompleted();
 }
 // TODO: The nunit code uses UnitTestAttributeCache
 public XunitPsiFileExplorer(UnitTestElementFactory unitTestElementFactory,
                             IUnitTestElementsObserver observer, IFile file,
                             Func <bool> interrupted, SearchDomainFactory searchDomainFactory)
 {
     this.observer = observer;
     this.unitTestElementFactory = unitTestElementFactory;
     this.file                = file;
     this.interrupted         = interrupted;
     this.searchDomainFactory = searchDomainFactory;
     projectFile              = file.GetSourceFile().ToProjectFile();
     project      = file.GetProject();
     assemblyPath = project.GetOutputFilePath().FullPath;
 }
Example #30
0
        private void ExploreType(IProject project, IMetadataAssembly assembly, IUnitTestElementsObserver observer, IMetadataTypeInfo metadataTypeInfo)
        {
            // It would be nice to use TestClassCommandFactory.Make(...), but that doesn't work
            // with RunWith, since Make ends up calling TypeUtility.GetRunWith, which tries to
            // call IAttributeInfo.GetInstance<RunWithAttribute>, and we can't support that.
            // So we'll break down Make and do it ourselves. If the runner finds any methods
            // that we don't find, it will create them at runtime
            var typeInfo = metadataTypeInfo.AsTypeInfo();

            if (TypeUtility.IsTestClass(typeInfo))
            {
                ExploreTestClass(project, assembly, observer, typeInfo, metadataTypeInfo.FullyQualifiedName);
            }
        }
        public void ExploreFile(IFile psiFile, IUnitTestElementsObserver consumer, Func<bool> interrupted)
        {
            if (psiFile == null)
                throw new ArgumentNullException("psiFile");

            var project = psiFile.GetProject();
            if (project == null)
                return;

            if ((psiFile.Language.Name == "CSHARP") || (psiFile.Language.Name == "VBASIC"))
            {
                psiFile.ProcessDescendants(new FileExplorer(_provider, _factories, psiFile, consumer, interrupted));
            }
        }
        private void ExploreTestClass(IProject project, IMetadataAssembly assembly, IUnitTestElementsObserver observer, ITypeInfo typeInfo, string typeName)
        {
            var classUnitTestElement = unitTestElementFactory.GetOrCreateTestClass(project, new ClrTypeName(typeName), assembly.Location.FullPath, typeInfo.GetTraits());
            observer.OnUnitTestElement(classUnitTestElement);

            // Don't create elements for [Fact] methods when the class has [RunWith]. This
            // is because we don't know what the RunWith will do - it might not pay any
            // attention to [Fact], and if we create the elements now, they won't be
            // dynamic, and that can cause issues later
            if (!TypeUtility.HasRunWith(typeInfo))
            {
                foreach (var methodInfo in TypeUtility.GetTestMethods(typeInfo))
                    ExploreTestMethod(project, classUnitTestElement, observer, methodInfo);
            }
        }
        public override void ProcessProject(
            IProject project,
            FileSystemPath assemblyPath,
            MetadataLoader loader,
            IUnitTestElementsObserver observer,
            CancellationToken token)
        {
            var factory  = new UnitTestElementFactory(_serviceProvider, observer.TargetFrameworkId);
            var explorer = new MspecTestMetadataExplorer(factory, observer);

            MetadataElementsSource.ExploreProject(project, assemblyPath, loader, observer, _logger, token,
                                                  assembly => explorer.ExploreAssembly(project, assembly, token));

            observer.OnCompleted();
        }
Example #34
0
        public void ExploreAssembly(IProject project, IMetadataAssembly assembly, IUnitTestElementsObserver observer, CancellationToken cancellationToken)
        {
            using (ReadLockCookie.Create())
            {
                foreach (var metadataTypeInfo in GetExportedTypes(assembly.GetTypes()))
                {
                    if (cancellationToken.IsCancellationRequested)
                    {
                        break;
                    }

                    ExploreType(project, assembly, observer, metadataTypeInfo);
                }
            }
        }
Example #35
0
 public override void ProcessProject(
     [NotNull] IProject project,
     [NotNull] FileSystemPath assemblyPath,
     [NotNull] MetadataLoader loader,
     [NotNull] IUnitTestElementsObserver observer,
     CancellationToken token)
 {
     MetadataElementsSource.ExploreProject(
         project,
         assemblyPath,
         loader,
         observer,
         _logger,
         token,
         metadataAssembly => _testMetadataExplorer.Explore(project, metadataAssembly, observer, token));
     observer.OnCompleted();
 }
Example #36
0
        private void ExploreTestClass(IProject project, IMetadataAssembly assembly, IUnitTestElementsObserver observer, ITypeInfo typeInfo, string typeName)
        {
            var classUnitTestElement = unitTestElementFactory.GetOrCreateTestClass(project, new ClrTypeName(typeName), assembly.Location.FullPath, typeInfo.GetTraits());

            observer.OnUnitTestElement(classUnitTestElement);

            // Don't create elements for [Fact] methods when the class has [RunWith]. This
            // is because we don't know what the RunWith will do - it might not pay any
            // attention to [Fact], and if we create the elements now, they won't be
            // dynamic, and that can cause issues later
            if (!TypeUtility.HasRunWith(typeInfo))
            {
                foreach (var methodInfo in TypeUtility.GetTestMethods(typeInfo))
                {
                    ExploreTestMethod(project, classUnitTestElement, observer, methodInfo);
                }
            }
        }
Example #37
0
        public void ExploreFile(IFile psiFile, IUnitTestElementsObserver consumer, Func <bool> interrupted)
        {
            if (psiFile == null)
            {
                throw new ArgumentNullException("psiFile");
            }

            var project = psiFile.GetProject();

            if (project == null)
            {
                return;
            }

            if ((psiFile.Language.Name == "CSHARP") || (psiFile.Language.Name == "VBASIC"))
            {
                psiFile.ProcessDescendants(new FileExplorer(_provider, _factories, psiFile, consumer, interrupted));
            }
        }
Example #38
0
        public void ProcessFile(IFile psiFile, IUnitTestElementsObserver observer, Func <bool> interrupted)
        {
            if (!myClrLanguagesKnown.AllLanguages.Any(language => Equals(language, psiFile.Language)))
            {
                return;
            }

            // external sources case.
            var projectFile = psiFile.GetSourceFile().ToProjectFile();

            if (projectFile == null)
            {
                return;
            }

            var factory      = new UnityTestElementFactory(myIdFactory, myUnityTestProvider, myUnitTestElementManager, myServiceProvider);
            var fileExplorer = new UnityTestFileExplorer(psiFile, factory, myUnitTestAttributeCache, observer, interrupted, projectFile.GetProject());

            psiFile.ProcessDescendants(fileExplorer);
        }
        public void Explore(IProject project, IMetadataAssembly assembly, IUnitTestElementsObserver consumer, IMetadataTypeInfo metadataTypeInfo)
        {
            if (!metadataTypeInfo.IsContext())
            {
                return;
            }

            var contextElement = this._factories.Contexts.CreateContext(project, assembly.Location.FullPath, metadataTypeInfo);

            consumer.OnUnitTestElement(contextElement);

            metadataTypeInfo.GetSpecifications()
                .ForEach(x =>
                {
                    var element = this._factories.ContextSpecifications.CreateContextSpecification(contextElement, x);
                    consumer.OnUnitTestElement(element);
                    consumer.OnUnitTestElementChanged(element);
                });


            metadataTypeInfo.GetBehaviors().ForEach(x =>
            {
                var behaviorElement = this._factories.Behaviors.CreateBehavior(contextElement, x);
                consumer.OnUnitTestElement(behaviorElement);
                consumer.OnUnitTestElementChanged(behaviorElement);


                this._factories.BehaviorSpecifications
                            .CreateBehaviorSpecificationsFromBehavior(behaviorElement, x)
                            .ForEach(y =>
                            {
                                consumer.OnUnitTestElement(y);
                                consumer.OnUnitTestElementChanged(y);
                            });
            });
        }
Example #40
0
 public MetadataExplorer(UnitTestElementFactory factory, IUnitTestElementsObserver observer)
 {
     _factory  = factory;
     _observer = observer;
 }
 private void ExploreTestMethod(IProject project, XunitTestClassElement classUnitTestElement, IUnitTestElementsObserver observer, IMethodInfo methodInfo)
 {
     var methodUnitTestElement = unitTestElementFactory.GetOrCreateTestMethod(project, classUnitTestElement, new ClrTypeName(methodInfo.TypeName), methodInfo.Name,
         MethodUtility.GetSkipReason(methodInfo), methodInfo.GetTraits(), false);
     observer.OnUnitTestElement(methodUnitTestElement);
 }
Example #42
0
        private void ExploreTestMethod(IProject project, XunitTestClassElement classUnitTestElement, IUnitTestElementsObserver observer, IMethodInfo methodInfo)
        {
            var methodUnitTestElement = unitTestElementFactory.GetOrCreateTestMethod(project, classUnitTestElement, new ClrTypeName(methodInfo.TypeName), methodInfo.Name,
                                                                                     MethodUtility.GetSkipReason(methodInfo), methodInfo.GetTraits(), false);

            observer.OnUnitTestElement(methodUnitTestElement);
        }
 protected override void ExploreAssembly(IProject testProject, IMetadataAssembly metadataAssembly, IUnitTestElementsObserver add)
 {
     GetMetdataExplorer().ExploreAssembly(testProject, metadataAssembly, add, CancellationToken.None);
 }
 public void ExploreProjects(IDictionary<IProject, FileSystemPath> projects, MetadataLoader loader, IUnitTestElementsObserver observer)
 {
     var explorer = new MSpecTestMetadataExplorer(_provider, _assemblyExplorer);
     _metadataElementsSource.ExploreProjects(projects, loader, observer, explorer.ExploreAssembly);
     observer.OnCompleted();
 }
 public void ExploreSolution(IUnitTestElementsObserver observer)
 {
 }
        public void ProcessFile(
            IFile psiFile,
            IUnitTestElementsObserver observer,
            Func <bool> interrupted)
        {
            if (!(psiFile is GherkinFile gherkinFile))
            {
                return;
            }

            var project = psiFile.GetProject();

            if (project == null)
            {
                return;
            }

            var projectFile = gherkinFile.GetSourceFile().ToProjectFile();

            if (projectFile == null)
            {
                return;
            }

            var projectTests = _unitTestElementRepository.Query()
                               .Where(t => t.Id.Project.Guid == project.Guid)
                               .ToList();

            var featureCsFile = GetRelatedFeatureFile(psiFile);

            if (featureCsFile == null)
            {
                return;
            }

            var relatedTests = projectTests.Where(t => t.GetProjectFiles()?.Contains(featureCsFile) == true).ToList();

            if (relatedTests.Count == 0)
            {
                return;
            }

            var featureTests = relatedTests.Where(x => x.IsOfKind(UnitTestElementKind.TestContainer)).ToList();

            foreach (var feature in gherkinFile.GetFeatures())
            {
                var featureText = feature.GetFeatureText();
                var featureTest = featureTests.FirstOrDefault(t => GetDescription(t) == featureText) ?? featureTests.FirstOrDefault();
                if (featureTest == null)
                {
                    continue;
                }

                observer.OnUnitTestElementDisposition(new UnitTestElementDisposition(
                                                          featureTest,
                                                          projectFile,
                                                          feature.GetDocumentRange().TextRange,
                                                          feature.GetDocumentRange().TextRange
                                                          ));

                foreach (var scenario in feature.GetScenarios())
                {
                    var scenarioText = scenario.GetScenarioText();
                    var matchingTest = featureTest.Children.FirstOrDefault(t => GetDescription(t) == scenarioText);
                    if (matchingTest == null)
                    {
                        continue;
                    }

                    observer.OnUnitTestElementDisposition(new UnitTestElementDisposition(
                                                              matchingTest,
                                                              projectFile,
                                                              scenario.GetDocumentRange().TextRange,
                                                              scenario.GetDocumentRange().TextRange
                                                              ));
                }
            }
        }
 private void ExploreAssembly(IProject project, IMetadataAssembly assembly, IUnitTestElementsObserver observer)
 {
     if (assembly.ReferencedAssembliesNames.Any(n => n.Name == SilverlightMsTestAssemblyName))
     {
         this.RunWithElementFactory(elementFactory => new MsTestMetadataExplorer(elementFactory, this.msTestAttributesProvider, project, this.shellLocks, observer).ExploreAssembly(assembly));
     }
 }
 public void ExploreSolution(IUnitTestElementsObserver observer)
 {
     // Do nothing. We find all tests via source, or via assembly metadata
 }
 private void ExploreType(IProject project, IMetadataAssembly assembly, IUnitTestElementsObserver observer, IMetadataTypeInfo metadataTypeInfo)
 {
     // It would be nice to use TestClassCommandFactory.Make(...), but that doesn't work
     // with RunWith, since Make ends up calling TypeUtility.GetRunWith, which tries to
     // call IAttributeInfo.GetInstance<RunWithAttribute>, and we can't support that.
     // So we'll break down Make and do it ourselves. If the runner finds any methods
     // that we don't find, it will create them at runtime
     var typeInfo = metadataTypeInfo.AsTypeInfo();
     if (TypeUtility.IsTestClass(typeInfo))
         ExploreTestClass(project, assembly, observer, typeInfo, metadataTypeInfo.FullyQualifiedName);
 }
Example #50
0
        public void ExploreProjects(IDictionary <IProject, FileSystemPath> projects, MetadataLoader loader, IUnitTestElementsObserver observer)
        {
            var explorer = new MSpecTestMetadataExplorer(_provider, _assemblyExplorer);

            _metadataElementsSource.ExploreProjects(projects, loader, observer, explorer.ExploreAssembly);
            observer.OnCompleted();
        }
Example #51
0
 public void ExploreSolution(IUnitTestElementsObserver observer)
 {
 }
Example #52
0
 public void ExploreFile(IFile psiFile, IUnitTestElementsObserver observer, Func<bool> interrupted)
 {
     _testFileExplorer.Explore(psiFile, observer.OnUnitTestElementDisposition, () => !interrupted());
       observer.OnCompleted();
 }
Example #53
0
 public void ExploreProjects(IDictionary<IProject, FileSystemPath> projects, MetadataLoader loader, IUnitTestElementsObserver observer, CancellationToken cancellationToken)
 {
     _metadataElementsSource.ExploreProjects(projects, loader, observer, _testMetadataExplorer.Explore, cancellationToken);
       observer.OnCompleted();
 }
 public void ExploreFile(IFile psiFile, IUnitTestElementsObserver observer, Func<bool> interrupted)
 {
     // Do nothing. We find all tests via assembly metadata
 }