Example #1
0
        public void ShouldReportSuccessWhenAllSingleRuleReportsReportSuccess()
        {
            //GIVEN
            var ruleFactory       = Substitute.For <IRuleReportFactory>();
            var report            = new AnalysisReportInProgress(ruleFactory);
            var ruleDescription1  = Any.Instance <RuleDescription>();
            var ruleDescription2  = Any.Instance <RuleDescription>();
            var ruleDescription3  = Any.Instance <RuleDescription>();
            var singleRuleReport1 = SuccessfulRuleReport();
            var singleRuleReport2 = SuccessfulRuleReport();
            var singleRuleReport3 = SuccessfulRuleReport();

            ruleFactory.EmptyReportFor(ruleDescription1).Returns(singleRuleReport1);
            ruleFactory.EmptyReportFor(ruleDescription2).Returns(singleRuleReport2);
            ruleFactory.EmptyReportFor(ruleDescription3).Returns(singleRuleReport3);

            report.FinishedEvaluatingRule(ruleDescription1);
            report.FinishedEvaluatingRule(ruleDescription2);
            report.FinishedEvaluatingRule(ruleDescription3);

            //WHEN
            var isFailure = report.IsFailure();

            //THEN
            isFailure.Should().BeFalse();
        }
Example #2
0
        public void ShouldPrintAllReportsInTheSameOrderTheyWereReceived()
        {
            //GIVEN
            var ruleReportFactory = Substitute.For <IRuleReportFactory>();
            var resultBuilder     = Substitute.For <IResultBuilder>();
            var ruleDescription1  = Any.Instance <RuleDescription>();
            var ruleDescription2  = Any.Instance <RuleDescription>();
            var ruleDescription3  = Any.Instance <RuleDescription>();
            var report            = new AnalysisReportInProgress(ruleReportFactory);
            var ruleReport1       = Substitute.For <ISingleRuleReport>();
            var ruleReport2       = Substitute.For <ISingleRuleReport>();
            var ruleReport3       = Substitute.For <ISingleRuleReport>();

            ruleReportFactory.EmptyReportFor(ruleDescription1).Returns(ruleReport1);
            ruleReportFactory.EmptyReportFor(ruleDescription2).Returns(ruleReport2);
            ruleReportFactory.EmptyReportFor(ruleDescription3).Returns(ruleReport3);

            report.FinishedEvaluatingRule(ruleDescription1);
            report.FinishedEvaluatingRule(ruleDescription2);
            report.FinishedEvaluatingRule(ruleDescription3);

            //WHEN
            report.PutContentInto(resultBuilder);

            //THEN
            Received.InOrder(() =>
            {
                ruleReport1.AppendTo(resultBuilder);
                resultBuilder.AppendRuleSeparator();
                ruleReport2.AppendTo(resultBuilder);
                resultBuilder.AppendRuleSeparator();
                ruleReport3.AppendTo(resultBuilder);
            });
        }