public void Dispose_FaultsAwaiters() { var quota = new Quota(1L); using (var cts = new CancellationTokenSource()) { var awaiters = new[] { quota.WaitAsync(), quota.WaitAsync(cts.Token), quota.WaitAsync(), quota.WaitAsync() }; cts.Cancel(); quota.Dispose(); using (TaskAssert.Completed(awaiters[0])) { } TaskAssert.Cancelled(awaiters[1]); foreach (var awaiter in awaiters.Skip(2)) { TaskAssert.Faulted <ObjectDisposedException>(awaiter); } } }
public void OrCanceledBy_NotCanceled_Propagates(TaskStatus AStatus) { using (var cts = new CancellationTokenSource()) { var tcs = new TaskCompletionSource <Void>(); var cont = tcs.Task.OrCanceledBy(cts.Token); Assume.That(cont.Wait(10), Is.False); switch (AStatus) { case TaskStatus.RanToCompletion: tcs.TrySetResult(default); TaskAssert.Completed(cont); break; case TaskStatus.Canceled: tcs.TrySetCanceled(_FCanceled.Token); TaskAssert.Cancelled(cont); break; case TaskStatus.Faulted: tcs.TrySetException(_FFaulted); Assert.That( TaskAssert.Faulted <Exception>(cont), Is.SameAs(_FFaulted) ); break; default: throw new NotImplementedException(); } } }
public void Dispose_FaultsAwaiters() { var lck = new Lock(); using (var cts = new CancellationTokenSource()) { var awaiters = new[] { TaskAssert.Detach(lck.WaitAsync), TaskAssert.Detach(() => lck.WaitAsync(cts.Token)), TaskAssert.Detach(lck.WaitAsync), TaskAssert.Detach(lck.WaitAsync) }; cts.Cancel(); lck.Dispose(); using (TaskAssert.Completed(awaiters[0])) { } TaskAssert.Cancelled(awaiters[1]); foreach (var awaiter in awaiters.Skip(2)) { TaskAssert.Faulted <ObjectDisposedException>(awaiter); } } }
public void Dispose_FaultsAwaiters() { var turnstile = new Turnstile(); using (var cts = new CancellationTokenSource()) { var awaiters = new[] { turnstile.WaitAsync(), turnstile.WaitAsync(cts.Token), turnstile.WaitAsync(), turnstile.WaitAsync() }; cts.Cancel(); turnstile.Dispose(); TaskAssert.Faulted <ObjectDisposedException>(awaiters[0]); TaskAssert.Cancelled(awaiters[1]); foreach (var awaiter in awaiters.Skip(2)) { TaskAssert.Faulted <ObjectDisposedException>(awaiter); } } }
public void WaitAsync_Disposed_ReturnsFaultedTask() { var future = new Future <int>(); future.Dispose(); TaskAssert.Faulted <ObjectDisposedException>(future.WaitAsync()); }
public void WaitAsync_Disposed_ReturnsFaultedTask() { var evt = new Event <int>(); evt.Dispose(); TaskAssert.Faulted <ObjectDisposedException>(evt.WaitAsync()); }
public void WaitAsync_Disposed_ThrowsObjectDisposedException() { var cond = new Condition(); cond.Dispose(); TaskAssert.Faulted <ObjectDisposedException>(cond.WaitAsync()); }
public void WaitAsync_Disposed_ReturnsFaultedTask() { var trigger = new Trigger(); trigger.Dispose(); TaskAssert.Faulted <ObjectDisposedException>(trigger.WaitAsync()); }
public void WaitAsync_Disposed_ReturnsFaultedTask() { var era = new Era(); era.Dispose(); TaskAssert.Faulted <ObjectDisposedException>(era.WaitAsync()); }
public void WaitAsync_Disposed_ThrowsObjectDisposedException() { var quota = new Quota(1L); quota.Dispose(); TaskAssert.Faulted <ObjectDisposedException>(quota.WaitAsync()); }
public void WaitAsync_Disposed_ThrowsObjectDisposedException() { var lck = new Lock(); lck.Dispose(); TaskAssert.Faulted <ObjectDisposedException>(lck.WaitAsync()); }
public void WaitAsync_Disposed_ThrowsObjectDisposedException() { var turnstile = new Turnstile(); turnstile.Dispose(); TaskAssert.Faulted <ObjectDisposedException>(turnstile.WaitAsync()); }
public void Dispose_FaultsAwaiters() { var era = new Era(); var awaiter = era.WaitAsync(); era.Dispose(); TaskAssert.Faulted <ObjectDisposedException>(awaiter); }
public void Dispose_FaultsAwaiters() { var trigger = new Trigger(); var awaiter = trigger.WaitAsync(); trigger.Dispose(); TaskAssert.Faulted <ObjectDisposedException>(awaiter); }
public void Dispose_FaultsAwaiters() { var evt = new Event <int>(); var awaiter = evt.WaitAsync(); evt.Dispose(); TaskAssert.Faulted <ObjectDisposedException>(awaiter); }
public void Dispose_FaultsAwaiters() { var future = new Future <int>(); var awaiter = future.WaitAsync(); future.Dispose(); TaskAssert.Faulted <ObjectDisposedException>(awaiter); }
public void Dispose_FaultsAwaiters() { var cond = new Condition(); var awaiter = cond.WaitAsync(); cond.Dispose(); TaskAssert.Faulted <ObjectDisposedException>(awaiter); }
public void WaitAsync_Disposed_ThrowsObjectDisposedException() { var barrier = new Barrier(3); barrier.Dispose(); var awaiter = barrier.WaitAsync(); TaskAssert.Faulted <ObjectDisposedException>(awaiter); }
public void Dispose_FaultsAwaiters() { var barrier = new Barrier(3); var awaiters = new [] { barrier.WaitAsync(), barrier.WaitAsync() }; barrier.Dispose(); foreach (var awaiter in awaiters) { TaskAssert.Faulted <ObjectDisposedException>(awaiter); } }