Example #1
0
        public void Dispose_CanBeCalledMultipleTimes()
        {
            var queue = new DeliveryQueue();

            Should.NotThrow(() =>
            {
                queue.Dispose();
                queue.Dispose();
                queue.Dispose();
            });
        }
Example #2
0
        public void Dispose_DisposesQueue()
        {
            var delivery = new Delivery(new Message());
            var queue    = new DeliveryQueue();

            queue.Dispose();

            Should.Throw <ObjectDisposedException>(() => queue.Enqueue(delivery));
            Should.Throw <ObjectDisposedException>(() => queue.Dequeue(CancellationToken.None));
            Should.Throw <ObjectDisposedException>(() => queue.Process(null));
        }
Example #3
0
        public void Dispose()
        {
            if (_disposed)
            {
                return;
            }
            _disposed = true;

            _deliveryQueue.Dispose();

            foreach (Delivery delivery in _deliveries)
            {
                delivery.Dispose();
            }
        }