public void PerformSearch_WhenFindSpecificationsServiceUnavailable_ThenHttpExceptionThrown() { // Arrange ISpecsApiClient specsClient = Substitute.For <ISpecsApiClient>(); ILogger logger = Substitute.For <ILogger>(); IMapper mapper = MappingHelper.CreateFrontEndMapper(); IFeatureToggle featureToggle = CreateFeatureToggle(); ISpecificationSearchService SpecificationSearchService = new SpecificationSearchService(specsClient, mapper, logger, featureToggle); 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>(); }