Loads the configuration file for a specification assembly
        public bool DirectoryBasedExecuted(string baseInputDirectory)
        {
            if (m_InTestRun) return true;

            m_InTestRun = true;

            //work around for bug of NUnit GUI runner
            baseInputDirectory = baseInputDirectory +
                                 Path.DirectorySeparatorChar +
                                 ".." +
                                 Path.DirectorySeparatorChar +
                                 this.GetType().Assembly.GetName().Name;

            var specificationConfig = new SpecificationConfig().Load(this.GetType());
            specificationConfig.BaseInputDirectory = baseInputDirectory;
            var fixtureRunner = new FixtureRunner(specificationConfig);
            var testResult = fixtureRunner.Run(this);

            m_InTestRun = false;

            foreach (var failureDetail in testResult.FailureDetails) {
                Console.WriteLine(failureDetail.Message);
                Console.WriteLine(failureDetail.StackTrace);
            }
            foreach (var errorDetail in testResult.ErrorDetails)
            {
                Console.WriteLine(errorDetail.Message);
                Console.WriteLine(errorDetail.StackTrace);
                Console.WriteLine(errorDetail.Exception);
            }

            return !testResult.HasFailures && !testResult.HasExceptions;
        }
Esempio n. 2
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 bool EmbeddedExecuted()
        {
            if (m_InTestRun) return true;

            m_InTestRun = true;

            var specificationConfig = new SpecificationConfig().Load(this.GetType());
            specificationConfig.BaseInputDirectory = null;
            var fixtureRunner = new FixtureRunner(specificationConfig);
            var testResult = fixtureRunner.Run(this);

            m_InTestRun = false;

            return !testResult.HasFailures && !testResult.HasExceptions;
        }
Esempio n. 4
0
        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);
            }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="SpecificationConfigParser"/> class.
 /// </summary>
 /// <param name="config">The config.</param>
 public SpecificationConfigParser(SpecificationConfig config)
 {
     this.Config = config;
 }
        private void GetInputOutputDirectories(IAssemblyInfo assembly)
        {
            var config = new SpecificationConfig().Load(assembly.Resolve(false));

            var baseInputDirectoryInfo = new DirectoryInfo(config.BaseInputDirectory);
            if (baseInputDirectoryInfo.Exists)
            {
            }
            else
            {
               TestModel.AddAnnotation(new Annotation(AnnotationType.Error, assembly, String.Format("The Base Input Directory {0} does not exist, reverting to default", config.BaseInputDirectory)));
            }

            var baseOutputDirectoryInfo = new DirectoryInfo(config.BaseOutputDirectory);
            this._baseOutputDirectory = baseOutputDirectoryInfo;

            if (!_baseOutputDirectory.Exists)
            {
                Directory.CreateDirectory(_baseOutputDirectory.FullName);
            }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="SpecificationConfigParser"/> class.
 /// </summary>
 /// <param name="config">The config.</param>
 public SpecificationConfigParser(SpecificationConfig config)
 {
     this.Config = config;
 }
Esempio n. 8
0
 public FixtureRunner(SpecificationConfig specificationConfig)
     : this()
 {
     m_SpecificationConfig = specificationConfig;
 }
Esempio n. 9
0
 public FixtureRunner(SpecificationConfig specificationConfig)
     : this()
 {
     m_SpecificationConfig = specificationConfig;
 }