Пример #1
0
        public void ShouldGetSpecifications()
        {
            var          location = new Uri(Assembly.GetAssembly(typeof(TestSpecificationWithBeforeAll)).CodeBase).LocalPath;
            const string testPath = "test";

            fileSystem.CurrentPath.Returns(testPath);
            fileSystem.GetFilesWithExtension(testPath, "Example.Spec.dll").Returns(new[] { location });

            var result = finder.GetSpecificationFiles(testPath, "Example.Spec");

            result.Should().HaveCount(1);
        }
Пример #2
0
        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);
            }
        }