public async Task <ICollection <MortgageProduct> > ExecuteAsync() { //If the applicant is under 18, no products should be returned var isUnderage = _applicant.DateOfBirth.AddYears(18) > DateTime.Today; if (isUnderage) { return(new List <MortgageProduct>()); } //If LTV is not less than 90%, no products should be returned var loanToValueRatio = LoanToValueCalculator.GetLtvRatio(_propertyValue, _depositAmount); bool isLtvTooHigh = loanToValueRatio > 0.9m; if (isLtvTooHigh) { return(new List <MortgageProduct>()); } using (var db = PodiumDbContextFactory.GetDbContext()) { return(await db.MortgageProducts .Where(mp => loanToValueRatio <= mp.MaximumLoanToValue) .ToListAsync()); } }
public void LoanToValueCalculator_Given10kPaymentOn100kHome_Returns90Percent() { var expected = 0.9m; var actual = LoanToValueCalculator.GetLtvRatio(100000, 10000); Assert.AreEqual(expected, actual); }