public void GivenTier3ThatFails_ThenTheReportShouldBeRanForEachTier4()
        {
            var hierarchy =
                new List <CostCentre>()
            {
                new CostCentre {
                    Tier3 = "A", Tier4 = "B"
                },
                new CostCentre {
                    Tier3 = "A", Tier4 = "C"
                }
            }.GroupBy(x => x.Tier3, x => x);

            var engineFactory =
                new DummyEngineFactory(
                    returnEmpty: hierarchy.Single().Select(x => Resql.Bcr(tier4: x.Tier4)),
                    throws: new[] { Resql.Bcr(tier3: hierarchy.Single().Key) }
                    );

            var bcrReport = new BcrReport(engineFactory, new NullLogging());

            bcrReport.RunBcr(hierarchy);

            hierarchy.Single().ToList().ForEach(
                c => { engineFactory.Mock.Verify(x => x.RunReport(Resql.BcrTier4(c.Tier4)), Times.Once); });
        }
        public void GivenTier4ThatFails_ThenTheReportShouldBeRanForTheCostCentre()
        {
            var hierarchy =
                new List <CostCentre>()
            {
                new CostCentre {
                    Tier3 = "A", Tier4 = "B", Code = "C"
                }
            }.GroupBy(
                x => x.Tier3,
                x => x);

            var engineFactory =
                new DummyEngineFactory(
                    returnEmpty: new[] { Resql.Bcr(costCentre: hierarchy.Single().Single().Code) },
                    throws: new[]
            {
                Resql.Bcr(tier3: hierarchy.Single().Key), Resql.Bcr(tier4: hierarchy.Single().Single().Tier4)
            }
                    );

            var bcrReport = new BcrReport(engineFactory, new NullLogging());

            bcrReport.RunBcr(hierarchy);

            engineFactory.Mock.Verify(
                x => x.RunReport(Resql.BcrCostCentre(hierarchy.Single().Single().Code)),
                Times.Once);
        }
        public void GivenOneTier3_ThenTheReportShouldBeRanForThatTier3()
        {
            var hierarchy = new List <CostCentre>()
            {
                new CostCentre {
                    Tier3 = "A"
                }
            }.GroupBy(x => x.Tier3, x => x);

            var engineFactory =
                new DummyEngineFactory(
                    new[] { Resql.Bcr(tier3: hierarchy.Single().Single().Tier3) }
                    );

            var bcrReport = new BcrReport(engineFactory, new NullLogging());

            bcrReport.RunBcr(hierarchy);

            engineFactory.Mock.Verify(x => x.RunReport(Resql.BcrTier3(hierarchy.Single().Key)), Times.Once);
        }