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); }
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); }
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); }
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); }
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); }