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>())); }
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); }
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); }
public void Abort(Exception error) { _request.Abort(error); _emptyRequest.Abort(error); _response.Abort(); }