public async Task <(bool IsValid, PostcodeLocation PostcodeLocation)> IsSearchPostcodeValid(string postcode) { if (!Regex.IsMatch(postcode, PostcodeRegexPattern, RegexOptions.IgnoreCase)) { _logger.LogInformation("Postcode regex failed for {postcode}", postcode); return(false, null); } return(await _distanceCalculationService.IsPostcodeValid(postcode)); }
public async Task IsSearchPostcodeValid_Validate_A_Postcode(string postcode, bool expected) { _distanceCalculationService.IsPostcodeValid(postcode).Returns((expected, new PostcodeLocation { Postcode = postcode })); var(isValid, postcodeLocation) = await _service.IsSearchPostcodeValid(postcode); isValid.Should().Be(expected); postcodeLocation.Should().NotBeNull(); postcodeLocation.Postcode.Should().Be(postcode); await _distanceCalculationService.Received(1).IsPostcodeValid(postcode); }
public async Task IsPostcodeValid_Validate_a_Postcode_Including_TerminatedPostcodes(string postcode, bool isValid) { var postcodeLookupResultDto = isValid ? new PostcodeLookupResultDto { Postcode = postcode } : null; var expected = isValid; _locationApiClient.GetGeoLocationDataAsync(postcode).Returns(postcodeLookupResultDto); var actual = await _distanceCalculationService.IsPostcodeValid(postcode); actual.IsValid.Should().Be(expected); await _locationApiClient.Received(1).GetGeoLocationDataAsync(postcode); }
public async Task <(bool IsValid, PostcodeLocation PostcodeLocation)> IsSearchPostcodeValid(string postcode) { return(await _distanceCalculationService.IsPostcodeValid(postcode)); }