public When_ProviderProximityService_Is_Called_To_Search_Providers_By_Postcode_Proximity_With_Route_Filter() { var dto = new ProviderProximitySearchParametersDto { Postcode = Postcode, SearchRadius = SearchRadius, SelectedRoutes = new List <int> { 12 } }; _searchProvider = Substitute.For <ISearchProvider>(); _searchProvider .SearchProvidersByPostcodeProximityAsync(dto) .Returns(new SearchResultsBuilder().Build()); _locationService = Substitute.For <ILocationService>(); _locationService.GetGeoLocationDataAsync(Postcode) .Returns(new PostcodeLookupResultDto { Postcode = Postcode, Longitude = "1.2", Latitude = "1.2" }); var routePathService = Substitute.For <IRoutePathService>(); var datetimeProvider = Substitute.For <IDateTimeProvider>(); var fileWriter = Substitute.For <IFileWriter <ProviderProximityReportDto> >(); var service = new ProviderProximityService(_searchProvider, _locationService, routePathService, fileWriter, datetimeProvider); _result = service.SearchProvidersByPostcodeProximityAsync(dto).GetAwaiter().GetResult(); }
public When_ProviderProximity_Controller_FindAllProviders_Is_Called_With_Unformatted_Postcode() { const string requestPostcode = "cV12 Wt"; var httpClient = new TestPostcodesIoHttpClient().Get(requestPostcode); var routes = new List <SelectListItem> { new SelectListItem { Text = "1", Value = "Route 1" }, new SelectListItem { Text = "2", Value = "Route 2" } }; var routeDictionary = new Dictionary <int, string> { { 1, "Route 1" }, { 2, "Route 2" } }; var locationService = new LocationService( new LocationApiClient(httpClient, new MatchingConfiguration { PostcodeRetrieverBaseUrl = "https://api.postcodes.io" })); var searchProvider = Substitute.For <ISearchProvider>(); var datetimeProvider = Substitute.For <IDateTimeProvider>(); var fileWriter = Substitute.For <IFileWriter <ProviderProximityReportDto> >(); var routePathService = Substitute.For <IRoutePathService>(); routePathService.GetRouteSelectListItemsAsync().Returns(routes); routePathService.GetRouteDictionaryAsync().Returns(routeDictionary); var providerProximityService = new ProviderProximityService(searchProvider, locationService, routePathService, fileWriter, datetimeProvider); var providerProximityController = new ProviderProximityController(routePathService, providerProximityService, locationService); const string postcode = requestPostcode; var viewModel = new ProviderProximitySearchParamViewModel { Postcode = postcode }; _result = providerProximityController.FindAllProviders(viewModel).GetAwaiter().GetResult(); }