コード例 #1
0
 public void Dequeue_WithoutResult_CompletesWithDefaultResult()
 {
     var queue = new DefaultAsyncWaitQueue<object>() as IAsyncWaitQueue<object>;
     var task = queue.Enqueue();
     queue.Dequeue().Dispose();
     Assert.AreEqual(default(object), task.Result);
 }
コード例 #2
0
        public void Dequeue_WithoutResult_SynchronouslyCompletesWithDefaultResult()
        {
            IAsyncWaitQueue <object> queue = new DefaultAsyncWaitQueue <object>() as IAsyncWaitQueue <object>;
            Task <object>            task  = queue.Enqueue();

            queue.Dequeue();
            Assert.Equal(default(object), task.Result);
        }
コード例 #3
0
 public void Dequeue_WithResult_CompletesWithResult()
 {
     var queue = new DefaultAsyncWaitQueue<object>() as IAsyncWaitQueue<object>;
     var result = new object();
     var task = queue.Enqueue();
     queue.Dequeue(result).Dispose();
     Assert.AreSame(result, task.Result);
 }
コード例 #4
0
        public void Dequeue_WithoutResult_CompletesWithDefaultResult()
        {
            var queue = new DefaultAsyncWaitQueue <object>() as IAsyncWaitQueue <object>;
            var task  = queue.Enqueue();

            queue.Dequeue().Dispose();
            Assert.AreEqual(default(object), task.Result);
        }
コード例 #5
0
        public void Dequeue_SynchronouslyCompletesTask()
        {
            var queue = new DefaultAsyncWaitQueue <object>() as IAsyncWaitQueue <object>;
            var task  = queue.Enqueue();

            queue.Dequeue();
            Assert.True(task.IsCompleted);
        }
コード例 #6
0
        public void Dequeue_WithResult_CompletesWithResult()
        {
            var queue  = new DefaultAsyncWaitQueue <object>() as IAsyncWaitQueue <object>;
            var result = new object();
            var task   = queue.Enqueue();

            queue.Dequeue(result).Dispose();
            Assert.AreSame(result, task.Result);
        }
コード例 #7
0
 public void Dequeue_Disposed_CompletesTask()
 {
     var queue = new DefaultAsyncWaitQueue<object>() as IAsyncWaitQueue<object>;
     var task = queue.Enqueue();
     var finish = queue.Dequeue();
     Assert.IsFalse(task.IsCompleted);
     finish.Dispose();
     Assert.IsTrue(task.IsCompleted);
 }
コード例 #8
0
        public void Dequeue_WithResult_SynchronouslyCompletesWithResult()
        {
            IAsyncWaitQueue <object> queue = new DefaultAsyncWaitQueue <object>() as IAsyncWaitQueue <object>;
            object        result           = new object();
            Task <object> task             = queue.Enqueue();

            queue.Dequeue(result);
            Assert.Same(result, task.Result);
        }
コード例 #9
0
        public void Dequeue_Disposed_CompletesTask()
        {
            var queue  = new DefaultAsyncWaitQueue <object>() as IAsyncWaitQueue <object>;
            var task   = queue.Enqueue();
            var finish = queue.Dequeue();

            Assert.IsFalse(task.IsCompleted);
            finish.Dispose();
            Assert.IsTrue(task.IsCompleted);
        }
コード例 #10
0
        public void TryCancel_EntryNotFound_DoesNotRemoveTaskFromQueue()
        {
            var queue = new DefaultAsyncWaitQueue <object>() as IAsyncWaitQueue <object>;
            var task  = queue.Enqueue();

            queue.Enqueue();
            queue.Dequeue().Dispose();
            queue.TryCancel(task).Dispose();
            Assert.IsFalse(queue.IsEmpty);
        }
コード例 #11
0
        public async Task Dequeue_WithTwoItems_OnlyCompletesFirstItem()
        {
            var queue = new DefaultAsyncWaitQueue <object>() as IAsyncWaitQueue <object>;
            var task1 = queue.Enqueue();
            var task2 = queue.Enqueue();

            queue.Dequeue();
            Assert.True(task1.IsCompleted);
            await AsyncAssert.NeverCompletesAsync(task2);
        }
コード例 #12
0
        public void TryCancel_EntryNotFound_DoesNotRemoveTaskFromQueue()
        {
            var queue = new DefaultAsyncWaitQueue <object>() as IAsyncWaitQueue <object>;
            var task  = queue.Enqueue();

            queue.Enqueue();
            queue.Dequeue();
            queue.TryCancel(task, new CancellationToken(true));
            Assert.False(queue.IsEmpty);
        }
コード例 #13
0
        public async Task Dequeue_WithTwoItems_OnlyCompletesFirstItem()
        {
            IAsyncWaitQueue <object> queue = new DefaultAsyncWaitQueue <object>() as IAsyncWaitQueue <object>;
            Task <object>            task1 = queue.Enqueue();
            Task <object>            task2 = queue.Enqueue();

            queue.Dequeue();
            Assert.True(task1.IsCompleted);
            await AsyncAssert.NeverCompletesAsync(task2).ConfigureAwait(false);
        }
コード例 #14
0
        public void Cancelled_WhenNotInQueue_DoesNotRemoveTaskFromQueue()
        {
            IAsyncWaitQueue <object> queue = new DefaultAsyncWaitQueue <object>() as IAsyncWaitQueue <object>;
            CancellationTokenSource  cts   = new CancellationTokenSource();
            Task <object>            task  = queue.Enqueue(new object(), cts.Token);
            Task <object>            _     = queue.Enqueue();

            queue.Dequeue();
            cts.Cancel();
            Assert.False(queue.IsEmpty);
        }
コード例 #15
0
        public void Cancelled_WhenNotInQueue_DoesNotRemoveTaskFromQueue()
        {
            var queue = new DefaultAsyncWaitQueue <object>() as IAsyncWaitQueue <object>;
            var cts   = new CancellationTokenSource();
            var task  = queue.Enqueue(cts.Token);
            var _     = queue.Enqueue();

            queue.Dequeue().Dispose();
            cts.Cancel();
            Assert.IsFalse(queue.IsEmpty);
        }
コード例 #16
0
 public void Dequeue_WithTwoItems_OnlyCompletesFirstItem()
 {
     Test.Async(async() =>
     {
         var queue = new DefaultAsyncWaitQueue <object>() as IAsyncWaitQueue <object>;
         var task1 = queue.Enqueue();
         var task2 = queue.Enqueue();
         queue.Dequeue().Dispose();
         Assert.IsTrue(task1.IsCompleted);
         await AssertEx.NeverCompletesAsync(task2);
     });
 }
コード例 #17
0
 public void Dequeue_WithTwoItems_OnlyCompletesFirstItem()
 {
     Test.Async(async () =>
     {
         var queue = new DefaultAsyncWaitQueue<object>() as IAsyncWaitQueue<object>;
         var task1 = queue.Enqueue();
         var task2 = queue.Enqueue();
         queue.Dequeue().Dispose();
         Assert.IsTrue(task1.IsCompleted);
         await AssertEx.NeverCompletesAsync(task2);
     });
 }
コード例 #18
0
 public void Cancelled_WhenNotInQueue_DoesNotRemoveTaskFromQueue()
 {
     var queue = new DefaultAsyncWaitQueue<object>() as IAsyncWaitQueue<object>;
     var cts = new CancellationTokenSource();
     var task = queue.Enqueue(new object(), cts.Token);
     var _ = queue.Enqueue();
     queue.Dequeue().Dispose();
     cts.Cancel();
     Assert.IsFalse(queue.IsEmpty);
 }
コード例 #19
0
 public void TryCancel_EntryNotFound_DoesNotRemoveTaskFromQueue()
 {
     var queue = new DefaultAsyncWaitQueue<object>() as IAsyncWaitQueue<object>;
     var task = queue.Enqueue();
     queue.Enqueue();
     queue.Dequeue().Dispose();
     queue.TryCancel(task).Dispose();
     Assert.IsFalse(queue.IsEmpty);
 }