public void SetUp() { employerAccountId = 112; jobId = 114; initialLevyBalance = 2000; initialTransferAllowance = 1000; remainingBalance = 900; remainingTransferAllowance = 800; collectionPeriod = new CollectionPeriod { AcademicYear = 1920, Period = 4 }; levyAccount = new LevyAccountModel { Balance = initialLevyBalance, TransferAllowance = initialTransferAllowance }; firstPriorityCalculatedRequiredLevyAmountAmountDue = 3000; firstPriorityUkprn = 668498390; secondPriorityCalculatedRequiredLevyAmountAmountDue = 1500; secondPriorityUkprn = 228733629; priorities = new List <EmployerProviderPriorityModel> { new EmployerProviderPriorityModel { EmployerAccountId = employerAccountId, Id = 116, Order = 2, Ukprn = secondPriorityUkprn }, new EmployerProviderPriorityModel { EmployerAccountId = employerAccountId, Id = 116, Order = 1, Ukprn = firstPriorityUkprn } }; levyTransactions = new List <LevyTransactionModel> { new LevyTransactionModel { AccountId = employerAccountId, Amount = 1500, MessagePayload = JsonConvert.SerializeObject(new CalculatedRequiredLevyAmount { AccountId = employerAccountId, AmountDue = secondPriorityCalculatedRequiredLevyAmountAmountDue, Ukprn = secondPriorityUkprn }) }, new LevyTransactionModel { AccountId = employerAccountId, Amount = 3000, MessagePayload = JsonConvert.SerializeObject(new CalculatedRequiredLevyAmount { AccountId = employerAccountId, AmountDue = firstPriorityCalculatedRequiredLevyAmountAmountDue, Ukprn = firstPriorityUkprn }) } }; prioritisedTransactions = new List <CalculatedRequiredLevyAmount> { new CalculatedRequiredLevyAmount { AccountId = employerAccountId, AmountDue = firstPriorityCalculatedRequiredLevyAmountAmountDue, Ukprn = firstPriorityUkprn }, new CalculatedRequiredLevyAmount { AccountId = employerAccountId, AmountDue = secondPriorityCalculatedRequiredLevyAmountAmountDue, Ukprn = secondPriorityUkprn } }; firstPriorityFundingSourcePaymentEvents = new List <FundingSourcePaymentEvent> { new EmployerCoInvestedFundingSourcePaymentEvent { AmountDue = 540 }, new LevyFundingSourcePaymentEvent { AmountDue = 700 }, new TransferFundingSourcePaymentEvent { AmountDue = 900 } }; secondPriorityFundingSourcePaymentEvents = new List <FundingSourcePaymentEvent> { new TransferFundingSourcePaymentEvent { AmountDue = 2500 } }; logger = new Mock <IPaymentLogger>(); dataContext = new Mock <IFundingSourceDataContext>(); levyBalanceService = new Mock <ILevyBalanceService>(); levyFundingSourceRepository = new Mock <ILevyFundingSourceRepository>(); levyBalanceService = new Mock <ILevyBalanceService>(); levyAccountCache = new Mock <IDataCache <LevyAccountModel> >(); calculatedRequiredLevyAmountPrioritisationService = new Mock <ICalculatedRequiredLevyAmountPrioritisationService>(); fundingSourcePaymentEventBuilder = new Mock <IFundingSourcePaymentEventBuilder>(); levyFundingSourceRepository.Setup(x => x.GetLevyAccount(employerAccountId, It.IsAny <CancellationToken>())) .ReturnsAsync(levyAccount); dataContext.Setup(x => x.GetEmployerProviderPriorities(employerAccountId, It.IsAny <CancellationToken>())) .ReturnsAsync(priorities); dataContext.Setup(x => x.GetTransactionsToBePaidByEmployer(employerAccountId, collectionPeriod)) .ReturnsAsync(levyTransactions); calculatedRequiredLevyAmountPrioritisationService .Setup(x => x.Prioritise(It.IsAny <List <CalculatedRequiredLevyAmount> >(), It.IsAny <List <(long Ukprn, int Order)> >())) .Returns(prioritisedTransactions); fundingSourcePaymentEventBuilder .Setup(x => x.BuildFundingSourcePaymentsForRequiredPayment(It.Is <CalculatedRequiredLevyAmount>(y => y.Ukprn == firstPriorityUkprn), employerAccountId, jobId)) .Returns(firstPriorityFundingSourcePaymentEvents); fundingSourcePaymentEventBuilder .Setup(x => x.BuildFundingSourcePaymentsForRequiredPayment(It.Is <CalculatedRequiredLevyAmount>(y => y.Ukprn == secondPriorityUkprn), employerAccountId, jobId)) .Returns(secondPriorityFundingSourcePaymentEvents); levyBalanceService.SetupGet(x => x.RemainingBalance).Returns(remainingBalance); levyBalanceService.SetupGet(x => x.RemainingTransferAllowance).Returns(remainingTransferAllowance); service = new FundingSourceEventGenerationService( logger.Object, dataContext.Object, levyBalanceService.Object, levyFundingSourceRepository.Object, levyAccountCache.Object, calculatedRequiredLevyAmountPrioritisationService.Object, fundingSourcePaymentEventBuilder.Object); }
public void SetUp() { ukprn = 3383742; accountId = 78934234; message = new ProcessUnableToFundTransferFundingSourcePayment { AccountId = accountId, Ukprn = ukprn }; calculatedRequiredLevyAmount = new CalculatedRequiredLevyAmount { Ukprn = ukprn }; levyAccountModel = new LevyAccountModel { AccountId = accountId, Balance = 3000, TransferAllowance = 2000 }; mappedLevyAccountModel = new LevyAccountModel { AccountId = accountId, Balance = 3000, TransferAllowance = 2000 }; fundingSourcePaymentEvents = new List <FundingSourcePaymentEvent> { new LevyFundingSourcePaymentEvent { AccountId = accountId, Ukprn = ukprn, AmountDue = 1000 } }; paymentLogger = new Mock <IPaymentLogger>(); mapper = new Mock <IMapper>(); monthEndCache = new Mock <IDataCache <bool> >(); levyAccountCache = new Mock <IDataCache <LevyAccountModel> >(); levyBalanceService = new Mock <ILevyBalanceService>(); fundingSourcePaymentEventBuilder = new Mock <IFundingSourcePaymentEventBuilder>(); levyTransactionBatchStorageService = new Mock <ILevyTransactionBatchStorageService>(); mapper.Setup(x => x.Map <CalculatedRequiredLevyAmount>(message)) .Returns(calculatedRequiredLevyAmount); mapper.Setup(x => x.Map <LevyAccountModel>(levyAccountModel)) .Returns(mappedLevyAccountModel); levyAccountCache.Setup(x => x.TryGet(CacheKeys.LevyBalanceKey, It.IsAny <CancellationToken>())) .ReturnsAsync(new ConditionalValue <LevyAccountModel>(true, levyAccountModel)); fundingSourcePaymentEventBuilder.Setup(x => x.BuildFundingSourcePaymentsForRequiredPayment( It.IsAny <CalculatedRequiredLevyAmount>(), accountId, It.IsAny <long>())) .Returns(fundingSourcePaymentEvents); service = new TransferFundingSourceEventGenerationService( paymentLogger.Object, mapper.Object, monthEndCache.Object, levyAccountCache.Object, levyBalanceService.Object, fundingSourcePaymentEventBuilder.Object, levyTransactionBatchStorageService.Object ); }