Example #1
0
 public Loan(decimal principal, decimal outstanding, Bank previousOwner, DateTime lastPayDate)
 {
     this.Principle = principal;
     this.Outstanding = outstanding;
     this.PreviousOwner = previousOwner;
     this.LastPayDate = lastPayDate;
 }
Example #2
0
            public void FirstPay()
            {
                //arrange
                Bank bank = new Bank(name: "SMC", interestRate: 7.0);

                Loan loan = new Loan(
                    principal: 1000000,
                    outstanding: 1000000,
                    previousOwner: bank,
                    lastPayDate: new DateTime(2015, 7, 1));

                //act
                var d = new DateTime(2015, 8, 1);
                var payment = loan.Pay(d, 10000);

                //assert
                //Assert.NotNull(payment);
                payment.ShouldNotBeNull();
                //Assert.Equal(31, payment.Days);
                payment.Days.ShouldEqual(31);
                Assert.Equal(10000, payment.PaidAmount);
                Assert.Equal(d, payment.PaidDate);

                Assert.Equal(5945.21m, payment.InterestAmount);
                Assert.Equal(4054.79m, payment.PaidPrincipalAmount);
                Assert.Equal(995945.21m, payment.Outstanding);

                Assert.Equal(d, loan.LastPayDate);
                Assert.Equal(995945.21m, loan.Outstanding);
            }
Example #3
0
        public Loan(decimal pricipal, decimal outstanding, Bank bank, DateTime lastpaydate)
        {
            this.Pricipal = pricipal;
            this.Outstanding = outstanding;
            this.PreviousOwner = bank;
            this.LastPaydate = lastpaydate;

            Payments = new List<Payment>();
        }
Example #4
0
            public void DifferentYearPayment_HaveCorrectDay()
            {
                Bank bank = new Bank(name: "SMC", interestRate: 7.0);
                var loan = new Loan(principal: 1000000, outstanding: 1000000, previousOwner: bank, lastPayDate: new DateTime(2014, 12, 20));
                var p = loan.Pay(new DateTime(2015, 1, 20), 10000);

                outputPayment(p);

                //Assert.Equal(31, p.Days);
                p.Days.ShouldEqual(31);
            }
Example #5
0
            public void FirstPay()
            {
                //arrange

                Bank bank = new Bank("SMC", 7.0m);

                Loan loan = new Loan(pricipal: 1000000, outstanding: 1000000 , bank: bank , lastpaydate:new DateTime(2015, 7, 1) );

                //act
                var d = new DateTime(2015, 8, 1);
                var payment = loan.Pay(d, 10000);

                // assert
                Assert.NotNull(payment);
                Assert.Equal(31, payment.Days);

                Assert.Equal(10000, payment.PaidAmount);
                Assert.Equal(d, payment.PaidDate);

                Assert.Equal(5945.21m, payment.InterestAmount);
                Assert.Equal(4054.79m, payment.PaidPrincipalAmount);
            }