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); }
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); }
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); }
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); }
public void Dequeue_SynchronouslyCompletesTask() { var queue = new DefaultAsyncWaitQueue <object>() as IAsyncWaitQueue <object>; var task = queue.Enqueue(); queue.Dequeue(); Assert.True(task.IsCompleted); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }); }
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); }); }
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); }
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); }