public void ResponderWorkerScheduler_CurrentWorkerThreadCount_not_decreased_when_back_idle_before_MaxIdleTime()
        {
            var worker = new TestWorker(30);

            using (var scheduler = new ResponderWorkerScheduler(0, 1, TimeSpan.FromMilliseconds(100)))
            {
                scheduler.AddWorker(worker, new TestMessage(), null);

                worker.WaitStarted(Timeout);
                Assert.AreEqual(1, scheduler.CurrentWorkerThreadCount);

                worker.WaitCompleted(Timeout);
                Thread.Sleep(15);
                Assert.AreEqual(1, scheduler.CurrentWorkerThreadCount);
            }
        }
        public void ResponderWorkerScheduler_CurrentBusyThreadCount_decreased_when_back_idle()
        {
            var worker = new TestWorker(30);

            using (var scheduler = new ResponderWorkerScheduler(1, 1))
            {
                scheduler.AddWorker(worker, new TestMessage(), null);

                worker.WaitStarted(Timeout);
                Assert.AreEqual(1, scheduler.CurrentBusyThreadCount);

                worker.WaitCompleted(Timeout);
                Thread.Sleep(15);
                Assert.AreEqual(0, scheduler.CurrentBusyThreadCount);
            }
        }
        public void ResponderWorkerScheduler_CurrentWorkerThreadCount_increased_then_decreased_then_increased()
        {
            using (var scheduler = new ResponderWorkerScheduler(0, 1, TimeSpan.FromMilliseconds(1)))
            {
                var worker1 = new TestWorker(30);
                scheduler.AddWorker(worker1, new TestMessage(), null);

                worker1.WaitStarted(Timeout);
                Assert.AreEqual(1, scheduler.CurrentWorkerThreadCount);

                worker1.WaitCompleted(Timeout);
                Thread.Sleep(10);
                Assert.AreEqual(0, scheduler.CurrentWorkerThreadCount);

                var worker2 = new TestWorker(30);
                scheduler.AddWorker(worker2, new TestMessage(), null);

                worker2.WaitStarted(Timeout);
                Assert.AreEqual(1, scheduler.CurrentWorkerThreadCount);
            }
        }
        public void ResponderWorkerScheduler_CurrentWorkerThreadCount_increased_then_decreased_then_increased()
        {
            using (var scheduler = new ResponderWorkerScheduler(0, 1, TimeSpan.FromMilliseconds(1)))
            {
                var worker1 = new TestWorker(30);
                scheduler.AddWorker(worker1, new TestMessage(), null);

                worker1.WaitStarted(Timeout);
                Assert.AreEqual(1, scheduler.CurrentWorkerThreadCount);

                worker1.WaitCompleted(Timeout);
                Thread.Sleep(10);
                Assert.AreEqual(0, scheduler.CurrentWorkerThreadCount);

                var worker2 = new TestWorker(30);
                scheduler.AddWorker(worker2, new TestMessage(), null);

                worker2.WaitStarted(Timeout);
                Assert.AreEqual(1, scheduler.CurrentWorkerThreadCount);
            }
        }
        public void ResponderWorkerScheduler_CurrentWorkerThreadCount_not_decreased_when_back_idle_before_MaxIdleTime()
        {
            var worker = new TestWorker(30);
            using (var scheduler = new ResponderWorkerScheduler(0, 1, TimeSpan.FromMilliseconds(100)))
            {
                scheduler.AddWorker(worker, new TestMessage(), null);

                worker.WaitStarted(Timeout);
                Assert.AreEqual(1, scheduler.CurrentWorkerThreadCount);

                worker.WaitCompleted(Timeout);
                Thread.Sleep(15);
                Assert.AreEqual(1, scheduler.CurrentWorkerThreadCount);
            }
        }
        public void ResponderWorkerScheduler_CurrentBusyThreadCount_decreased_when_back_idle()
        {
            var worker = new TestWorker(30);
            using (var scheduler = new ResponderWorkerScheduler(1, 1))
            {
                scheduler.AddWorker(worker, new TestMessage(), null);

                worker.WaitStarted(Timeout);
                Assert.AreEqual(1, scheduler.CurrentBusyThreadCount);

                worker.WaitCompleted(Timeout);
                Thread.Sleep(15);
                Assert.AreEqual(0, scheduler.CurrentBusyThreadCount);
            }
        }