public async Task ShouldInsert_LoanAgreementAndLoanPymt_UsingLoanAgreementAggregate() { LoanAgreement agreement = new LoanAgreement ( new EconomicEvent(Guid.NewGuid(), EventType.CashReceiptFromLoanAgreement), FinancierId.Create(new Guid("b49471a0-5c1e-4a4d-97e7-288fb0f6338a")), LoanAmount.Create(175000), InterestRate.Create(.0675), LoanDate.Create(new DateTime(2021, 11, 5)), MaturityDate.Create(new DateTime(2022, 11, 5)), PaymentsPerYear.Create(12), UserId.Create(new Guid("660bb318-649e-470d-9d2b-693bfb0b2744")) ); LoanPayment loanPayment = new LoanPayment ( new EconomicEvent(Guid.NewGuid(), EventType.CashDisbursementForLoanPayment), agreement, PaymentNumber.Create(1), PaymentDueDate.Create(new DateTime(2021, 12, 5)), LoanPrincipalAmount.Create(14135), LoanInterestAmount.Create(984), LoanPrincipalRemaining.Create(160862), UserId.Create(new Guid("660bb318-649e-470d-9d2b-693bfb0b2744")) ); agreement.AddLoanPayment(loanPayment); await _loanAgreementRepo.AddAsync(agreement); await _unitOfWork.Commit(); var result = await _loanAgreementRepo.Exists(agreement.Id); Assert.True(result); //TODO Test navigation to LoanPayment }
public async Task ShouldInsert_LoanPymt_UsingLoanAgreementAggregate() { LoanAgreement agreement = await _loanAgreementRepo.GetByIdAsync(new Guid("0a7181c0-3ce9-4981-9559-157fd8e09cfb")); EconomicEvent economicEvent = new EconomicEvent(Guid.NewGuid(), EventType.CashDisbursementForLoanPayment); await _loanAgreementRepo.AddEconomicEventAsync(economicEvent); LoanPayment loanPayment = new LoanPayment ( economicEvent, agreement, PaymentNumber.Create(1), PaymentDueDate.Create(new DateTime(2021, 12, 5)), LoanPrincipalAmount.Create(14135.13M), LoanInterestAmount.Create(984), LoanPrincipalRemaining.Create(160862.13M), UserId.Create(new Guid("660bb318-649e-470d-9d2b-693bfb0b2744")) ); agreement.AddLoanPayment(loanPayment); _loanAgreementRepo.Update(agreement); await _unitOfWork.Commit(); LoanPayment result = agreement.LoanPayments.FirstOrDefault(p => p.Id == loanPayment.EconomicEvent.Id); Assert.NotNull(result); }