Esempio n. 1
0
    public async Task CalculateProviderLocationDistanceInMiles_Calculate_Distance_In_Miles_From_StudentPostcode_To_ProviderLocation_Using_LocationApi(
        string studentPostcode,
        double studentLat,
        double studentLon,
        double providerLat,
        double providerLon,
        int expectedMileageInMilesAfterRounding)
    {
        var postcodeLookupResultDto = new PostcodeLookupResultDto {
            Postcode = studentPostcode, Latitude = studentLat, Longitude = studentLon
        };

        _locationApiClient.GetGeoLocationDataAsync(studentPostcode).Returns(postcodeLookupResultDto);

        var providerLocation = new ProviderLocation {
            Latitude = providerLat, Longitude = providerLon
        };
        var providerLocations = new List <ProviderLocation>
        {
            providerLocation
        };

        await _distanceCalculationService.CalculateProviderLocationDistanceInMiles(new PostcodeLocation { Postcode = studentPostcode }, providerLocations.AsQueryable());

        var roundedDistanceInMiles = (int)Math.Round(providerLocation.DistanceInMiles, MidpointRounding.AwayFromZero);

        roundedDistanceInMiles.Should().Be(expectedMileageInMilesAfterRounding);

        await _locationApiClient.Received(1).GetGeoLocationDataAsync(studentPostcode);
    }
 public void LocationApiClient_IsValidPostcode_Is_Called_Exactly_Once()
 {
     _locationApiClient
     .Received(1)
     .IsValidPostcodeAsync(Arg.Is <string>(s => s == "Test provider venue"),
                           Arg.Is <bool>(b => b));
 }
Esempio n. 3
0
 public void LocationApiClient_GetGeoLocationDataAsync_Is_Called_Exactly_Once()
 {
     _locationApiClient
     .Received(1)
     .GetGeoLocationDataAsync(Arg.Is <string>(s => s == "CV1 2WT"),
                              Arg.Is <bool>(b => b));
 }
 public void Then_LocationApiClient_GetGeoLocationData_Is_Called_Exactly_Once()
 {
     _locationApiClient
     .Received(1)
     .GetGeoLocationDataAsync(UnFormattedPostcode, true);
 }