public void RunCompleteDown()
        {
            var random   = new Random();
            var count    = random.Next(5, int.MaxValue);
            var duration = TimeSpan.FromMilliseconds(random.Next());

            var poller    = Substitute.For <IPoller <object> >();
            var processor = Substitute.For <IProcessor <object> >();
            var tracker   = Substitute.For <ITimingTracker>();

            tracker.Calculate(duration, 1).Returns((byte)2);
            tracker.Calculate(duration, 2).Returns((byte)1);

            var d = new DequeueBatchDynamic <object>(poller, processor, tracker);

            d.RunCompleted(1, duration);
            d.RunCompleted(1, duration);

            Assert.AreEqual(1, d.BatchCount);

            tracker.Received().Calculate(duration, 1);
            tracker.Received().Calculate(duration, 2);
        }
        public void RunCompleteDownIntegration()
        {
            var random   = new Random();
            var duration = TimeSpan.FromMilliseconds(10);

            var poller    = Substitute.For <IPoller <object> >();
            var processor = Substitute.For <IProcessor <object> >();

            var d = new DequeueBatchDynamic <object>(poller, processor, new TimingTracker(TimeSpan.FromMinutes(1), 50));

            d.RunCompleted(1, duration);
            d.RunCompleted(2, duration);
            d.RunCompleted(3, duration);
            d.RunCompleted(1, TimeSpan.FromMinutes(1));
            d.RunCompleted(1, TimeSpan.FromMinutes(1));
            d.RunCompleted(1, TimeSpan.FromMinutes(1));

            Assert.AreEqual(1, d.BatchCount);
        }
        public void RunCompleteDownIntegration()
        {
            var random = new Random();
            var duration = TimeSpan.FromMilliseconds(10);

            var poller = Substitute.For<IPoller<object>>();
            var processor = Substitute.For<IProcessor<object>>();

            var d = new DequeueBatchDynamic<object>(poller, processor, new TimingTracker(TimeSpan.FromMinutes(1), 50));
            d.RunCompleted(1, duration);
            d.RunCompleted(2, duration);
            d.RunCompleted(3, duration);
            d.RunCompleted(1, TimeSpan.FromMinutes(1));
            d.RunCompleted(1, TimeSpan.FromMinutes(1));
            d.RunCompleted(1, TimeSpan.FromMinutes(1));

            Assert.AreEqual(1, d.BatchCount);
        }
        public void RunCompleteDown()
        {
            var random = new Random();
            var count = random.Next(5, int.MaxValue);
            var duration = TimeSpan.FromMilliseconds(random.Next());

            var poller = Substitute.For<IPoller<object>>();
            var processor = Substitute.For<IProcessor<object>>();
            var tracker = Substitute.For<ITimingTracker>();
            tracker.Calculate(duration, 1).Returns((byte)2);
            tracker.Calculate(duration, 2).Returns((byte)1);

            var d = new DequeueBatchDynamic<object>(poller, processor, tracker);
            d.RunCompleted(1, duration);
            d.RunCompleted(1, duration);

            Assert.AreEqual(1, d.BatchCount);

            tracker.Received().Calculate(duration, 1);
            tracker.Received().Calculate(duration, 2);
        }