public static void TestObjectDisposed()
        {
            WorkerGroup workerGroup = new WorkerGroup();
            IThreadWorker worker = workerGroup.CreateWorker();
            worker.Run();
            workerGroup.Dispose();

            worker = null;
            Assert.Throws<ObjectDisposedException>(() => { worker = workerGroup.CreateWorker(); }, "A call to a method on a disposed object should raise ObjectDisposedException.");
            Assert.That(worker, Is.Null, "The worker should still be null, since the previous attempt to create should fail with an exception.");
            Assert.Throws<ObjectDisposedException>(() => { workerGroup.WaitAllAndFinish(); }, "A call to a method on a disposed object should raise ObjectDisposedException.");
        }
 public static void TestDoubleDispose()
 {
     Assert.DoesNotThrow(() =>
         {
             using (WorkerGroup workerGroup = new WorkerGroup())
             {
                 IThreadWorker worker = workerGroup.CreateWorker();
                 worker.Run();
                 workerGroup.Dispose();
             }
         });
 }