Exemplo n.º 1
0
        public void AbortCausesReadToCancel()
        {
            var stream = new FrameRequestStream();

            stream.StartAcceptingReads(null);
            stream.Abort();
            var task = stream.ReadAsync(new byte[1], 0, 1);

            Assert.True(task.IsCanceled);
        }
        public void AbortCausesCopyToAsyncToCancel()
        {
            var stream = new FrameRequestStream(Mock.Of <IHttpBodyControlFeature>());

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

            Assert.True(task.IsCanceled);
        }
        public void AbortWithErrorCausesCopyToAsyncToCancel()
        {
            var stream = new FrameRequestStream(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);
        }
Exemplo n.º 4
0
 public void Abort(Exception error)
 {
     _request.Abort(error);
     _emptyRequest.Abort(error);
     _response.Abort();
 }