public void MakePayment_Pass_PaymentCorrect() { // Arrange Repository repo = new Repository(); var mockRepository = new Mock <ILoanModelDAL>(); PaymentModel pay = new PaymentModel(); pay.LoanID = 1; pay.PaymentAmount = 75; LoanModel loan = new LoanModel(); loan.LoanID = 1; loan.Amount = 100; int id = 1; // tell the mock that when LoanSelectByID is called, // return the specified Loan mockRepository.Setup(cr => cr.LoanSelectByID(id)).Returns(loan); // pass the mocked instance, not the mock itself, to the category // controller using the Object property repo.iLoanModelDAL = mockRepository.Object; // Act LoanLogic loanLogic = new LoanLogic(repo); bool result = loanLogic.AttemptPayment(pay); // Assert Assert.IsTrue(result); }
public ActionResult MakePayment(PaymentModel pay) { LoanLogic loanLogic = new LoanLogic(repo); ViewBag.PaymentResult = loanLogic.AttemptPayment(pay); return(View(pay)); }