public void Dispose_CanBeCalledMultipleTimes() { var queue = new DeliveryQueue(); Should.NotThrow(() => { queue.Dispose(); queue.Dispose(); queue.Dispose(); }); }
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)); }
public void Dispose() { if (_disposed) { return; } _disposed = true; _deliveryQueue.Dispose(); foreach (Delivery delivery in _deliveries) { delivery.Dispose(); } }