public async Task ComputeHashAsync_SupportsCancellation() { using (CancellationTokenSource cancellationSource = new CancellationTokenSource(100)) using (PositionValueStream stream = new SlowPositionValueStream(10000)) using (HashAlgorithm hash = new SummingTestHashAlgorithm()) { await Assert.ThrowsAnyAsync <OperationCanceledException>( () => hash.ComputeHashAsync(stream, cancellationSource.Token)); } }
public void ComputeHashAsync_Disposed() { using (PositionValueStream stream = new SlowPositionValueStream(10000)) using (HashAlgorithm hash = new SummingTestHashAlgorithm()) { hash.Dispose(); Assert.Throws <ObjectDisposedException>( () => { // Not returning or awaiting the Task, it never got created. hash.ComputeHashAsync(stream); }); } }