public async Task WhenBuildingMetrics_ThenGetMetricsIsCalled_ForEachProviderSummary(int numberOfProviders)
        {
            periodEndSummaryFactory
            .Setup(x => x.CreatePeriodEndProviderSummary(It.IsAny <long>(), It.IsAny <long>(),
                                                         It.IsAny <byte>(), It.IsAny <short>()))
            .Returns(new PeriodEndProviderSummary(1, 1, 1, 1));

            var earnings = PeriodEndTestHelper.MultipleProviderDcEarnings(numberOfProviders);

            periodEndMetricsRepositoryMock
            .Setup(x => x.GetInLearningCount(It.IsAny <short>(), It.IsAny <byte>(), It.IsAny <CancellationToken>()))
            .ReturnsAsync(earnings.Select(x => new ProviderInLearningTotal {
                InLearningCount = 0, Ukprn = x.Ukprn
            }).ToList());

            dcMetricsDataContextMock
            .Setup(x => x.GetEarnings(It.IsAny <short>(), It.IsAny <byte>(),
                                      It.IsAny <CancellationToken>()))
            .ReturnsAsync(earnings);



            var service = moqer.Create <PeriodEndMetricsService>();

            await service.BuildMetrics(2, 1920, 1, CancellationToken.None).ConfigureAwait(false);

            periodEndSummaryFactory.Verify(x => x.CreatePeriodEndProviderSummary(
                                               It.IsAny <long>(), It.IsAny <long>(),
                                               It.IsAny <byte>(), It.IsAny <short>()), Times.Exactly(numberOfProviders));
        }
        public async Task WhenBuildingMetrics_ThenProviderSummariesAreAddedToPeriodEndSummary_AndCallsGetMetrics(int numberOfProviders)
        {
            dcMetricsDataContextMock
            .Setup(x => x.GetEarnings(It.IsAny <short>(), It.IsAny <byte>(),
                                      It.IsAny <CancellationToken>()))
            .ReturnsAsync(PeriodEndTestHelper.MultipleProviderDcEarnings(numberOfProviders));

            var service = moqer.Create <PeriodEndMetricsService>();

            await service.BuildMetrics(2, 1920, 1, CancellationToken.None).ConfigureAwait(false);

            periodEndSummary.Verify(x => x.AddProviderSummaries(It.Is <List <ProviderPeriodEndSummaryModel> >(y => y.Count == numberOfProviders)));
            periodEndSummary.Verify(x => x.GetMetrics(), Times.Once);
        }