public virtual void AddDataLockTypeCounts(decimal total, DataLockTypeCounts dataLockedCounts, decimal alreadyPaidDataLockedEarnings) { actualTotalDataLocked = total; dataLocked = dataLockedCounts ?? throw new ArgumentNullException(nameof(dataLockedCounts)); alreadyPaidDataLocked = alreadyPaidDataLockedEarnings; }
public void SetUp() { dcEarnings = TestsHelper.DefaultDcEarnings; dasEarnings = TestsHelper.DefaultDasEarnings; dataLocks = TestsHelper.DefaultDataLockedEarnings; requiredPayments = TestsHelper.DefaultRequiredPayments; heldBackCompletionPayments = TestsHelper.DefaultHeldBackCompletionPayments; }
public SubmissionSummary(long ukprn, long jobId, byte collectionPeriod, short academicYear) { Ukprn = ukprn; JobId = jobId; CollectionPeriod = collectionPeriod; AcademicYear = academicYear; dcEarnings = new List <TransactionTypeAmounts>(); dasEarnings = new List <TransactionTypeAmounts>(); dataLocked = new DataLockTypeCounts(); requiredPayments = new List <TransactionTypeAmounts>(); heldBackCompletionPayments = new ContractTypeAmounts(); yearToDatePayments = new ContractTypeAmounts(); }
private void CalculateDataLockTypeCounts() { var allDataLockTypeCounts = allSummaries.Select(x => x.DataLockTypeCounts).ToList(); dataLockTypeCounts = new DataLockTypeCounts { DataLock1 = allDataLockTypeCounts.Sum(x => x.DataLock1), DataLock2 = allDataLockTypeCounts.Sum(x => x.DataLock2), DataLock3 = allDataLockTypeCounts.Sum(x => x.DataLock3), DataLock4 = allDataLockTypeCounts.Sum(x => x.DataLock4), DataLock5 = allDataLockTypeCounts.Sum(x => x.DataLock5), DataLock6 = allDataLockTypeCounts.Sum(x => x.DataLock6), DataLock7 = allDataLockTypeCounts.Sum(x => x.DataLock7), DataLock8 = allDataLockTypeCounts.Sum(x => x.DataLock8), DataLock9 = allDataLockTypeCounts.Sum(x => x.DataLock9), DataLock10 = allDataLockTypeCounts.Sum(x => x.DataLock10), DataLock11 = allDataLockTypeCounts.Sum(x => x.DataLock11), DataLock12 = allDataLockTypeCounts.Sum(x => x.DataLock12) }; }
public void SetUp() { moqer = AutoMock.GetLoose(); dcEarnings = TestsHelper.DefaultDcEarnings; dasEarnings = TestsHelper.DefaultDasEarnings; dataLocks = TestsHelper.DefaultDataLockedEarnings; requiredPayments = TestsHelper.DefaultRequiredPayments; totalDataLockedEarnings = TestsHelper.DefaultDataLockedTotal; var dcMetricsDataContext = moqer.Mock <IDcMetricsDataContext>(); dcMetricsDataContext.Setup(ctx => ctx.GetEarnings(It.IsAny <long>(), It.IsAny <short>(), It.IsAny <byte>(), It.IsAny <CancellationToken>())) .ReturnsAsync(dcEarnings); moqer.Mock <IDcMetricsDataContextFactory>() .Setup(factory => factory.CreateContext(It.IsAny <short>())) .Returns(dcMetricsDataContext.Object); var mockSubmissionSummary = moqer.Mock <ISubmissionSummary>(); mockSubmissionSummary.Setup(x => x.GetMetrics()) .Returns(new SubmissionSummaryModel { SubmissionMetrics = new ContractTypeAmountsVerbose(), DasEarnings = new ContractTypeAmountsVerbose(), DataLockMetrics = new DataLockCountsModel(), DcEarnings = new ContractTypeAmounts(), EarningsMetrics = new List <EarningsModel>(), HeldBackCompletionPayments = new ContractTypeAmounts(), RequiredPayments = new ContractTypeAmounts(), RequiredPaymentsMetrics = new List <RequiredPaymentsModel>(), YearToDatePayments = new ContractTypeAmounts() }); moqer.Mock <ISubmissionSummaryFactory>() .Setup(factory => factory.Create(It.IsAny <long>(), It.IsAny <long>(), It.IsAny <short>(), It.IsAny <byte>())) .Returns(mockSubmissionSummary.Object); moqer.Mock <ISubmissionMetricsRepository>() .Setup(repo => repo.GetDasEarnings(It.IsAny <long>(), It.IsAny <long>(), It.IsAny <CancellationToken>())) .ReturnsAsync(dasEarnings); moqer.Mock <ISubmissionMetricsRepository>() .Setup(repo => repo.GetDasEarnings(It.IsAny <long>(), It.IsAny <long>(), It.IsAny <CancellationToken>())) .ReturnsAsync(dasEarnings); moqer.Mock <ISubmissionMetricsRepository>() .Setup(repo => repo.GetDataLockedEarnings(It.IsAny <long>(), It.IsAny <long>(), It.IsAny <CancellationToken>())) .ReturnsAsync(dataLocks); moqer.Mock <ISubmissionMetricsRepository>() .Setup(repo => repo.GetDataLockedEarningsTotal(It.IsAny <long>(), It.IsAny <long>(), It.IsAny <CancellationToken>())) .ReturnsAsync(TestsHelper.DefaultDataLockedTotal); moqer.Mock <ISubmissionMetricsRepository>() .Setup(repo => repo.GetAlreadyPaidDataLockedEarnings(It.IsAny <long>(), It.IsAny <long>(), It.IsAny <CancellationToken>())) .ReturnsAsync(TestsHelper.AlreadyPaidDataLockedEarnings); moqer.Mock <ISubmissionMetricsRepository>() .Setup(repo => repo.GetRequiredPayments(It.IsAny <long>(), It.IsAny <long>(), It.IsAny <CancellationToken>())) .ReturnsAsync(requiredPayments); moqer.Mock <ISubmissionMetricsRepository>() .Setup(repo => repo.GetHeldBackCompletionPaymentsTotal(It.IsAny <long>(), It.IsAny <long>(), It.IsAny <CancellationToken>())) .ReturnsAsync(TestsHelper.DefaultHeldBackCompletionPayments); moqer.Mock <ISubmissionMetricsRepository>() .Setup(repo => repo.GetYearToDatePaymentsTotal(It.IsAny <long>(), It.IsAny <short>(), It.IsAny <byte>(), It.IsAny <CancellationToken>())) .ReturnsAsync(TestsHelper.DefaultYearToDateAmounts); }
public void SetUp() { inMemoryMetricsQueryDataContext = new InMemoryMetricsQueryDataContext(); moqer = AutoMock.GetLoose(); dcEarnings = TestsHelper.DefaultDcEarnings; dasEarnings = TestsHelper.DefaultDasEarnings; dataLocks = TestsHelper.DefaultDataLockedEarnings; var dcMetricsDataContext = moqer.Mock <IDcMetricsDataContext>(); dcMetricsDataContext.Setup(ctx => ctx.GetEarnings(It.IsAny <long>(), It.IsAny <short>(), It.IsAny <byte>(), It.IsAny <CancellationToken>())) .ReturnsAsync(dcEarnings); moqer.Mock <IDcMetricsDataContextFactory>() .Setup(factory => factory.CreateContext(It.IsAny <short>())) .Returns(dcMetricsDataContext.Object); latestSuccessfulJob = moqer.Mock <LatestSuccessfulJobModel>().Object; latestSuccessfulJob.Ukprn = 1234; latestSuccessfulJob.CollectionPeriod = 1; latestSuccessfulJob.AcademicYear = 1920; latestSuccessfulJob.DcJobId = 123; moqer.Mock <ISubmissionSummaryFactory>() .Setup(factory => factory.Create(It.IsAny <long>(), It.IsAny <long>(), It.IsAny <short>(), It.IsAny <byte>())) .Returns((long ukprn, long jobId, short academicYear, byte collectionPeriod) => new SubmissionSummary(ukprn, jobId, collectionPeriod, academicYear)); var jobsRepository = moqer.Mock <ISubmissionJobsRepository>(); jobsRepository.Setup(x => x.GetLatestSuccessfulJobForProvider(It.IsAny <long>(), It.IsAny <short>(), It.IsAny <byte>())) .ReturnsAsync(latestSuccessfulJob); moqer.Mock <ISubmissionJobsDataContext>(); submissionMetricsRepository = moqer.Mock <ISubmissionMetricsRepository>(); submissionMetricsRepository.Setup(repo => repo.GetDasEarnings(It.IsAny <long>(), It.IsAny <long>(), It.IsAny <CancellationToken>())) .ReturnsAsync(dasEarnings); submissionMetricsRepository.Setup(repo => repo.GetDasEarnings(It.IsAny <long>(), It.IsAny <long>(), It.IsAny <CancellationToken>())) .ReturnsAsync(dasEarnings); submissionMetricsRepository.Setup(repo => repo.GetDataLockedEarnings(It.IsAny <long>(), It.IsAny <long>(), It.IsAny <CancellationToken>())) .ReturnsAsync(dataLocks); submissionMetricsRepository.Setup(repo => repo.GetDataLockedEarningsTotal(It.IsAny <long>(), It.IsAny <long>(), It.IsAny <CancellationToken>())) .ReturnsAsync(TestsHelper.DefaultDataLockedTotal); submissionMetricsRepository.Setup(repo => repo.GetAlreadyPaidDataLockedEarnings(It.IsAny <long>(), It.IsAny <long>(), It.IsAny <CancellationToken>())) .ReturnsAsync(TestsHelper.AlreadyPaidDataLockedEarnings); submissionMetricsRepository.Setup(repo => repo.GetHeldBackCompletionPaymentsTotal(It.IsAny <long>(), It.IsAny <long>(), It.IsAny <CancellationToken>())) .ReturnsAsync(TestsHelper.DefaultHeldBackCompletionPayments); submissionMetricsRepository.Setup(repo => repo.GetYearToDatePaymentsTotal(It.IsAny <long>(), It.IsAny <short>(), It.IsAny <byte>(), It.IsAny <CancellationToken>())) .ReturnsAsync(TestsHelper.DefaultYearToDateAmounts); var queryDataContext = moqer.Mock <IMetricsQueryDataContextFactory>(); queryDataContext.Setup(f => f.Create()) .Returns(inMemoryMetricsQueryDataContext); var realSubmissionMetricsRepository = moqer.Create <SubmissionMetricsRepository>( new NamedParameter("metricsQueryDataContextFactory", queryDataContext.Object), new AutowiringParameter()); submissionMetricsRepository .Setup(repo => repo.GetRequiredPayments(It.IsAny <long>(), It.IsAny <long>(), It.IsAny <CancellationToken>())) .Returns(async(long ukprn, long jobId, CancellationToken cancellationToken) => await realSubmissionMetricsRepository.GetRequiredPayments(ukprn, jobId, cancellationToken)); }