public async Task CreateCollectionPeriodToleranceModel(byte collectionPeriod, short academicYear, decimal lowerTolerance, decimal upperTolerance)
        {
            collectionPeriodToleranceModel = new CollectionPeriodToleranceModel
            {
                CollectionPeriod = collectionPeriod,
                AcademicYear = academicYear,
                SubmissionToleranceLower = lowerTolerance,
                SubmissionToleranceUpper = upperTolerance
            };

            await RemoveCollectionPeriodToleranceModel(collectionPeriod, academicYear);

            metricsTestDataContext.Add(collectionPeriodToleranceModel);
            await metricsTestDataContext.SaveChangesAsync();
        }
示例#2
0
        public GetCollectionPeriodToleranceFixture()
        {
            var fixture = new Fixture();

            academicYear                   = fixture.Create <short>();
            collectionPeriod               = fixture.Create <byte>();
            persistenceDataContext         = new InMemoryMetricsPersistenceDataContext();
            metricsQueryDataContextFactory = new Mock <IMetricsQueryDataContextFactory>();
            logger = new Mock <IPaymentLogger>();
            sut    = new SubmissionMetricsRepository(persistenceDataContext, metricsQueryDataContextFactory.Object, logger.Object);

            matchingCollectionPeriodToleranceModel = fixture.Create <CollectionPeriodToleranceModel>();
            matchingCollectionPeriodToleranceModel.AcademicYear     = academicYear;
            matchingCollectionPeriodToleranceModel.CollectionPeriod = collectionPeriod;
            nonMatchingCollectionPeriodToleranceModels = fixture.Create <List <CollectionPeriodToleranceModel> >();
        }
        public void SetUp()
        {
            moqer = AutoMock.GetLoose();
            var fixture = new Fixture();
            var random  = new Random();


            dcNegativeEarningsResult = fixture.CreateMany <ProviderNegativeEarningsTotal>(10).ToList();
            dcNegativeEarningsResult.ForEach(x =>
            {
                var randomInt = random.Next(0, 2);

                x.ContractType          = randomInt == 1 ? ContractType.Act1 : ContractType.Act2;
                x.NegativeEarningsTotal = Math.Abs(x.NegativeEarningsTotal);
            });

            periodEndSummary          = moqer.Mock <IPeriodEndSummary>();
            periodEndProviderSummary  = moqer.Mock <IPeriodEndProviderSummary>();
            periodEndSummaryFactory   = moqer.Mock <IPeriodEndSummaryFactory>();
            collectionPeriodTolerance = new CollectionPeriodToleranceModel();
            telemetryMock             = moqer.Mock <ITelemetry>();


            periodEndSummary
            .Setup(x => x.GetMetrics())
            .Returns(new PeriodEndSummaryModel());

            periodEndSummary
            .Setup(x => x.AddProviderSummaries(It.IsAny <List <ProviderPeriodEndSummaryModel> >()));

            periodEndSummaryFactory
            .Setup(x => x.CreatePeriodEndProviderSummary(It.IsAny <long>(), It.IsAny <long>(), It.IsAny <byte>(), It.IsAny <short>()))
            .Returns(new PeriodEndProviderSummary(1, 1, 1, 1));

            periodEndSummary.Setup(x => x.GetMetrics())
            .Returns(new PeriodEndSummaryModel());

            periodEndProviderSummary
            .Setup(x => x.GetMetrics())
            .Returns(new ProviderPeriodEndSummaryModel());

            periodEndSummaryFactory
            .Setup(x => x.CreatePeriodEndSummary(It.IsAny <long>(), It.IsAny <byte>(), It.IsAny <short>()))
            .Returns(periodEndSummary.Object);

            dcMetricsDataContextMock = moqer.Mock <IDcMetricsDataContext>();
            dcMetricsDataContextMock
            .Setup(x => x.GetEarnings(It.IsAny <short>(), It.IsAny <byte>(), It.IsAny <CancellationToken>()))
            .ReturnsAsync(dcEarnings);

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

            var dcMetricsDataContextFactoryMock = moqer.Mock <IDcMetricsDataContextFactory>();

            dcMetricsDataContextFactoryMock
            .Setup(x => x.CreateContext(It.IsAny <short>()))
            .Returns(dcMetricsDataContextMock.Object);

            periodEndMetricsRepositoryMock = moqer.Mock <IPeriodEndMetricsRepository>();
            periodEndMetricsRepositoryMock
            .Setup(x => x.GetTransactionTypesByContractType(It.IsAny <short>(), It.IsAny <byte>(), It.IsAny <CancellationToken>()))
            .ReturnsAsync(new List <ProviderTransactionTypeAmounts>());
            periodEndMetricsRepositoryMock
            .Setup(x => x.GetFundingSourceAmountsByContractType(It.IsAny <short>(), It.IsAny <byte>(), It.IsAny <CancellationToken>()))
            .ReturnsAsync(new List <ProviderFundingSourceAmounts>());
            periodEndMetricsRepositoryMock
            .Setup(x => x.GetYearToDatePayments(It.IsAny <short>(), It.IsAny <byte>(), It.IsAny <CancellationToken>()))
            .ReturnsAsync(new List <ProviderContractTypeAmounts>());
            periodEndMetricsRepositoryMock
            .Setup(x => x.GetDataLockedEarningsTotals(It.IsAny <short>(), It.IsAny <byte>(), It.IsAny <CancellationToken>()))
            .ReturnsAsync(new List <ProviderFundingLineTypeAmounts>());
            periodEndMetricsRepositoryMock
            .Setup(x => x.GetAlreadyPaidDataLockedEarnings(It.IsAny <short>(), It.IsAny <byte>(), It.IsAny <CancellationToken>()))
            .ReturnsAsync(new List <ProviderFundingLineTypeAmounts>());
            periodEndMetricsRepositoryMock
            .Setup(x => x.GetHeldBackCompletionPaymentsTotals(It.IsAny <short>(), It.IsAny <byte>(), It.IsAny <CancellationToken>()))
            .ReturnsAsync(new List <ProviderContractTypeAmounts>());
            periodEndMetricsRepositoryMock
            .Setup(x => x.GetPeriodEndProviderDataLockTypeCounts(It.IsAny <short>(), It.IsAny <byte>(), It.IsAny <CancellationToken>()))
            .ReturnsAsync(new List <PeriodEndProviderDataLockTypeCounts>());
            periodEndMetricsRepositoryMock
            .Setup(x => x.GetInLearningCount(It.IsAny <short>(), It.IsAny <byte>(), It.IsAny <CancellationToken>()))
            .ReturnsAsync(new List <ProviderInLearningTotal> {
                new ProviderInLearningTotal {
                    InLearningCount = 0, Ukprn = dcEarnings.Select(x => x.Ukprn).First()
                }
            });
            periodEndMetricsRepositoryMock
            .Setup(x => x.GetCollectionPeriodTolerance(It.IsAny <byte>(), It.IsAny <short>(), It.IsAny <CancellationToken>()))
            .ReturnsAsync(collectionPeriodTolerance);
        }
示例#4
0
 public void Assert_CorrectMatchingModelIsReturned(CollectionPeriodToleranceModel result)
 {
     matchingCollectionPeriodToleranceModel.Should().BeSameAs(result);
     matchingCollectionPeriodToleranceModel.AcademicYear.Should().Be(result.AcademicYear);
     matchingCollectionPeriodToleranceModel.CollectionPeriod.Should().Be(result.CollectionPeriod);
 }