public void GivenMultipleIncrementThenEachDecrementShouldDecreaseTheCountToZero() { var resourceCounter = new ResourceCounter(); resourceCounter.Increment(ID); resourceCounter.Increment(ID); resourceCounter.Increment(ID); resourceCounter.Increment(ID); resourceCounter.Increment(ID); resourceCounter.Increment(ID); resourceCounter.Increment(ID); resourceCounter.Increment(ID); resourceCounter.Increment(ID); resourceCounter.Increment(ID); Assert.AreEqual(9, resourceCounter.Decrement(ID)); Assert.AreEqual(8, resourceCounter.Decrement(ID)); Assert.AreEqual(7, resourceCounter.Decrement(ID)); Assert.AreEqual(6, resourceCounter.Decrement(ID)); Assert.AreEqual(5, resourceCounter.Decrement(ID)); Assert.AreEqual(4, resourceCounter.Decrement(ID)); Assert.AreEqual(3, resourceCounter.Decrement(ID)); Assert.AreEqual(2, resourceCounter.Decrement(ID)); Assert.AreEqual(1, resourceCounter.Decrement(ID)); Assert.AreEqual(0, resourceCounter.Decrement(ID)); Assert.AreEqual(0, resourceCounter.Decrement(ID)); }
public void GivenEmptyResourceCounterThenShouldReturnZeroCountOnDecrement() { var resourceCounter = new ResourceCounter(); Assert.AreEqual(0, resourceCounter.Decrement(ID)); Assert.AreEqual(0, resourceCounter.Decrement(ID)); }
public void GivenOneIncrementAndOneDecrementThenShouldReturnZeroCountOnDecrement() { var resourceCounter = new ResourceCounter(); resourceCounter.Increment(ID); Assert.AreEqual(0, resourceCounter.Decrement(ID)); }
private IXDListener CreateNetworkListener(IIdentityProvider provider) { var settings = AmazonAccountSettings.GetInstance(); var amazonSnsFacade = new AmazonSnsFacade(settings); var amazonSqsFacade = new AmazonSqsFacade(settings); var queuePoller = new QueuePoller(amazonSqsFacade); var resourceCounter = new ResourceCounter(); var respository = new TopicRepository(AmazonAccountSettings.GetInstance(), amazonSnsFacade); var subscriberRepository = new SubscriberRepository(settings, amazonSqsFacade); var subscriptionService = new SubscriptionService( resourceCounter, amazonSnsFacade, amazonSqsFacade, subscriberRepository, queuePoller); return new XDAmazonListener(provider, serializer, respository, subscriberRepository, subscriptionService); }