Пример #1
0
        public void ThrowsWhenFlushingAfterDisposed()
        {
            var queue = new JobQueue <string>(GetEmptyProcessHandler <string>(), "dp", int.MaxValue, int.MaxValue, false, (message) => { });

            queue.Dispose();

            Assert.ThrowsException <ObjectDisposedException>(() =>
            {
                queue.Flush();
            });
        }
Пример #2
0
        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);
            }
        }