示例#1
0
 private void AddSpecificationListeners()
 {
     foreach (var listener in SpecificationProcessingListeners)
     {
         SpecificationCommand.AddSpecificationListener(listener);
     }
 }
示例#2
0
        public ConcordionBuilder()
        {
            SpecificationLocator = new ClassNameBasedSpecificationLocator();
            Source               = null;
            Target               = null;
            CommandRegistry      = new CommandRegistry();
            DocumentParser       = new DocumentParser(CommandRegistry);
            EvaluatorFactory     = new SimpleEvaluatorFactory();
            SpecificationCommand = new SpecificationCommand();
            AssertEqualsCommand  = new AssertEqualsCommand();
            AssertTrueCommand    = new AssertTrueCommand();
            AssertFalseCommand   = new AssertFalseCommand();
            ExecuteCommand       = new ExecuteCommand();
            RunCommand           = new RunCommand();
            VerifyRowsCommand    = new VerifyRowsCommand();
            EchoCommand          = new EchoCommand();
            ExceptionRenderer    = new ExceptionRenderer();

            // Set up the commands

            CommandRegistry.Register("", "specification", SpecificationCommand);
            WithApprovedCommand(HtmlFramework.NAMESPACE_CONCORDION_2007, "run", RunCommand);
            WithApprovedCommand(HtmlFramework.NAMESPACE_CONCORDION_2007, "execute", ExecuteCommand);
            WithApprovedCommand(HtmlFramework.NAMESPACE_CONCORDION_2007, "set", new SetCommand());
            WithApprovedCommand(HtmlFramework.NAMESPACE_CONCORDION_2007, "assertEquals", AssertEqualsCommand);
            WithApprovedCommand(HtmlFramework.NAMESPACE_CONCORDION_2007, "assertTrue", AssertTrueCommand);
            WithApprovedCommand(HtmlFramework.NAMESPACE_CONCORDION_2007, "assertFalse", AssertFalseCommand);
            WithApprovedCommand(HtmlFramework.NAMESPACE_CONCORDION_2007, "verifyRows", VerifyRowsCommand);
            WithApprovedCommand(HtmlFramework.NAMESPACE_CONCORDION_2007, "echo", EchoCommand);

            // Wire up the command listeners

            var assertEqualsResultRenderer = new AssertEqualsResultRenderer();

            AssertEqualsCommand.SuccessReported += assertEqualsResultRenderer.SuccessReportedEventHandler;
            AssertEqualsCommand.FailureReported += assertEqualsResultRenderer.FailureReportedEventHandler;
            AssertTrueCommand.SuccessReported   += assertEqualsResultRenderer.SuccessReportedEventHandler;
            AssertTrueCommand.FailureReported   += assertEqualsResultRenderer.FailureReportedEventHandler;
            AssertFalseCommand.SuccessReported  += assertEqualsResultRenderer.SuccessReportedEventHandler;
            AssertFalseCommand.FailureReported  += assertEqualsResultRenderer.FailureReportedEventHandler;

            var verifyRowsCommandRenderer = new VerifyRowResultRenderer();

            VerifyRowsCommand.MissingRowFound += verifyRowsCommandRenderer.MissingRowFoundEventHandler;
            VerifyRowsCommand.SurplusRowFound += verifyRowsCommandRenderer.SurplusRowFoundEventHandler;

            var runResultRenderer = new RunResultRenderer();

            RunCommand.SuccessfulRunReported += runResultRenderer.SuccessfulRunReportedEventHandler;
            RunCommand.FailedRunReported     += runResultRenderer.FailedRunReportedEventHandler;
            RunCommand.IgnoredRunReported    += runResultRenderer.IgnoredRunReportedEventHandler;

            var documentStructureImprovementRenderer = new DocumentStructureImprovementRenderer();

            DocumentParser.DocumentParsing += documentStructureImprovementRenderer.DocumentParsingEventHandler;

            var stylesheetEmbeddingRenderer = new StylesheetEmbeddingRenderer(HtmlFramework.EMBEDDED_STYLESHEET_RESOURCE);

            DocumentParser.DocumentParsing += stylesheetEmbeddingRenderer.DocumentParsingEventHandler;
        }
示例#3
0
        public ConcordionBuilder()
        {
            BuildListeners = new List <IConcordionBuildListener>();
            SpecificationProcessingListeners = new List <ISpecificationProcessingListener>();
            ResourceToCopyMap  = new Dictionary <string, Resource>();
            ExceptionListeners = new List <IExceptionCaughtListener>();

            SpecificationLocator = new ClassNameBasedSpecificationLocator();
            Source               = null;
            Target               = null;
            CommandRegistry      = new CommandRegistry();
            DocumentParser       = new DocumentParser(CommandRegistry);
            EvaluatorFactory     = new SimpleEvaluatorFactory();
            SpecificationCommand = new SpecificationCommand();
            AssertEqualsCommand  = new AssertEqualsCommand();
            AssertTrueCommand    = new AssertTrueCommand();
            AssertFalseCommand   = new AssertFalseCommand();
            ExecuteCommand       = new ExecuteCommand();
            RunCommand           = new RunCommand();
            VerifyRowsCommand    = new VerifyRowsCommand();
            EchoCommand          = new EchoCommand();
            ExceptionRenderer    = new ExceptionRenderer();

            WithExceptionListener(ExceptionRenderer);

            // Set up the commands

            CommandRegistry.Register("", "specification", SpecificationCommand);

            // Wire up the command listeners

            var assertResultRenderer = new AssertResultRenderer();

            WithAssertEqualsListener(assertResultRenderer);
            WithAssertTrueListener(assertResultRenderer);
            WithAssertFalseListener(assertResultRenderer);
            WithVerifyRowsListener(new VerifyRowResultRenderer());
            WithRunListener(new RunResultRenderer());
            WithDocumentParsingListener(new DocumentStructureImprover());
            WithDocumentParsingListener(new MetadataCreator());
            WithEmbeddedCss(HtmlFramework.EMBEDDED_STYLESHEET_RESOURCE);
        }
示例#4
0
        public Concordion Build()
        {
            Check.IsFalse(this.m_BuiltAlready, "ConcordionBuilder currently does not support calling build() twice");
            this.m_BuiltAlready = true;

            WithApprovedCommand(HtmlFramework.NAMESPACE_CONCORDION_2007, "run", RunCommand);
            WithApprovedCommand(HtmlFramework.NAMESPACE_CONCORDION_2007, "execute", ExecuteCommand);
            WithApprovedCommand(HtmlFramework.NAMESPACE_CONCORDION_2007, "set", new SetCommand());
            WithApprovedCommand(HtmlFramework.NAMESPACE_CONCORDION_2007, "assertEquals", AssertEqualsCommand);
            WithApprovedCommand(HtmlFramework.NAMESPACE_CONCORDION_2007, "assertTrue", AssertTrueCommand);
            WithApprovedCommand(HtmlFramework.NAMESPACE_CONCORDION_2007, "assertFalse", AssertFalseCommand);
            WithApprovedCommand(HtmlFramework.NAMESPACE_CONCORDION_2007, "verifyRows", VerifyRowsCommand);
            WithApprovedCommand(HtmlFramework.NAMESPACE_CONCORDION_2007, "echo", EchoCommand);

            if (Target == null)
            {
                Target = new FileTarget(BaseOutputDir ?? Directory.GetCurrentDirectory());
            }

            SetAllRunners();

            SpecificationCommand.AddSpecificationListener(new BreadCrumbRenderer(this.Source));
            SpecificationCommand.AddSpecificationListener(new PageFooterRenderer(this.Target));
            SpecificationCommand.AddSpecificationListener(new SpecificationRenderer(this.Target));

            SpecificationReader = new XmlSpecificationReader(Source, DocumentParser);

            CopyResources();

            AddSpecificationListeners();

            foreach (var concordionBuildListener in BuildListeners)
            {
                concordionBuildListener.ConcordionBuilt(new ConcordionBuildEvent(Target));
            }

            return(new Concordion(SpecificationLocator, SpecificationReader, EvaluatorFactory));
        }