public void PerformSearch_WhenFindCalculationsServiceUnavailable_ThenHttpExceptionThrown() { // Arrange ICalculationsApiClient calcsClient = Substitute.For <ICalculationsApiClient>(); ILogger logger = Substitute.For <ILogger>(); IMapper mapper = MappingHelper.CreateFrontEndMapper(); IFeatureToggle featureToggle = CreateFeatureToggle(); ICalculationSearchService calculationSearchService = new CalculationSearchService(calcsClient, mapper, logger, featureToggle); calcsClient .When(a => a.FindCalculations(Arg.Any <SearchFilterRequest>())) .Do(x => { throw new HttpRequestException(); }); SearchRequestViewModel request = new SearchRequestViewModel(); // Act Action pageAction = new Action(() => { CalculationSearchResultViewModel result = calculationSearchService.PerformSearch(request).Result; }); // Assert pageAction.Should().Throw <HttpRequestException>(); }