예제 #1
0
        public void CustomerWhoDoesNotHaveSubscriptionDoesNotGetCharged()
        {
            var processor = TestableBillingProcessor.Create(new Customer());

            processor.ProcessMonth(2011, 8);

            processor.MockCharger.Verify(c => c.ChargeCustomer(new Customer()), Times.Never);
        }
예제 #2
0
        public void CustomerWithSubscriptionThatIsExpiredGetsCharged()
        {
            var subscription = new MonthlySubscription();
            var customer     = new Customer {
                Subscription = subscription
            };
            var processor = TestableBillingProcessor.Create(customer);

            processor.ProcessMonth(2011, 8);

            processor.MockCharger.Verify(c => c.ChargeCustomer(customer), Times.Once());
        }
예제 #3
0
    public void CustomerWithSubscriptionThatIsCurrentDoesNotGetCharged()
    {
        var customer = new Customer
        {
            Subscribed       = true,
            PaidThroughYear  = 2012,
            PaidThroughMonth = 1
        };
        var processor = TestableBillingProcessor.Create(customer);

        processor.ProcessMonth(2011, 8);

        processor.MockCharger.Verify(c => c.ChargeCustomer(customer), Times.Never());
    }
예제 #4
0
        public void CustomerWithSubscriptionThatIsCurrentThroughNextYearDoesNotGetCharged()
        {
            var subscription = new MonthlySubscription {
                PaidThroughYear = 2012, PaidThroughMonth = 8
            };
            var customer = new Customer {
                Subscription = subscription
            };
            var processor = TestableBillingProcessor.Create(customer);

            processor.ProcessMonth(2011, 8);

            processor.Charger.Verify(c => c.ChargeCustomer(customer), Times.Never);
        }
예제 #5
0
        public void CustomerWhoIsCurrentAndDueToPayAndFailsOnceIsStillCurrent()
        {
            var subscription = new MonthlySubscription();
            var customer     = new Customer {
                Subscription = subscription
            };
            var processor = TestableBillingProcessor.Create(customer);

            processor.Charger.Setup(c => c.ChargeCustomer(It.IsAny <Customer>()))
            .Returns(false);


            processor.ProcessMonth(2011, 8);

            Assert.True(customer.Subscription.IsCurrent);
        }
예제 #6
0
        public void CustomerWithSubscriptionThatIsExpiredGetsCharged()
        {
            var subscription = new MonthlySubscription()
            {
                PaidThroughYear = 2011, PaidThroughMonth = 8
            };
            var customer = new Customer()
            {
                Subscription = subscription
            };
            var processor = TestableBillingProcessor.Create(customer);

            processor.ProcessMonth(2011, 9);

            processor.Charger.Verify(c => c.ChargeCustomer(customer), Times.Once);
        }
예제 #7
0
    public void CustomerWhoIsSubscribedAndDueToPayButFailsOnceIsStillCurrent()
    {
        var customer = new Customer
        {
            Subscribed       = true,
            PaidThroughYear  = 2012,
            PaidThroughMonth = 1
        };
        var processor = TestableBillingProcessor.Create(customer);

        processor.MockCharger.Setup(c => c.ChargeCustomer(It.IsAny <Customer>()))
        .Returns(false);

        processor.ProcessMonth(2011, 8);

        //processor.MockCharger.Verify(c => c.ChargeCustomer(customer), Times.Never());
        Assert.True(customer.Subscribed);
    }
예제 #8
0
        public void CustomerWhoIsCurrentAndDueToPayAndFailsMaximumTimesIsNoLongerSubscribed()
        {
            var subscription = new MonthlySubscription();
            var customer     = new Customer {
                Subscription = subscription
            };
            var processor = TestableBillingProcessor.Create(customer);

            processor.Charger.Setup(c => c.ChargeCustomer(It.IsAny <Customer>()))
            .Returns(false);

            for (int i = 0; i < MonthlySubscription.MAX_FAILURES; i++)
            {
                processor.ProcessMonth(2011, 8);
            }

            Assert.False(customer.Subscription.IsCurrent);
        }
예제 #9
0
        public void CustomerWhoIsSubscribedButFailsToPayOnceIsStillSubscribed()
        {
            var subscription = new MonthlySubscription()
            {
                PaidThroughYear = 2011, PaidThroughMonth = 8
            };
            var customer = new Customer()
            {
                Subscription = subscription
            };
            var processor = TestableBillingProcessor.Create(customer);

            processor.Charger.Setup(c => c.ChargeCustomer(It.IsAny <Customer>()))
            .Returns(false);

            processor.ProcessMonth(2011, 8);

            Assert.True(customer.Subscription.IsCurrent);
        }
예제 #10
0
    public void CustomerWhoIsSubscribedAndDueToPayButFailsThreeTimesIsNoLongerSubcribed()
    {
        var customer = new Customer
        {
            Subscribed       = true,
            PaidThroughYear  = 2011,
            PaidThroughMonth = 8
        };
        var processor = TestableBillingProcessor.Create(customer);

        processor.MockCharger.Setup(c => c.ChargeCustomer(It.IsAny <Customer>()))
        .Returns(false);

        for (int i = 0; i < BillingProcessor.MAX_FAILURES; i++)
        {
            processor.ProcessMonth(2011, 8);
        }

        //processor.MockCharger.Verify(c => c.ChargeCustomer(customer), Times.Never());
        Assert.True(customer.Subscribed);
    }