public void ChargeLateFee_ShouldIncreaseBalance()
        {
            var basicLoan = LoanFactory.CreateLoan("basic", 100, 10M, 24);

            basicLoan.ChargeLateFee();

            basicLoan.Balance.Should().Be(225);
        }
        public void MakePayment_ShouldDecreaseBalanceByPaymentAmount()
        {
            var basicLoan = LoanFactory.CreateLoan("basic", 10000, 10M, 24);

            basicLoan.MakePayment(2500);

            basicLoan.Balance.Should().Be(7500);
        }
        public void CanCalculateInterest_ShouldIncreaseBalanceByRate()
        {
            var basicLoan = LoanFactory.CreateLoan("basic", 10000, 10M, 24);

            var interestAccrued = basicLoan.ApplyInterest();

            interestAccrued.Should().Be(1000);
            basicLoan.Balance.Should().Be(11000);
        }
Beispiel #4
0
        public PaymentSchedule GetPaymentSchedule(LoanType loanType, int duration, double principal)
        {
            Validate(duration, principal);

            var factory = new LoanFactory();
            var loan    = factory.GetLoan(loanType);

            var calculationStrategy = new FixedMonthlyRateCalculationStrategy();

            var loanCalulator = new LoanCalculator(calculationStrategy);

            return(loanCalulator.GetPaymentSchedule(new LoanCalculationParameters()
            {
                AnnualInterestRate = loan.InterestRate,
                PaybackTimeInYears = duration,
                Principal = principal
            }));
        }
Beispiel #5
0
 public LoanController(IPaymentCalculator paymentCalculator, LoanFactory loanFactory)
 {
     _paymentCalculator = paymentCalculator;
     _loanFactory       = loanFactory;
 }
Beispiel #6
0
 public Loan GetLoan(LoanType type, double interestRate)
 {
     return(LoanFactory.CreateLoanInstance(type, interestRate));
 }
        public void MakePaymentGreaterThanBalance_ShouldThrowException()
        {
            var basicLoan = LoanFactory.CreateLoan("basic", 100, 10M, 24);

            Assert.Throws <LoanOverpaymentException>(() => basicLoan.MakePayment(30000));
        }
 public void CreateInvalidLoanType_ShouldThrowException()
 {
     Assert.Throws <ArgumentException>(() => LoanFactory.CreateLoan("aiofnqweiufwiubfweif", 10000, 8.65M, 24));
 }
        public void CanCreateBasicLoan()
        {
            var basicLoan = LoanFactory.CreateLoan("basic", 10000, 8.65M, 24);

            basicLoan.GetType().Name.Should().Be("BasicLoan");
        }