public void ThrowsWhenFlushingAfterDisposed() { var queue = new JobQueue <string>(GetEmptyProcessHandler <string>(), "dp", int.MaxValue, int.MaxValue, false, (message) => { }); queue.Dispose(); Assert.ThrowsException <ObjectDisposedException>(() => { queue.Flush(); }); }
public void FlushMethodWaitsForAllJobsToBeProcessedBeforeReturning() { // Setup the job process handler to keep track of the jobs it has processed. var jobsProcessed = 0; Action <string> processHandler = (job) => { jobsProcessed++; }; // Queue several jobs and verify they have been processed when wait returns. using (var queue = new JobQueue <string>(processHandler, "dp", int.MaxValue, int.MaxValue, false, (message) => { })) { queue.QueueJob("dp", 0); queue.QueueJob("dp", 0); queue.QueueJob("dp", 0); queue.Flush(); Assert.AreEqual(3, jobsProcessed); } }