public void ShouldReturnCorrectAmountToRefundAgainstPaidInstallments()
        {
            SetupPaymentService();
            var paymentPlan      = new PaymentPlan(_userId, 100, ThirPartyPaymentAPIMock, 4);
            var firstInstallment = paymentPlan.FirstInstallment();

            paymentPlan.MakePayment(25, firstInstallment.Id);
            //Unclear on purpose of the return value
            var cashRefundAmount = paymentPlan.ApplyRefund(new Refund(Guid.NewGuid().ToString(), 100));

            cashRefundAmount.Should().Be(25);
            paymentPlan.OustandingBalance().Should().Be(0);
        }
Пример #2
0
        public void WhenAttemptingASecondRefundShouldThrow()
        {
            var paymentPlan = new PaymentPlan(100, 4);

            var firstInstallment = paymentPlan.FirstInstallment();

            paymentPlan.MakePayment(25, firstInstallment.Id);
            Refund refund = new Refund(Guid.NewGuid().ToString(), 100);

            paymentPlan.ApplyRefund(refund);

            Assert.Throws <Exception>(() => {
                paymentPlan.ApplyRefund(refund);
            });
        }
        public void AmountPastDueIsReturnedForDefaultedStatuses()
        {
            SetupPaymentService();
            var paymentPlan      = new PaymentPlan(_userId, 100, ThirPartyPaymentAPIMock, 4);
            var firstInstallment = paymentPlan.FirstInstallment();

            paymentPlan.MakePayment(25, firstInstallment.Id);

            SetupPaymentServiceToDefault();
            var secondInstallment = paymentPlan.NextInstallment();

            paymentPlan.MakePayment(25, secondInstallment.Id);
            var amountPastDue = paymentPlan.AmountPastDue(Today().AddMonths(3));

            Assert.Equal(75, amountPastDue);
        }