public void SendsBeforeBufferingShouldBeCaptured() { int x = 0; var queue = new ScaleoutTaskQueue(new TraceSource("Queue"), "0", new ScaleoutConfiguration() { RetryOnError = true }); queue.Enqueue(_ => { x++; return(TaskAsyncHelper.Empty); }, null); queue.SetError(new Exception()); Task task = queue.Enqueue(_ => { x++; return(TaskAsyncHelper.Empty); }, null); queue.Open(); task.Wait(); Assert.Equal(2, x); }
public void BufferAfterClosedEnqueueThrows() { var queue = new ScaleoutTaskQueue(new TraceSource("Queue"), "0", new ScaleoutConfiguration() { RetryOnError = true }); queue.Close(); queue.SetError(new Exception()); Assert.Throws <InvalidOperationException>(() => queue.Enqueue(_ => TaskAsyncHelper.Empty, null)); }
public void ThrowingFromErrorCallbackIsCaught() { var config = new ScaleoutConfiguration() { RetryOnError = true, OnError = ex => { throw new Exception(); } }; var queue = new ScaleoutTaskQueue(new TraceSource("Queue"), "0", config); queue.SetError(new Exception()); }
public void InitialToBufferingToOpenToSend() { int x = 0; var queue = new ScaleoutTaskQueue(new TraceSource("Queue"), "0", new ScaleoutConfiguration() { RetryOnError = true }); queue.SetError(new Exception()); queue.Open(); queue.Enqueue(_ => { x++; return(TaskAsyncHelper.Empty); }, null).Wait(); Assert.Equal(1, x); }
public void SendsDuringInitialThenBufferingShouldNotSend() { int x = 0; var queue = new ScaleoutTaskQueue(new TraceSource("Queue"), "0", new ScaleoutConfiguration() { RetryOnError = true }); Task task = queue.Enqueue(_ => { x++; return(TaskAsyncHelper.Empty); }, null); queue.SetError(new Exception()); task.Wait(TimeSpan.FromSeconds(0.5)); Assert.Equal(0, x); }