示例#1
0
        public IResultSummary Run(object fixture)
        {
            try
            {
                this.m_Fixture = fixture;
                this.m_Source = new EmbeddedResourceSource(fixture.GetType().Assembly);
                this.m_SpecificationConfig = new SpecificationConfig().Load(fixture.GetType());
                this.m_Target = new FileTarget(m_SpecificationConfig.BaseOutputDirectory);

                var fileExtensions = m_SpecificationConfig.SpecificationFileExtensions;
                if (fileExtensions.Count > 1)
                {
                    return RunAllSpecifications(fileExtensions);
                }
                else if (fileExtensions.Count == 1)
                {
                    return RunSingleSpecification(fileExtensions.First());
                }
                else
                {
                    throw new InvalidOperationException(string.Format("no specification extensions defined for: {0}", this.m_SpecificationConfig));
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                var exceptionResult = new SummarizingResultRecorder();
                exceptionResult.Record(Result.Exception);
                return exceptionResult;
            }
        }
        public override TestResult Run(EventListener listener, ITestFilter filter)
        {
            listener.TestStarted(TestName);

            var source = new EmbeddedResourceSource(m_FixtureType.Assembly);
            var target = new FileTarget(new SpecificationConfig().Load(m_FixtureType).BaseOutputDirectory);
            var concordion = new ConcordionBuilder().WithSource(source).WithTarget(target).Build();

            Fixture = Reflect.Construct(m_FixtureType);
            var concordionResult = concordion.Process(Fixture);
            var testResult = NUnitTestResult(concordionResult);

            listener.TestFinished(testResult);

            return testResult;
        }