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>(); }
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>(); }