public async Task SelectSpecificationForFunding(string specificationId) { Guard.IsNullOrWhiteSpace(specificationId, nameof(specificationId)); HttpStatusCode specificationForFundingResponse = await _resiliencePolicy.ExecuteAsync(() => _specifications.SelectSpecificationForFunding(specificationId)); if (!specificationForFundingResponse.IsSuccess()) { throw new Exception($"Failed to select specification with id '{specificationId}' for funding."); } }
public void SelectSpecificationForFunding__GivenNonSuccessResponse_ThrowsException() { //Arrange string specificationId = new RandomString(); _specifications.SelectSpecificationForFunding(Arg.Is(specificationId)) .Returns(HttpStatusCode.NotFound); //Act Func <Task> test = async() => await _service.SelectSpecificationForFunding(specificationId); //Assert test .Should() .ThrowExactly <Exception>() .Which .Message .Should() .Be($"Failed to select specification with id '{specificationId}' for funding."); }