public async Task ExecuteShouldHandleHttpRequestException()
        {
            _subject.Response = () =>
            {
                var tcr = new TaskCompletionSource <HttpStreamResult>();
                tcr.SetResult(new HttpStreamResult {
                    Exception = new HttpRequestException()
                });

                return(tcr.Task);
            };

            await Task.Run(() => _subject.Execute(new ActionExecutionContext()));

            _subject.Error.Should().BeOfType <CommunicationException>();
        }
示例#2
0
        public async Task ExecuteShouldHandleHttpRequestException()
        {
            _subject.GetResourceFunc = () =>
            {
                var taskCompletionSource = new TaskCompletionSource <HttpStreamResult>();
                taskCompletionSource.SetResult(new HttpStreamResult {
                    Exception = new HttpRequestException()
                });

                return(taskCompletionSource.Task);
            };

            await _subject.Execute();

            _subject.Error.Should().BeOfType <HttpRequestException>();
        }