Beispiel #1
0
        public When_ProviderProximity_Controller_RefineSearchResults_Is_Called()
        {
            var locationService = Substitute.For <ILocationService>();

            locationService.IsValidPostcodeAsync(Arg.Any <string>()).Returns((true, "CV1 2WT"));

            var opportunityProximityService = Substitute.For <IOpportunityProximityService>();

            _routeService = Substitute.For <IRoutePathService>();
            _routeService.GetRouteIdsAsync().Returns(new List <int> {
                1, 2
            });

            var opportunityService = Substitute.For <IOpportunityService>();

            var opportunityProximityController = new OpportunityProximityController(_routeService, opportunityProximityService, opportunityService,
                                                                                    locationService);

            var viewModel = new SearchParametersViewModel
            {
                Postcode           = "CV12WT",
                SelectedRouteId    = 1,
                CompanyNameWithAka = "CompanyName (AlsoKnownAs)"
            };

            _result = opportunityProximityController.RefineSearchResultsAsync(viewModel).GetAwaiter().GetResult();
        }
        public When_OpportunityProximity_Controller_RefineSearchResults_Is_Called_With_Invalid_Postcode()
        {
            const string requestPostcode = "CV1234";
            var          httpClient      = new TestPostcodesIoHttpClient().Get(requestPostcode);

            var routes = new List <SelectListItem>
            {
                new SelectListItem {
                    Text = "1", Value = "Route 1"
                }
            };

            var locationService = new LocationService(new LocationApiClient(httpClient, new MatchingConfiguration
            {
                PostcodeRetrieverBaseUrl = "https://api.postcodes.io"
            }));

            var opportunityProximityService = new OpportunityProximityService(Substitute.For <ISearchProvider>(), locationService);

            var routePathService = Substitute.For <IRoutePathService>();

            routePathService.GetRouteSelectListItemsAsync().Returns(routes);

            var opportunityService = Substitute.For <IOpportunityService>();

            _opportunityProximityController = new OpportunityProximityController(routePathService, opportunityProximityService, opportunityService, locationService);

            var viewModel = new SearchParametersViewModel
            {
                Postcode        = "CV1234",
                SelectedRouteId = 1
            };

            _result = _opportunityProximityController.RefineSearchResultsAsync(viewModel).GetAwaiter().GetResult();
        }
Beispiel #3
0
        public When_OpportunityProximity_Controller_RefineSearchResults_Is_Called_With_Unformatted_Postcode()
        {
            const string requestPostcode = "Cv 12 Wt";
            var          httpClient      = new TestPostcodesIoHttpClient().Get(requestPostcode);

            var locationService = new LocationService(new LocationApiClient(httpClient, new MatchingConfiguration
            {
                PostcodeRetrieverBaseUrl = "https://api.postcodes.io"
            }));

            var opportunityProximityService = new OpportunityProximityService(Substitute.For <ISearchProvider>(), locationService);

            _routeService = Substitute.For <IRoutePathService>();
            _routeService.GetRouteIdsAsync().Returns(new List <int> {
                1, 2
            });

            var opportunityService = Substitute.For <IOpportunityService>();

            var opportunityProximityController = new OpportunityProximityController(_routeService, opportunityProximityService, opportunityService, locationService);

            var viewModel = new SearchParametersViewModel
            {
                Postcode        = requestPostcode,
                SelectedRouteId = 1
            };

            _result = opportunityProximityController.RefineSearchResultsAsync(viewModel).GetAwaiter().GetResult();
        }