Inheritance: IResultRecorder, IResultSummary
 public IResultSummary Process(Resource resource, object fixture) 
 {
     var specification = SpecificationReader.ReadSpecification(resource);
     var resultRecorder = new SummarizingResultRecorder();
     specification.Process(EvaluatorFactory.CreateEvaluator(fixture), resultRecorder);
     return resultRecorder;
 }
        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 IResultSummary Run(object fixture)
        {
            try
            {
                this.m_Fixture = fixture;
                if (m_SpecificationConfig == null)
                {
                    this.m_SpecificationConfig = new SpecificationConfig().Load(fixture.GetType());
                }
                if (!string.IsNullOrEmpty(m_SpecificationConfig.BaseInputDirectory))
                {
                    this.m_Source = new FileSource(m_SpecificationConfig.BaseInputDirectory);
                }
                else
                {
                    this.m_Source = new EmbeddedResourceSource(fixture.GetType().Assembly);
                }
                this.m_Target = new FileTarget(this.m_SpecificationConfig.BaseOutputDirectory);

                var fileExtensions = this.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.Error(e);
                return(exceptionResult);
            }
        }
 private IResultSummary RunAllSpecifications(IEnumerable<string> fileExtensions)
 {
     var testSummary = new SummarizingResultRecorder();
     var anySpecExecuted = false;
     foreach (var fileExtension in fileExtensions)
     {
         var specLocator = new ClassNameBasedSpecificationLocator(fileExtension);
         var specResource = specLocator.LocateSpecification(m_Fixture);
         if (m_Source.CanFind(specResource))
         {
             var fixtureResult = RunSingleSpecification(fileExtension);
             AddToTestResults(fixtureResult, testSummary);
             anySpecExecuted = true;
         }
     }
     if (!anySpecExecuted)
     {
         testSummary.Record(Result.Exception);
         Console.WriteLine("no active specification found for fixture: {0}", m_Fixture.GetType().FullName);
     }
     return testSummary;
 }
        private IResultSummary RunAllSpecifications(IEnumerable <string> fileExtensions)
        {
            var testSummary     = new SummarizingResultRecorder();
            var anySpecExecuted = false;

            foreach (var fileExtension in fileExtensions)
            {
                var specLocator  = new ClassNameBasedSpecificationLocator(fileExtension);
                var specResource = specLocator.LocateSpecification(m_Fixture);
                if (m_Source.CanFind(specResource))
                {
                    var fixtureResult = RunSingleSpecification(fileExtension);
                    AddToTestResults(fixtureResult, testSummary);
                    anySpecExecuted = true;
                }
            }
            if (!anySpecExecuted)
            {
                string specPath;
                if (!string.IsNullOrEmpty(m_SpecificationConfig.BaseInputDirectory))
                {
                    specPath = string.Format("directory {0}",
                                             Path.GetFullPath(m_SpecificationConfig.BaseInputDirectory));
                }
                else
                {
                    specPath = string.Format("assembly {0}",
                                             m_Fixture.GetType().Assembly.GetName().Name);
                }
                testSummary.Error(new AssertionErrorException(string.Format(
                                                                  "no active specification found for {0} in {1}",
                                                                  this.m_Fixture.GetType().Name,
                                                                  specPath)));
            }
            return(testSummary);
        }
 private IResultSummary RunAllSpecifications(IEnumerable<string> fileExtensions)
 {
     var testSummary = new SummarizingResultRecorder();
     var anySpecExecuted = false;
     foreach (var fileExtension in fileExtensions)
     {
         var specLocator = new ClassNameBasedSpecificationLocator(fileExtension);
         var specResource = specLocator.LocateSpecification(m_Fixture);
         if (m_Source.CanFind(specResource))
         {
             var fixtureResult = RunSingleSpecification(fileExtension);
             AddToTestResults(fixtureResult, testSummary);
             anySpecExecuted = true;
         }
     }
     if (!anySpecExecuted)
     {
         string specPath;
         if (!string.IsNullOrEmpty(m_SpecificationConfig.BaseInputDirectory))
         {
             specPath = string.Format("directory {0}",
                 Path.GetFullPath(m_SpecificationConfig.BaseInputDirectory));
         }
         else
         {
             specPath = string.Format("assembly {0}",
                 m_Fixture.GetType().Assembly.GetName().Name);
         }
         testSummary.Error(new AssertionErrorException(string.Format(
             "no active specification found for {0} in {1}",
             this.m_Fixture.GetType().Name,
             specPath)));
     }
     return testSummary;
 }