public void SubmitApplicationFor_BusinessLoans_CallsBusinessLoansService()
        {
            // **Arrange**
            BusinessLoan      product     = _fixture.Build <BusinessLoan>().Create();
            SellerCompanyData companyData = _fixture.Build <SellerCompanyData>().Create();
            SellerApplication <BusinessLoan> application = _fixture.Build <SellerApplication <BusinessLoan> >()
                                                           .With(a => a.Product, product)
                                                           .With(a => a.CompanyData, companyData)
                                                           .Create();

            loans.SubmitApplicationFor(
                Arg.Is <CompanyDataRequest>(x => x.DirectorName == companyData.DirectorName &&
                                            x.CompanyNumber == companyData.Number &&
                                            x.CompanyName == companyData.Name &&
                                            x.CompanyFounded == companyData.Founded),
                Arg.Is <LoansRequest>(y => y.InterestRatePerAnnum == product.InterestRatePerAnnum &&
                                      y.LoanAmount == product.LoanAmount))
            .Returns(new TestApplicationResult(10, true, new List <string>()));

            // **Act**
            int result = _service.SubmitApplicationFor(application);

            // **Assert**
            loans.Received(1).SubmitApplicationFor(Arg.Is <CompanyDataRequest>(x => x.DirectorName == companyData.DirectorName &&
                                                                               x.CompanyNumber == companyData.Number &&
                                                                               x.CompanyName == companyData.Name &&
                                                                               x.CompanyFounded == companyData.Founded),
                                                   Arg.Is <LoansRequest>(y => y.InterestRatePerAnnum == product.InterestRatePerAnnum &&
                                                                         y.LoanAmount == product.LoanAmount));
            Assert.Equal(10, result);
        }
Example #2
0
        public static Loan CreateLoanInstance(LoanType type, double interestRate)
        {
            Loan loanObject = default(Loan);

            switch (type)
            {
            case LoanType.Business:
                loanObject = new BusinessLoan(interestRate);
                break;

            case LoanType.Education:
                loanObject = new EducationLoan(interestRate);
                break;

            case LoanType.Home:
                loanObject = new HomeLoan(interestRate);
                break;
            }

            return(loanObject);
        }
 /// <summary>
 /// Map the business loans object to loan request.
 /// </summary>
 /// <returns>New loan request model with mapper properties.</returns>
 public static LoansRequest ToLoanRequest(BusinessLoan loan)
 {
     return(new LoansRequest {
         InterestRatePerAnnum = loan.InterestRatePerAnnum, LoanAmount = loan.LoanAmount
     });
 }