コード例 #1
0
        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>();
        }