public async Task AbortCausesCopyToAsyncToCancel()
        {
            var stream = new HttpRequestStream(Mock.Of <IHttpBodyControlFeature>());

            stream.StartAcceptingReads(null);
            stream.Abort();
            await Assert.ThrowsAsync <TaskCanceledException>(() => stream.CopyToAsync(Mock.Of <Stream>()));
        }
Example #2
0
        public void AbortCausesCopyToAsyncToCancel()
        {
            var stream = new HttpRequestStream(Mock.Of <IHttpBodyControlFeature>());

            stream.StartAcceptingReads(null);
            stream.Abort();
            var task = stream.CopyToAsync(Mock.Of <Stream>());

            Assert.True(task.IsCanceled);
        }
        public async Task AbortWithErrorCausesCopyToAsyncToCancel()
        {
            var stream = new HttpRequestStream(Mock.Of <IHttpBodyControlFeature>());

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

            stream.Abort(error);
            var exception = await Assert.ThrowsAsync <Exception>(() => stream.CopyToAsync(Mock.Of <Stream>()));

            Assert.Same(error, exception);
        }
Example #4
0
        public void AbortWithErrorCausesCopyToAsyncToCancel()
        {
            var stream = new HttpRequestStream(Mock.Of <IHttpBodyControlFeature>());

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

            stream.Abort(error);
            var task = stream.CopyToAsync(Mock.Of <Stream>());

            Assert.True(task.IsFaulted);
            Assert.Same(error, task.Exception.InnerException);
        }
Example #5
0
 public void Abort(Exception error)
 {
     _request.Abort(error);
     _emptyRequest.Abort(error);
     _response.Abort();
 }