Beispiel #1
0
        public async Task GetVacancyListByRoute_Function_Not_Ran(string postcode)
        {
            await sut.GetByRoute("1", postcode, 10);

            _vacanciesApi.Verify(v => v.SearchApprenticeshipVacanciesByLocationAsync(It.IsAny <double>(), It.IsAny <double>(),
                                                                                     It.IsAny <int>(), It.IsAny <int>(), It.IsAny <int>(), It.Is <string>(s => s.Equals(_standardIds))), Times.Never());
        }
Beispiel #2
0
        private async Task <SearchResultsViewModel> GetSearchResults(string route, string postcode, int distance)
        {
            var viewModel = new SearchResultsViewModel();

            viewModel.Route    = route;
            viewModel.Distance = distance;
            viewModel.Postcode = postcode;

            var routeId = route.Replace("-", " ");

            var routes     = _repository.GetRoutes();
            var searchTask = _vacanciesService.GetByRoute(routeId, postcode, Convert.ToInt32(distance));

            await Task.WhenAll(routes, searchTask);

            var searchResults = searchTask.Result;

            if (searchResults != null)
            {
                viewModel.TotalResults = searchResults.Results.Count;
                viewModel.Results      = searchResults.Results.Where(w => w.DistanceInMiles <= distance).Take(100).ToList();

                viewModel.Location     = searchResults.searchLocation;
                viewModel.StaticMapUrl = _mappingService.GetStaticMapsUrl(searchResults.Results.Select(p => p.Location), "680", "530");

                viewModel.Country = searchResults.Country;
                viewModel.Routes  = routes.Result;
            }


            return(viewModel);
        }
        public async Task Then_Location_Is_Returned()
        {
            _searchResultCount = 200;

            var results = await sut.GetByRoute("1", postcode, 20);

            Assert.AreEqual(results.searchLocation.Longitude, coordinatesResponse.Coordinates.Lon);
            Assert.AreEqual(results.searchLocation.Latitude, coordinatesResponse.Coordinates.Lat);
        }
        public async Task Then_Coordinates_Are_Retrieved_For_Postcode_By_GeocodeService()
        {
            await sut.GetByRoute("1", postcode, 10);

            _geocodeService.Verify(s => s.GetFromPostCode(postcode), Times.Once);
        }