Пример #1
0
        private static void RegisterFormatters(IEnumerable<MessageFormatter> formatters, SpecExtractor specExtractor, RunSpecCommand command)
        {
            var requiredFormatters = formatters
                .Select(
                    x =>
                    new {Attribute = x.GetType().GetCustomAttribute<MessageFormatterTypeKeyAttribute>(), Formatter = x})
                .Where(x => x.Attribute != null)
                .Where(x => command.Formatters.Any(y => y.Type == x.Attribute.Type))
                .Select(x => new
                    {
                        x.Formatter,
                        Categories =
                                 command.Formatters.Where(y => y.Type == x.Attribute.Type)
                                        .Select(y => new SpecificationCategory(y.ContextName, y.CategoryName))
                                        .ToArray()
                    })
                .ToArray();

            foreach (var entry in requiredFormatters)
            {
                foreach (var category in entry.Categories)
                {
                    specExtractor.RegisterFormatter(category, entry.Formatter);
                }
            }
        }
Пример #2
0
        public void DescribeSpec(RunSpecCommand command)
        {
            var formatters = ExtractMessageFormatters(command.FormattersPath);

            var assembly = Assembly.LoadFrom(command.AssemblyPath);
            var specExtractor = new SpecExtractor();

            RegisterFormatters(formatters, specExtractor, command);

            var specs = command.Action == ActionInfo.Describe ? specExtractor.DescribeSuite(assembly) : specExtractor.RunSuite(assembly);

            var assemblyName = Path.GetFileNameWithoutExtension(command.AssemblyPath);

            var printer = new RunSpecCommandPrinterEvaluator().GetCommandPrinter(command.PrintInfo.Format, command.PrintInfo.Destination, assemblyName);
            printer.Print(specs);
        }
Пример #3
0
        public void DescribeAssembly(DokimiConfig config)
        {
            var files = RunnerHelper.GetFileList(config.Source.IncludePath);

            foreach (var file in files)
            {
                var appDomain = AppDomain.CreateDomain(file, AppDomain.CurrentDomain.Evidence);
                var runner = (AppDomainRunner)appDomain.CreateInstanceAndUnwrap(Assembly.GetExecutingAssembly().FullName, (typeof (AppDomainRunner)).FullName);

                var command = new RunSpecCommand(file, config.Formatters.IncludePath, config.Formatters.Formatters, config.Print, config.Action);

                runner.DescribeSpec(command);
            }
        }