Exemplo n.º 1
0
        /// <inheritdoc />
        public void Describe(IReflectionPolicy reflectionPolicy, IList <ICodeElementInfo> codeElements, TestExplorationOptions testExplorationOptions, IMessageSink messageSink, IProgressMonitor progressMonitor)
        {
            if (reflectionPolicy == null)
            {
                throw new ArgumentNullException("reflectionPolicy");
            }
            if (codeElements == null || codeElements.Contains(null))
            {
                throw new ArgumentNullException("codeElements");
            }
            if (testExplorationOptions == null)
            {
                throw new ArgumentNullException("testExplorationOptions");
            }
            if (messageSink == null)
            {
                throw new ArgumentNullException("messageSink");
            }
            if (progressMonitor == null)
            {
                throw new ArgumentNullException("progressMonitor");
            }

            DescribeImpl(reflectionPolicy, codeElements, testExplorationOptions, messageSink, progressMonitor);
        }
Exemplo n.º 2
0
        protected override void ExploreImpl(IReflectionPolicy reflectionPolicy, ICodeElementInfo codeElement)
        {
            InitializeExplorerIfNeeded(reflectionPolicy);

            IAssemblyInfo assembly = ReflectionUtils.GetAssembly(codeElement);

            if (assembly != null)
            {
                bool skipChildren = !(codeElement is IAssemblyInfo);
                if (BuildAssemblyTest(assembly, skipChildren))
                {
                    foreach (IPatternScope scope in evaluator.GetScopes(assembly))
                    {
                        scope.PopulateDeferredComponents(null);
                    }

                    assemblies[assembly] = true;
                }
                else
                {
                    ITypeInfo type = ReflectionUtils.GetType(codeElement);
                    if (type != null)
                    {
                        foreach (IPatternScope scope in evaluator.GetScopes(assembly))
                        {
                            scope.PopulateDeferredComponents(type);
                        }
                    }
                }
            }
        }
        /// <summary>
        /// Creates a test model builder.
        /// </summary>
        /// <param name="reflectionPolicy">The reflection policy.</param>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="reflectionPolicy"/> is null.</exception>
        public ReflectionOnlyTestModelBuilder(IReflectionPolicy reflectionPolicy)
        {
            if (reflectionPolicy == null)
                throw new ArgumentNullException("reflectionPolicy");

            this.reflectionPolicy = reflectionPolicy;
        }
            protected override IList <TestPart> GetTestPartsImpl(IReflectionPolicy reflectionPolicy, ICodeElementInfo codeElement)
            {
                bool             copied            = false;
                IList <TestPart> combinedTestParts = null;

                ForEachDriver(testFrameworkManager.SelectTestFrameworksForCodeElementsImpl(
                                  testFrameworkHandles, testFrameworkFallbackMode, testFrameworkOptions, new[] { codeElement }),
                              (driver, items, driverCount) =>
                {
                    IList <TestPart> testParts = driver.GetTestParts(reflectionPolicy, codeElement);
                    if (testParts.Count != 0)
                    {
                        if (combinedTestParts == null)
                        {
                            combinedTestParts = testParts;
                        }
                        else
                        {
                            if (!copied)
                            {
                                combinedTestParts = new List <TestPart>(combinedTestParts);
                                copied            = true;
                            }

                            GenericCollectionUtils.AddAll(testParts, combinedTestParts);
                        }
                    }

                    return(false);
                });

                return(combinedTestParts ?? EmptyArray <TestPart> .Instance);
            }
Exemplo n.º 5
0
        protected override void ExploreImpl(IReflectionPolicy reflectionPolicy, ICodeElementInfo codeElement)
        {
            InitializeExplorerIfNeeded(reflectionPolicy);

            IAssemblyInfo assembly = ReflectionUtils.GetAssembly(codeElement);
            if (assembly != null)
            {
                bool skipChildren = ! (codeElement is IAssemblyInfo);
                if (BuildAssemblyTest(assembly, skipChildren))
                {
                    foreach (IPatternScope scope in evaluator.GetScopes(assembly))
                        scope.PopulateDeferredComponents(null);

                    assemblies[assembly] = true;
                }
                else
                {
                    ITypeInfo type = ReflectionUtils.GetType(codeElement);
                    if (type != null)
                    {
                        foreach (IPatternScope scope in evaluator.GetScopes(assembly))
                            scope.PopulateDeferredComponents(type);
                    }
                }
            }
        }
Exemplo n.º 6
0
 /// <inheritdoc />
 protected override void DescribeImpl(IReflectionPolicy reflectionPolicy, IList <ICodeElementInfo> codeElements,
                                      TestExplorationOptions testExplorationOptions, IMessageSink messageSink, IProgressMonitor progressMonitor)
 {
     using (progressMonitor.BeginTask("Describing unsupported tests.", Math.Max(codeElements.Count, 1)))
     {
         PublishTestModelFromCodeElements(codeElements, messageSink, progressMonitor);
     }
 }
Exemplo n.º 7
0
 /// <inheritdoc />
 protected override void DescribeImpl(IReflectionPolicy reflectionPolicy, IList<ICodeElementInfo> codeElements,
     TestExplorationOptions testExplorationOptions, IMessageSink messageSink, IProgressMonitor progressMonitor)
 {
     using (progressMonitor.BeginTask("Describing unsupported tests.", Math.Max(codeElements.Count, 1)))
     {
         PublishTestModelFromCodeElements(codeElements, messageSink, progressMonitor);
     }
 }
Exemplo n.º 8
0
 /// <inheritdoc />
 sealed protected override void DescribeImpl(IReflectionPolicy reflectionPolicy, IList <ICodeElementInfo> codeElements, TestExplorationOptions testExplorationOptions, IMessageSink messageSink, IProgressMonitor progressMonitor)
 {
     using (progressMonitor.BeginTask(string.Format("Describing {0} tests.", FrameworkName), 100))
     {
         progressMonitor.SetStatus("Building the test model.");
         GenerateTestModel(reflectionPolicy, codeElements, messageSink);
     }
 }
Exemplo n.º 9
0
            private void Describe(IReflectionPolicy reflectionPolicy, IList <ICodeElementInfo> codeElements, ConsumerAdapter consumerAdapter)
            {
                var testDriver             = CreateTestDriver();
                var testExplorationOptions = new TestExplorationOptions();

                testDriver.Describe(reflectionPolicy, codeElements, testExplorationOptions, consumerAdapter,
                                    NullProgressMonitor.CreateInstance());
            }
Exemplo n.º 10
0
        /// <inheritdoc />
        public IList<TestPart> GetTestParts(IReflectionPolicy reflectionPolicy, ICodeElementInfo codeElement)
        {
            if (reflectionPolicy == null)
                throw new ArgumentNullException("reflectionPolicy");
            if (codeElement == null)
                throw new ArgumentNullException("codeElement");

            return GetTestPartsImpl(reflectionPolicy, codeElement);
        }
        /// <summary>
        /// Creates a test model builder.
        /// </summary>
        /// <param name="reflectionPolicy">The reflection policy.</param>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="reflectionPolicy"/> is null.</exception>
        public ReflectionOnlyTestModelBuilder(IReflectionPolicy reflectionPolicy)
        {
            if (reflectionPolicy == null)
            {
                throw new ArgumentNullException("reflectionPolicy");
            }

            this.reflectionPolicy = reflectionPolicy;
        }
Exemplo n.º 12
0
        /// <summary>
        /// Explores tests defined by the specified code element and populates the explorer's test model.
        /// </summary>
        /// <param name="reflectionPolicy">The reflection policy.</param>
        /// <param name="codeElement">The code element.</param>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="reflectionPolicy"/>,
        /// <paramref name="codeElement"/> is null.</exception>
        public void Explore(IReflectionPolicy reflectionPolicy, ICodeElementInfo codeElement)
        {
            if (reflectionPolicy == null)
                throw new ArgumentNullException("reflectionPolicy");
            if (codeElement == null)
                throw new ArgumentNullException("codeElement");

            ExploreImpl(reflectionPolicy, codeElement);
        }
Exemplo n.º 13
0
        protected override void ExploreImpl(IReflectionPolicy reflectionPolicy, ICodeElementInfo codeElement)
        {
            IAssemblyInfo assembly = ReflectionUtils.GetAssembly(codeElement);

            if (assembly == null)
            {
                return;
            }

            try
            {
                MbUnit2TestExplorerEngine engine;
                if (!assemblyTestExplorerEngines.TryGetValue(assembly, out engine))
                {
                    Assembly loadedAssembly = assembly.Resolve(false);

                    if (Reflector.IsUnresolved(loadedAssembly))
                    {
                        engine = new MbUnit2ReflectiveTestExplorerEngine(TestModel, assembly);
                    }
                    else
                    {
                        engine = new MbUnit2NativeTestExplorerEngine(TestModel, loadedAssembly);
                    }

                    assemblyTestExplorerEngines.Add(assembly, engine);

                    bool skipChildren = !(codeElement is IAssemblyInfo);
                    engine.ExploreAssembly(skipChildren, unresolvedDependencies);

                    for (int i = 0; i < unresolvedDependencies.Count; i++)
                    {
                        foreach (var entry in assemblyTestExplorerEngines)
                        {
                            if (entry.Key.FullName == unresolvedDependencies[i].Value)
                            {
                                unresolvedDependencies[i].Key.AddDependency(entry.Value.GetAssemblyTest());
                                unresolvedDependencies.RemoveAt(i--);
                                break;
                            }
                        }
                    }
                }

                ITypeInfo type = ReflectionUtils.GetType(codeElement);
                if (type != null)
                {
                    engine.ExploreType(type);
                }
            }
            catch (Exception ex)
            {
                TestModel.AddAnnotation(new Annotation(AnnotationType.Error, assembly,
                                                       "An exception was thrown while exploring an MbUnit v2 test assembly.", ex));
            }
        }
Exemplo n.º 14
0
        private void InitializeExplorerIfNeeded(IReflectionPolicy reflectionPolicy)
        {
            if (testModelBuilder != null)
            {
                return;
            }

            testModelBuilder = new DefaultTestModelBuilder(reflectionPolicy, (PatternTestModel)TestModel);
            evaluator        = new DefaultPatternEvaluator(testModelBuilder, DeclarativePatternResolver.Instance);
        }
        /// <summary>
        /// Creates a test model builder.
        /// </summary>
        /// <param name="reflectionPolicy">The reflection policy.</param>
        /// <param name="testModel">The underlying test model.</param>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="reflectionPolicy"/>
        /// or <paramref name="testModel"/> is null.</exception>
        public DefaultTestModelBuilder(IReflectionPolicy reflectionPolicy, PatternTestModel testModel)
        {
            if (reflectionPolicy == null)
                throw new ArgumentNullException("reflectionPolicy");
            if (testModel == null)
                throw new ArgumentNullException("testModel");

            this.reflectionPolicy = reflectionPolicy;
            this.testModel = testModel;

            rootTestBuilder = new DefaultTestBuilder(this, testModel.RootTest);
        }
Exemplo n.º 16
0
        /// <inheritdoc />
        public IList <TestPart> GetTestParts(IReflectionPolicy reflectionPolicy, ICodeElementInfo codeElement)
        {
            if (reflectionPolicy == null)
            {
                throw new ArgumentNullException("reflectionPolicy");
            }
            if (codeElement == null)
            {
                throw new ArgumentNullException("codeElement");
            }

            return(GetTestPartsImpl(reflectionPolicy, codeElement));
        }
Exemplo n.º 17
0
        protected override void ExploreImpl(IReflectionPolicy reflectionPolicy, ICodeElementInfo codeElement)
        {
            IAssemblyInfo assembly = ReflectionUtils.GetAssembly(codeElement);
            if (assembly != null)
            {
                Version frameworkVersion = GetFrameworkVersion(assembly);

                if (frameworkVersion != null)
                {
                    GetAssemblyTest(assembly, TestModel.RootTest, frameworkVersion);
                }
            }
        }
Exemplo n.º 18
0
        /// <summary>
        /// Explores tests defined by the specified code element and populates the explorer's test model.
        /// </summary>
        /// <param name="reflectionPolicy">The reflection policy.</param>
        /// <param name="codeElement">The code element.</param>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="reflectionPolicy"/>,
        /// <paramref name="codeElement"/> is null.</exception>
        public void Explore(IReflectionPolicy reflectionPolicy, ICodeElementInfo codeElement)
        {
            if (reflectionPolicy == null)
            {
                throw new ArgumentNullException("reflectionPolicy");
            }
            if (codeElement == null)
            {
                throw new ArgumentNullException("codeElement");
            }

            ExploreImpl(reflectionPolicy, codeElement);
        }
Exemplo n.º 19
0
        protected override void ExploreImpl(IReflectionPolicy reflectionPolicy, ICodeElementInfo codeElement)
        {
            IAssemblyInfo assembly = ReflectionUtils.GetAssembly(codeElement);

            if (assembly != null)
            {
                Version frameworkVersion = GetFrameworkVersion(assembly);

                if (frameworkVersion != null)
                {
                    GetAssemblyTest(assembly, TestModel.RootTest, frameworkVersion);
                }
            }
        }
 protected override void DescribeImpl(IReflectionPolicy reflectionPolicy, IList <ICodeElementInfo> codeElements, TestExplorationOptions testExplorationOptions, IMessageSink messageSink, Gallio.Runtime.ProgressMonitoring.IProgressMonitor progressMonitor)
 {
     using (progressMonitor.BeginTask("Describing tests.", 1))
     {
         ForEachDriver(testFrameworkManager.SelectTestFrameworksForCodeElementsImpl(
                           testFrameworkHandles, testFrameworkFallbackMode, testFrameworkOptions, codeElements),
                       (driver, items, driverCount) =>
         {
             driver.Describe(reflectionPolicy, items, testExplorationOptions, messageSink,
                             progressMonitor.CreateSubProgressMonitor(1.0 / driverCount));
             return(false);
         });
     }
 }
Exemplo n.º 21
0
        protected override void ExploreImpl(IReflectionPolicy reflectionPolicy, ICodeElementInfo codeElement)
        {
            IAssemblyInfo assembly = ReflectionUtils.GetAssembly(codeElement);
            if (assembly == null)
                return;

            try
            {
                MbUnit2TestExplorerEngine engine;
                if (! assemblyTestExplorerEngines.TryGetValue(assembly, out engine))
                {
                    Assembly loadedAssembly = assembly.Resolve(false);

                    if (Reflector.IsUnresolved(loadedAssembly))
                        engine = new MbUnit2ReflectiveTestExplorerEngine(TestModel, assembly);
                    else
                        engine = new MbUnit2NativeTestExplorerEngine(TestModel, loadedAssembly);

                    assemblyTestExplorerEngines.Add(assembly, engine);

                    bool skipChildren = !(codeElement is IAssemblyInfo);
                    engine.ExploreAssembly(skipChildren, unresolvedDependencies);

                    for (int i = 0; i < unresolvedDependencies.Count; i++)
                    {
                        foreach (var entry in assemblyTestExplorerEngines)
                        {
                            if (entry.Key.FullName == unresolvedDependencies[i].Value)
                            {
                                unresolvedDependencies[i].Key.AddDependency(entry.Value.GetAssemblyTest());
                                unresolvedDependencies.RemoveAt(i--);
                                break;
                            }
                        }
                    }
                }

                ITypeInfo type = ReflectionUtils.GetType(codeElement);
                if (type != null)
                {
                    engine.ExploreType(type);
                }
            }
            catch (Exception ex)
            {
                TestModel.AddAnnotation(new Annotation(AnnotationType.Error, assembly,
                    "An exception was thrown while exploring an MbUnit v2 test assembly.", ex));
            }
        }
Exemplo n.º 22
0
        /// <inheritdoc />
        public void Describe(IReflectionPolicy reflectionPolicy, IList<ICodeElementInfo> codeElements, TestExplorationOptions testExplorationOptions, IMessageSink messageSink, IProgressMonitor progressMonitor)
        {
            if (reflectionPolicy == null)
                throw new ArgumentNullException("reflectionPolicy");
            if (codeElements == null || codeElements.Contains(null))
                throw new ArgumentNullException("codeElements");
            if (testExplorationOptions == null)
                throw new ArgumentNullException("testExplorationOptions");
            if (messageSink == null)
                throw new ArgumentNullException("messageSink");
            if (progressMonitor == null)
                throw new ArgumentNullException("progressMonitor");

            DescribeImpl(reflectionPolicy, codeElements, testExplorationOptions, messageSink, progressMonitor);
        }
Exemplo n.º 23
0
        private TestModel GenerateTestModel(IReflectionPolicy reflectionPolicy, IEnumerable <ICodeElementInfo> codeElements, IMessageSink messageSink)
        {
            using (TestExplorer testExplorer = CreateTestExplorer())
            {
                foreach (var codeElement in codeElements)
                {
                    testExplorer.Explore(reflectionPolicy, codeElement);
                }

                testExplorer.Finish();

                TestModelSerializer.PublishTestModel(testExplorer.TestModel, messageSink);
                return(testExplorer.TestModel);
            }
        }
Exemplo n.º 24
0
        protected override void ExploreImpl(IReflectionPolicy reflectionPolicy, ICodeElementInfo codeElement)
        {
            IAssemblyInfo assembly         = ReflectionUtils.GetAssembly(codeElement);
            Version       frameworkVersion = GetFrameworkVersion(assembly);

            if (frameworkVersion != null)
            {
                ITypeInfo type         = ReflectionUtils.GetType(codeElement);
                Test      assemblyTest = GetAssemblyTest(assembly, TestModel.RootTest, frameworkVersion, type == null);
                if (type != null)
                {
                    TryGetTypeTest(type, assemblyTest);
                }
            }
        }
        protected override void ExploreImpl(IReflectionPolicy reflectionPolicy, ICodeElementInfo codeElement)
        {
            IAssemblyInfo assembly = ReflectionUtils.GetAssembly(codeElement);
            Version frameworkVersion = GetFrameworkVersion(assembly);
            if (frameworkVersion != null)
            {
                ITypeInfo type = ReflectionUtils.GetType(codeElement);
                Test assemblyTest = GetAssemblyTest(assembly, TestModel.RootTest, frameworkVersion, type == null);
                if (type != null)
                {
                    TryGetTypeTest(type, assemblyTest);
                }

            }
        }
Exemplo n.º 26
0
        /// <summary>
        /// Creates a test model builder.
        /// </summary>
        /// <param name="reflectionPolicy">The reflection policy.</param>
        /// <param name="testModel">The underlying test model.</param>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="reflectionPolicy"/>
        /// or <paramref name="testModel"/> is null.</exception>
        public DefaultTestModelBuilder(IReflectionPolicy reflectionPolicy, PatternTestModel testModel)
        {
            if (reflectionPolicy == null)
            {
                throw new ArgumentNullException("reflectionPolicy");
            }
            if (testModel == null)
            {
                throw new ArgumentNullException("testModel");
            }

            this.reflectionPolicy = reflectionPolicy;
            this.testModel        = testModel;

            rootTestBuilder = new DefaultTestBuilder(this, testModel.RootTest);
        }
Exemplo n.º 27
0
        protected override void ExploreImpl(IReflectionPolicy reflectionPolicy, ICodeElementInfo codeElement)
        {
            IAssemblyInfo assembly = ReflectionUtils.GetAssembly(codeElement);

            if (assembly == null)
            {
                return;
            }

            try
            {
                NUnitTestExplorerEngine engine;
                if (!assemblyTestExplorerEngines.TryGetValue(assembly, out engine))
                {
                    Assembly loadedAssembly = assembly.Resolve(false);

                    if (Reflector.IsUnresolved(loadedAssembly))
                    {
                        engine = new NUnitReflectiveTestExplorerEngine(TestModel, assembly);
                    }
                    else
                    {
                        engine = new NUnitNativeTestExplorerEngine(TestModel, loadedAssembly);
                    }

                    assemblyTestExplorerEngines.Add(assembly, engine);

                    bool skipChildren = !(codeElement is IAssemblyInfo);
                    engine.ExploreAssembly(skipChildren);
                }

                ITypeInfo type = ReflectionUtils.GetType(codeElement);
                if (type != null)
                {
                    engine.ExploreType(type);
                }
            }
            catch (Exception ex)
            {
                TestModel.AddAnnotation(new Annotation(AnnotationType.Error, assembly,
                                                       "An exception was thrown while exploring an NUnit test assembly.", ex));
            }
        }
Exemplo n.º 28
0
        protected override void ExploreImpl(IReflectionPolicy reflectionPolicy, ICodeElementInfo codeElement)
        {
            IAssemblyInfo assembly = ReflectionUtils.GetAssembly(codeElement);
            if (assembly == null)
                return;

            try
            {
                NUnitTestExplorerEngine engine;
                if (!assemblyTestExplorerEngines.TryGetValue(assembly, out engine))
                {
                    Assembly loadedAssembly = assembly.Resolve(false);

                    if (Reflector.IsUnresolved(loadedAssembly))
                        engine = new NUnitReflectiveTestExplorerEngine(TestModel, assembly);
                    else
                        engine = new NUnitNativeTestExplorerEngine(TestModel, loadedAssembly);

                    assemblyTestExplorerEngines.Add(assembly, engine);

                    bool skipChildren = !(codeElement is IAssemblyInfo);
                    engine.ExploreAssembly(skipChildren);
                }

                ITypeInfo type = ReflectionUtils.GetType(codeElement);
                if (type != null)
                {
                    engine.ExploreType(type);
                }
            }
            catch (Exception ex)
            {
                TestModel.AddAnnotation(new Annotation(AnnotationType.Error, assembly,
                    "An exception was thrown while exploring an NUnit test assembly.", ex));
            }
        }
Exemplo n.º 29
0
        protected override IList <TestPart> GetTestPartsImpl(IReflectionPolicy reflectionPolicy, ICodeElementInfo codeElement)
        {
            var evaluator = CreateReflectionOnlyPatternEvaluator(reflectionPolicy);

            return(evaluator.GetTestParts(codeElement, GetAutomaticPattern(codeElement)));
        }
Exemplo n.º 30
0
 private void Describe(IReflectionPolicy reflectionPolicy, IList<ICodeElementInfo> codeElements, ConsumerAdapter consumerAdapter)
 {
     var testDriver = CreateTestDriver();
     var testExplorationOptions = new TestExplorationOptions();
     testDriver.Describe(reflectionPolicy, codeElements, testExplorationOptions, consumerAdapter,
         NullProgressMonitor.CreateInstance());
 }
Exemplo n.º 31
0
 /// <summary>
 /// Describes tests via reflection over code elements.
 /// </summary>
 /// <remarks>
 /// <para>
 /// The default implementation does nothing.  Subclasses may override to enable tests
 /// to be described via reflection only.  This is required for ReSharper integration.
 /// </para>
 /// </remarks>
 /// <param name="reflectionPolicy">The reflection policy, not null.</param>
 /// <param name="codeElements">The enumeration of code elements, usually <see cref="ITypeInfo" />
 /// and <see cref="IAssemblyInfo" /> objects, that might contain tests to be described, not null.</param>
 /// <param name="testExplorationOptions">The test exploration options, not null.</param>
 /// <param name="messageSink">The message sink to receive test exploration messages, not null.</param>
 /// <param name="progressMonitor">The progress monitor, not null.</param>
 protected virtual void DescribeImpl(IReflectionPolicy reflectionPolicy, IList <ICodeElementInfo> codeElements,
                                     TestExplorationOptions testExplorationOptions, IMessageSink messageSink, IProgressMonitor progressMonitor)
 {
 }
Exemplo n.º 32
0
 /// <summary>
 /// Explores tests defined by the specified code element and populates the explorer's test model.
 /// </summary>
 /// <param name="reflectionPolicy">The reflection policy, not null.</param>
 /// <param name="codeElement">The code element, not null.</param>
 protected abstract void ExploreImpl(IReflectionPolicy reflectionPolicy, ICodeElementInfo codeElement);
Exemplo n.º 33
0
 /// <summary>
 /// Gets the test parts represented by a code element.
 /// </summary>
 /// <remarks>
 /// <para>
 /// The default implementation always returns an empty array.  Subclasses may override
 /// this method to provide information about code elements that represent tests.
 /// </para>
 /// </remarks>
 /// <param name="reflectionPolicy">The reflection policy, not null.</param>
 /// <param name="codeElement">The code element, not null.</param>
 /// <returns>The test parts, or an empty array if none.</returns>
 protected virtual IList <TestPart> GetTestPartsImpl(IReflectionPolicy reflectionPolicy, ICodeElementInfo codeElement)
 {
     return(EmptyArray <TestPart> .Instance);
 }
Exemplo n.º 34
0
 private static IPatternEvaluator CreateReflectionOnlyPatternEvaluator(IReflectionPolicy reflectionPolicy)
 {
     var testModelBuilder = new ReflectionOnlyTestModelBuilder(reflectionPolicy);
     return new DefaultPatternEvaluator(testModelBuilder, DeclarativePatternResolver.Instance);
 }
Exemplo n.º 35
0
 /// <summary>
 /// Gets the test parts represented by a code element.
 /// </summary>
 /// <remarks>
 /// <para>
 /// The default implementation always returns an empty array.  Subclasses may override
 /// this method to provide information about code elements that represent tests.
 /// </para>
 /// </remarks>
 /// <param name="reflectionPolicy">The reflection policy, not null.</param>
 /// <param name="codeElement">The code element, not null.</param>
 /// <returns>The test parts, or an empty array if none.</returns>
 protected virtual IList<TestPart> GetTestPartsImpl(IReflectionPolicy reflectionPolicy, ICodeElementInfo codeElement)
 {
     return EmptyArray<TestPart>.Instance;
 }
Exemplo n.º 36
0
 /// <inheritdoc />
 protected override sealed void DescribeImpl(IReflectionPolicy reflectionPolicy, IList<ICodeElementInfo> codeElements, TestExplorationOptions testExplorationOptions, IMessageSink messageSink, IProgressMonitor progressMonitor)
 {
     using (progressMonitor.BeginTask(string.Format("Describing {0} tests.", FrameworkName), 100))
     {
         progressMonitor.SetStatus("Building the test model.");
         GenerateTestModel(reflectionPolicy, codeElements, messageSink);
     }
 }
Exemplo n.º 37
0
 /// <summary>
 /// Explores tests defined by the specified code element and populates the explorer's test model.
 /// </summary>
 /// <param name="reflectionPolicy">The reflection policy, not null.</param>
 /// <param name="codeElement">The code element, not null.</param>
 protected abstract void ExploreImpl(IReflectionPolicy reflectionPolicy, ICodeElementInfo codeElement);
Exemplo n.º 38
0
        private static IPatternEvaluator CreateReflectionOnlyPatternEvaluator(IReflectionPolicy reflectionPolicy)
        {
            var testModelBuilder = new ReflectionOnlyTestModelBuilder(reflectionPolicy);

            return(new DefaultPatternEvaluator(testModelBuilder, DeclarativePatternResolver.Instance));
        }
Exemplo n.º 39
0
 protected override IList<TestPart> GetTestPartsImpl(IReflectionPolicy reflectionPolicy, ICodeElementInfo codeElement)
 {
     var evaluator = CreateReflectionOnlyPatternEvaluator(reflectionPolicy);
     return evaluator.GetTestParts(codeElement, GetAutomaticPattern(codeElement));
 }
Exemplo n.º 40
0
        private TestModel GenerateTestModel(IReflectionPolicy reflectionPolicy, IEnumerable<ICodeElementInfo> codeElements, IMessageSink messageSink)
        {
            using (TestExplorer testExplorer = CreateTestExplorer())
            {
                foreach (var codeElement in codeElements)
                    testExplorer.Explore(reflectionPolicy, codeElement);

                testExplorer.Finish();

                TestModelSerializer.PublishTestModel(testExplorer.TestModel, messageSink);
                return testExplorer.TestModel;
            }
        }
Exemplo n.º 41
0
 /// <summary>
 /// Describes tests via reflection over code elements.
 /// </summary>
 /// <remarks>
 /// <para>
 /// The default implementation does nothing.  Subclasses may override to enable tests
 /// to be described via reflection only.  This is required for ReSharper integration.
 /// </para>
 /// </remarks>
 /// <param name="reflectionPolicy">The reflection policy, not null.</param>
 /// <param name="codeElements">The enumeration of code elements, usually <see cref="ITypeInfo" />
 /// and <see cref="IAssemblyInfo" /> objects, that might contain tests to be described, not null.</param>
 /// <param name="testExplorationOptions">The test exploration options, not null.</param>
 /// <param name="messageSink">The message sink to receive test exploration messages, not null.</param>
 /// <param name="progressMonitor">The progress monitor, not null.</param>
 protected virtual void DescribeImpl(IReflectionPolicy reflectionPolicy, IList<ICodeElementInfo> codeElements,
     TestExplorationOptions testExplorationOptions, IMessageSink messageSink, IProgressMonitor progressMonitor)
 {
 }
Exemplo n.º 42
0
        private void InitializeExplorerIfNeeded(IReflectionPolicy reflectionPolicy)
        {
            if (testModelBuilder != null)
                return;

            testModelBuilder = new DefaultTestModelBuilder(reflectionPolicy, (PatternTestModel)TestModel);
            evaluator = new DefaultPatternEvaluator(testModelBuilder, DeclarativePatternResolver.Instance);
        }