public async Task TransferPrepayment() { Console.WriteLine("TransferPrepayment"); var logger = ServiceScope.ServiceProvider.GetService <ILogger <FundingTest> >(); var unitOfWork = CreateUnitOfWork.Timestamp(GetUniqueNow()); var incomeAmount = 100m; var salesTaxAmount = 5m; var totalAmount = incomeAmount + salesTaxAmount; var salesTaxJurisdiction = "XX"; // Create references. // var funderReference = CreateFunderReference.FromTimestamp(GetUniqueNow()); logger.LogInformation($"Funder reference = {funderReference}"); var fundableReference = CreateFundableReference.FromTimestamp(GetUniqueNow()); logger.LogInformation($"Fundable reference = {fundableReference}"); // Create funder and set funds received. // var funderId = await FundingMicroService.AllocateFunderAsync(funderReference); logger.LogInformation($"Funder ID = {funderId}"); await FundingMicroService.SetFundsReceivedAsync(funderId, fundableReference, totalAmount, unitOfWork.Next()); logger.LogInformation($"Set {totalAmount:c} funds received."); var eventCount = await EventProcessorMicroService.ProcessPendingEvents(); logger.LogInformation($"{eventCount} events processed."); // Create fundable and set funds required. // var fundableId = await FundingMicroService.AllocateFundableAsync(fundableReference); logger.LogInformation($"Fundable ID = {fundableId}"); await FundingMicroService.SetFundsRequiredAsync(fundableId, incomeAmount, salesTaxAmount, salesTaxJurisdiction, unitOfWork.Next()); logger.LogInformation($"Set {incomeAmount:c} + {salesTaxAmount:c} funds required."); eventCount = await EventProcessorMicroService.ProcessPendingEvents(); logger.LogInformation($"{eventCount} events processed."); // Ensure funds transferred. // var fundable = await FundingMicroService.GetFundableAsync(fundableId); Assert.IsNotNull(fundable); logger.LogInformation($"Fundable retrieved. Fundable reference = {fundable.FundableReference}"); Assert.AreEqual(fundableReference, fundable.FundableReference); Assert.AreEqual(fundable.FundsRequiredTotal, totalAmount); Assert.AreEqual(fundable.FundsReceived, totalAmount); }
public async Task CreateFundable() { Console.WriteLine("CreateFundable"); var logger = ServiceScope.ServiceProvider.GetService <ILogger <FundingTest> >(); var fundableReference = CreateFundableReference.FromTimestamp(GetUniqueNow()); logger.LogInformation($"Fundable reference = {fundableReference}"); var fundableId = await FundingMicroService.AllocateFundableAsync(fundableReference); logger.LogInformation($"Fundable ID = {fundableId}"); var fundable = await FundingMicroService.GetFundableAsync(fundableId); Assert.IsNotNull(fundable); logger.LogInformation($"Fundable retrieved. Fundable reference = {fundable.FundableReference}"); Assert.AreEqual(fundableReference, fundable.FundableReference); var fundables = await FundingMicroService.GetFundableSummariesAsync(null, null, null); Assert.IsNotNull(fundables); Assert.IsNotNull(fundables.Summaries); Assert.IsTrue(fundables.Summaries.Any(r => r.FundableReference == fundableReference)); }