Пример #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);
        }