public void Dequeue_ThrowsWhenNoDeliveryInQueueWithinTimeout() { var cts = new CancellationTokenSource(TimeSpan.FromMilliseconds(1)); var queue = new DeliveryQueue(); Action action = () => queue.Dequeue(cts.Token); action.ShouldThrow <OperationCanceledException>(); }
public void Enqueue_AddsDeliveryToQueue() { var cts = new CancellationTokenSource(TimeSpan.FromMilliseconds(50)); var delivery = new Delivery(new Message()); var queue = new DeliveryQueue(); queue.Enqueue(delivery); queue.Dequeue(cts.Token).ShouldBeSameAs(delivery.Message); }
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 Enqueue_GetsFirstInsertedItem() { var delivery1 = new Delivery(new Message()); var delivery2 = new Delivery(new Message()); var queue = new DeliveryQueue(); queue.Enqueue(delivery1); queue.Enqueue(delivery2); queue.Dequeue(CancellationToken.None).ShouldBeSameAs(delivery1.Message); }
public void Process_ProcessesDelivery() { var message = new Message(); message.InitializePrivateProperty("Delivery"); ListenerLink link = Construct.Uninitialized <ListenerLink>(); MessageContext messageContext = Construct.ForPrivate <MessageContext>(link, message); var delivery = new Delivery(message); var queue = new DeliveryQueue(); queue.Enqueue(delivery); queue.Dequeue(CancellationToken.None); queue.Process(messageContext); delivery.Processed.ShouldNotBeNull(); }