예제 #1
0
        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);
        }
예제 #2
0
        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));
        }
예제 #3
0
        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());
        }
예제 #4
0
        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);
        }
예제 #5
0
        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);
        }