Inheritance: IResourceCounter
コード例 #1
0
        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));
        }
コード例 #2
0
        public void GivenEmptyResourceCounterThenShouldReturnZeroCountOnDecrement()
        {
            var resourceCounter = new ResourceCounter();

            Assert.AreEqual(0, resourceCounter.Decrement(ID));
            Assert.AreEqual(0, resourceCounter.Decrement(ID));
        }
コード例 #3
0
        public void GivenOneIncrementAndOneDecrementThenShouldReturnZeroCountOnDecrement()
        {
            var resourceCounter = new ResourceCounter();

            resourceCounter.Increment(ID);

            Assert.AreEqual(0, resourceCounter.Decrement(ID));
        }
コード例 #4
0
        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);
        }