Ejemplo n.º 1
0
        public void OpenAfterErrorRunsQueue()
        {
            int x     = 0;
            var queue = new ScaleoutTaskQueue(new TraceSource("Queue"), "0", new ScaleoutConfiguration()
            {
                RetryOnError = true
            });

            queue.Open();
            queue.Enqueue(_ => { throw new InvalidOperationException(); }, null);
            queue.Enqueue(_ =>
            {
                x++;
                return(TaskAsyncHelper.Empty);
            },
                          null);

            var task = queue.Enqueue(_ =>
            {
                x++;
                return(TaskAsyncHelper.Empty);
            },
                                     null);

            queue.Open();

            task.Wait();

            Assert.Equal(2, x);
        }
Ejemplo n.º 2
0
        public void SendAfterCloseThenOpenRemainsClosed()
        {
            var queue = new ScaleoutTaskQueue(new TraceSource("Queue"), "0", new ScaleoutConfiguration()
            {
                RetryOnError = true
            });

            queue.Open();
            queue.Enqueue(_ => Task.Delay(50), null);
            queue.Close();
            queue.Open();
            Assert.Throws <InvalidOperationException>(() => queue.Enqueue(_ => TaskAsyncHelper.Empty, null));
        }
Ejemplo n.º 3
0
        public void ErrorOnSendBuffers()
        {
            int x     = 0;
            var queue = new ScaleoutTaskQueue(new TraceSource("Queue"), "0", new ScaleoutConfiguration()
            {
                RetryOnError = true
            });

            queue.Open();
            queue.Enqueue(_ => { throw new InvalidOperationException(); }, null);
            queue.Enqueue(_ =>
            {
                x++;
                return(TaskAsyncHelper.Empty);
            },
                          null);

            queue.Enqueue(_ =>
            {
                x++;
                return(TaskAsyncHelper.Empty);
            },
                          null);

            Assert.Equal(0, x);
        }
Ejemplo n.º 4
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);
        }
Ejemplo n.º 5
0
        public void ErrorOnSendThrowsNextTime()
        {
            var queue = new ScaleoutTaskQueue(new TraceSource("Queue"), "0", new ScaleoutConfiguration());

            queue.Open();
            queue.Enqueue(_ => { throw new InvalidOperationException(); }, null);
            Assert.Throws <InvalidOperationException>(() => queue.Enqueue(_ => TaskAsyncHelper.Empty, null));
        }
Ejemplo n.º 6
0
        public void CloseWhileQueueRuns()
        {
            var queue = new ScaleoutTaskQueue(new TraceSource("Queue"), "0", new ScaleoutConfiguration()
            {
                RetryOnError = true
            });

            queue.Open();
            queue.Enqueue(_ => Task.Delay(50), null);
            queue.Enqueue(_ => Task.Delay(100), null);
            queue.Enqueue(_ => Task.Delay(150), null);
            queue.Close();
        }
Ejemplo n.º 7
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);
        }