public void Shutdown_ReleaseAfter1Second()
        {
            var msg1 = new DispatchEvent(new FakeEvent());
            var evt = new ManualResetEvent(false);
            var context = new FakeContext(X => Thread.Sleep(1000));
            var dispatcher = new AsyncHandler(2);

            dispatcher.HandleDownstream(context, msg1);
            dispatcher.Close();
        }
        public void Shutdown_NotReleased()
        {
            var msg1 = new DispatchEvent(new FakeEvent());
            var evt = new ManualResetEvent(false);
            var context = new FakeContext(X => evt.WaitOne());
            var dispatcher = new AsyncHandler(2);

            dispatcher.HandleDownstream(context, msg1);
            Assert.Throws<InvalidOperationException>(() => dispatcher.Close());

            evt.Set();

            // and expect the third to get running.
            Assert.True(context.Wait(TimeSpan.FromMilliseconds(100)));
        }