Пример #1
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);
            });
        }
Пример #2
0
        public void ShouldRefundNothingIfNothingPaid()
        {
            var    paymentPlan = new PaymentPlan(100, 4);
            Refund refund      = new Refund(Guid.NewGuid().ToString(), 100);
            var    cashRefund  = paymentPlan.ApplyRefund(refund);

            Assert.Equal(0, cashRefund);
        }
        public void ShouldReturnMaximumRefundsAvailable()
        {
            SetupPaymentService();
            var paymentPlan      = new PaymentPlan(_userId, 100, ThirPartyPaymentAPIMock, 4);
            var firstInstallment = paymentPlan.FirstInstallment();

            paymentPlan.MakePayment(25, firstInstallment.Id);
            paymentPlan.ApplyRefund(new Refund(Guid.NewGuid().ToString(), 100));
            paymentPlan.MaximumRefundAvailable().Should().Be(100);
        }
Пример #4
0
        public void ShouldReturnCorrectAmountToRefundAgainstPaidInstallments()
        {
            var paymentPlan      = new PaymentPlan(100, 4);
            var firstInstallment = paymentPlan.FirstInstallment();

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

            Assert.Equal(25, cashRefundAmount);
            Assert.Equal(0, paymentPlan.OustandingBalance());
        }
Пример #5
0
        public void RefundShouldNotReflectDefaultedPayments()
        {
            var paymentPlan      = new PaymentPlan(100, 4);
            var firstInstallment = paymentPlan.FirstInstallment();

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

            Assert.Equal(0, cashRefund);
        }
        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);
        }