public int Run()
        {
            try {
                var arguments = Args.Parse <Arguments>(args);
                var writter   = consoleFactory.CreateConsoleWritter(arguments.Colour);

                if (arguments.Help)
                {
                    ArgUsage.GetStyledUsage <Arguments>().Write();
                    return(0);
                }

                if (arguments.Version)
                {
                    writter.WriteInformationLine(Assembly.GetEntryAssembly().GetName().Version.ToString());
                    return(0);
                }

                var consoleFormatter = formatterFactory.CreateConsoleFormatter(arguments.Format, writter);
                var expressionRunner = expressionFactory.CreateExpressionRunner(arguments.DryRun);
                var specRunner       = runnerFactory.CreateSpecificationRunner(arguments.Parrallel, expressionRunner, finder, consoleFormatter);
                var files            = finder.GetSpecificationFiles(arguments.Path, arguments.Pattern);
                var appDomain        = new SpecificationAppDomain(specRunner);
                var results          = new List <ExpressionResult>();

                foreach (var file in files)
                {
                    results.AddRange(appDomain.ExecuteSpecifications(file, arguments.Example));
                }

                consoleFormatter.WriteSummary(results);
                reporter.Write(fileSystem.OpenWrite(arguments.Output), results);

                return(results.HasErrors() ? 1 : 0);
            } catch (ArgException e) {
                var consoleFormatter = consoleFactory.CreateConsoleWritter(false);
                consoleFormatter.WriteInformationLine(e.Message);
                consoleFormatter.WriteLine();
                ArgUsage.GetStyledUsage <Arguments>().Write();
                return(1);
            } catch (Exception e) {
                var consoleFormatter = consoleFactory.CreateConsoleWritter(false);
                consoleFormatter.WriteInformationLine(e.ToString().Trim());
                return(1);
            }
        }
        public int Run()
        {
            try {
                var arguments = Args.Parse<Arguments>(args);
                var writter = consoleFactory.CreateConsoleWritter(arguments.Colour);

                if (arguments.Help) {
                    ArgUsage.GetStyledUsage<Arguments>().Write();
                    return 0;
                }

                if (arguments.Version) {
                    writter.WriteInformationLine(Assembly.GetEntryAssembly().GetName().Version.ToString());
                    return 0;
                }

                var consoleFormatter = formatterFactory.CreateConsoleFormatter(arguments.Format, writter);
                var expressionRunner = expressionFactory.CreateExpressionRunner(arguments.DryRun);
                var specRunner = runnerFactory.CreateSpecificationRunner(arguments.Parrallel, expressionRunner, finder, consoleFormatter);
                var files = finder.GetSpecificationFiles(arguments.Path, arguments.Pattern);
                var appDomain = new SpecificationAppDomain(specRunner);
                var results = new List<ExpressionResult>();

                foreach (var file in files) {
                    results.AddRange(appDomain.ExecuteSpecifications(file, arguments.Example));
                }

                consoleFormatter.WriteSummary(results);
                reporter.Write(fileSystem.OpenWrite(arguments.Output), results);

                return results.HasErrors() ? 1 : 0;
            } catch (ArgException e) {
                var consoleFormatter = consoleFactory.CreateConsoleWritter(false);
                consoleFormatter.WriteInformationLine(e.Message);
                consoleFormatter.WriteLine();
                ArgUsage.GetStyledUsage<Arguments>().Write();
                return 1;
            } catch (Exception e) {
                var consoleFormatter = consoleFactory.CreateConsoleWritter(false);
                consoleFormatter.WriteInformationLine(e.ToString().Trim());
                return 1;
            }
        }
        public void BeforeAll()
        {
            var finder = new DefaultSpecificationFinder(new DefaultFileSystem());
            var expressionRunner = new DefaultExpressionRunnerFactory().CreateExpressionRunner(false);
            var formatter = new SilentConsoleFormatter(new DefaultConsoleWritter());
            runner = new DefaultSpecificationRunner(expressionRunner, finder, formatter);

            var location = new Uri(typeof(TestSpecificationConfigurationManager).Assembly.CodeBase).LocalPath;
            var appDomain = new SpecificationAppDomain(runner);
            var results = appDomain.ExecuteSpecifications(location);
            
            using (var stream = new MemoryStream()) {
                var reporter = new NUnitSpecificationReporter();
                reporter.Write(stream, results);
                stream.Seek(0, SeekOrigin.Begin);

                var serializer = new XmlSerializer(typeof(resultType));
                using (var reader = XmlReader.Create(stream)) {
                    resultType = (resultType)serializer.Deserialize(reader);
                }
            }
        }
Exemple #4
0
        public void BeforeAll()
        {
            var finder           = new DefaultSpecificationFinder(new DefaultFileSystem());
            var expressionRunner = new DefaultExpressionRunnerFactory().CreateExpressionRunner(false);
            var formatter        = new SilentConsoleFormatter(new DefaultConsoleWritter());

            runner = new DefaultSpecificationRunner(expressionRunner, finder, formatter);

            var location  = new Uri(typeof(TestSpecificationConfigurationManager).Assembly.CodeBase).LocalPath;
            var appDomain = new SpecificationAppDomain(runner);
            var results   = appDomain.ExecuteSpecifications(location);

            using (var stream = new MemoryStream()) {
                var reporter = new NUnitSpecificationReporter();
                reporter.Write(stream, results);
                stream.Seek(0, SeekOrigin.Begin);

                var serializer = new XmlSerializer(typeof(resultType));
                using (var reader = XmlReader.Create(stream)) {
                    resultType = (resultType)serializer.Deserialize(reader);
                }
            }
        }
 public DefaultTestExecutor(ISpecificationRunner runner)
 {
     appDomainRunner = new SpecificationAppDomain(runner);
 }
 public DefaultTestDiscoverer(ISpecificationRunner runner)
 {
     appDomainRunner = new SpecificationAppDomain(runner);
 }
 public DefaultTestDiscoverer(ISpecificationRunner runner)
 {
     appDomainRunner = new SpecificationAppDomain(runner);
 }
 public DefaultTestExecutor(ISpecificationRunner runner)
 {
     appDomainRunner = new SpecificationAppDomain(runner);
 }