public async Task AbortCausesReadToCancel()
        {
            var pipeReader = new HttpRequestPipeReader();

            pipeReader.StartAcceptingReads(null);
            pipeReader.Abort();
            await Assert.ThrowsAsync <TaskCanceledException>(() => pipeReader.ReadAsync().AsTask());
        }
        public async Task StopAcceptingReadsCausesReadToThrowObjectDisposedException()
        {
            var pipeReader = new HttpRequestPipeReader();

            pipeReader.StartAcceptingReads(null);
            pipeReader.StopAcceptingReads();

            // Validation for ReadAsync occurs in an async method in ReadOnlyPipeStream.
            await Assert.ThrowsAsync <ObjectDisposedException>(async() => { await pipeReader.ReadAsync(); });
        }
        public async Task AbortWithErrorCausesReadToCancel()
        {
            var pipeReader = new HttpRequestPipeReader();

            pipeReader.StartAcceptingReads(null);
            var error = new Exception();

            pipeReader.Abort(error);
            var exception = await Assert.ThrowsAsync <Exception>(() => pipeReader.ReadAsync().AsTask());

            Assert.Same(error, exception);
        }