Exemple #1
0
        public void Dispose_causes_subsequent_enqueue_and_dequeue_to_throw_ObjectDisposed()
        {
            InputQueue <string> queue = new InputQueue <string>();

            queue.Dispose();

            Assert.Throws <ObjectDisposedException>(() => queue.Enqueue("a"));
            Assert.Throws <ObjectDisposedException>(() => queue.DequeueAsync());
        }
Exemple #2
0
        public void Dispose_completes_pending_receive_with_ObjectDisposed()
        {
            InputQueue <string> queue = new InputQueue <string>();

            Task <string> task = queue.DequeueAsync();

            Assert.False(task.IsCompleted);

            queue.Dispose();

            Assert.True(task.IsFaulted);
            Assert.NotNull(task.Exception);
            AggregateException ae = task.Exception;

            Assert.Equal(1, ae.InnerExceptions.Count);
            Assert.IsType <ObjectDisposedException>(ae.InnerExceptions[0]);
        }
        public void Dispose_causes_subsequent_enqueue_and_dequeue_to_throw_ObjectDisposed()
        {
            InputQueue<string> queue = new InputQueue<string>();
            queue.Dispose();

            Assert.Throws<ObjectDisposedException>(() => queue.Enqueue("a"));
            Assert.Throws<ObjectDisposedException>(() => queue.DequeueAsync());
        }
        public void Dispose_completes_pending_receive_with_ObjectDisposed()
        {
            InputQueue<string> queue = new InputQueue<string>();

            Task<string> task = queue.DequeueAsync();

            Assert.False(task.IsCompleted);

            queue.Dispose();

            Assert.True(task.IsFaulted);
            Assert.NotNull(task.Exception);
            AggregateException ae = task.Exception;
            Assert.Equal(1, ae.InnerExceptions.Count);
            Assert.IsType<ObjectDisposedException>(ae.InnerExceptions[0]);
        }
Exemple #5
0
 protected override void OnClosed()
 {
     base.OnClosed();
     channelQueue.Dispose();
 }