public void PerformSearch_WhenFindSpecificationsServiceUnavailable_ThenHttpExceptionThrown() { // Arrange ISpecificationsApiClient specsClient = Substitute.For <ISpecificationsApiClient>(); ILogger logger = Substitute.For <ILogger>(); IMapper mapper = MappingHelper.CreateFrontEndMapper(); ISpecificationSearchService SpecificationSearchService = new SpecificationSearchService(specsClient, mapper, logger); specsClient .When(a => a.FindSpecifications(Arg.Any <SearchFilterRequest>())) .Do(x => { throw new HttpRequestException(); }); SearchRequestViewModel request = new SearchRequestViewModel(); // Act Action pageAction = new Action(() => { SpecificationSearchResultViewModel result = SpecificationSearchService.PerformSearch(request).Result; }); // Assert pageAction.Should().Throw <HttpRequestException>(); }