public void CategoryMappingTest() { const ApprenticeshipSearchMode searchMode = ApprenticeshipSearchMode.Category; const string keywords = "chef"; const string location = "Warwick"; const int withinDistance = 15; const string apprenticeshipLevel = "Advanced"; const string category = "MFP"; var subCategories = new[] { "513", "540" }; const string searchField = "JobTitle"; var savedSearch = new SavedSearchBuilder() .WithSearchMode(searchMode) .WithKeywords(keywords) .WithLocation(location) .WithinDistance(withinDistance) .WithApprenticeshipLevel(apprenticeshipLevel) .WithCategory(category) .WithSubCategories(subCategories) .WithSearchField(searchField) .Build(); var parameters = SearchParametersFactory.Create(savedSearch); parameters.Should().NotBeNull(); parameters.Keywords.Should().BeNullOrEmpty(); parameters.Location.Should().NotBeNull(); parameters.Location.Name.Should().Be(location); parameters.SearchRadius.Should().Be(withinDistance); parameters.ApprenticeshipLevel.Should().Be(apprenticeshipLevel); parameters.CategoryCode.Should().Be(category); parameters.SubCategoryCodes.Should().BeEquivalentTo(subCategories); parameters.SearchField.Should().Be(ApprenticeshipSearchField.All); }
public void SectorFrameworkName() { var savedSearch = new SavedSearchBuilder().WithSearchMode(ApprenticeshipSearchMode.Category).WithLocation("CV1 2WT").WithCategory("CST").WithCategoryFullName("Construction, Planning and the Built Environment").WithSubCategories(new[] { "522", "532" }).WithinDistance(10).Build(); var name = savedSearch.Name(); name.Should().Be("Construction, Planning and the Built Environment within 10 miles of CV1 2WT"); }
public void EnglandSearchName() { var savedSearch = new SavedSearchBuilder().WithKeywords("engineering").WithinDistance(0).WithLocation("CV1 2WT").Build(); var name = savedSearch.Name(); name.Should().Be("engineering within England"); }
public void SectorSearchName() { var savedSearch = new SavedSearchBuilder().WithSearchMode(ApprenticeshipSearchMode.Category).WithCategory("CST").WithCategoryFullName("Construction, Planning and the Built Environment").WithinDistance(0).Build(); var name = savedSearch.Name(); name.Should().Be("Construction, Planning and the Built Environment within England"); }
public void LocationSearchName() { var savedSearch = new SavedSearchBuilder().WithinDistance(10).WithLocation("Coventry").Build(); var name = savedSearch.Name(); name.Should().Be("Within 10 miles of Coventry"); }
public void KeywordSearchFieldSearchName(ApprenticeshipSearchField apprenticeshipSearchField, string expectedPrefix) { var savedSearch = new SavedSearchBuilder().WithSearchField(apprenticeshipSearchField.ToString()).WithKeywords("engineering").WithinDistance(5).WithLocation("CV1 2WT").Build(); var name = savedSearch.Name(); name.Should().Be(string.Format("{0}engineering within 5 miles of CV1 2WT", expectedPrefix)); }
public void LocationSearchUrl() { var savedSearch = new SavedSearchBuilder().WithinDistance(10).WithLocation("Coventry").Build(); var searchUrl = savedSearch.SearchUrl(); searchUrl.Should().NotBeNull(); searchUrl.Value.Should().Be("/apprenticeships?SearchMode=Keyword&Location=Coventry&Hash=0&WithinDistance=10&ApprenticeshipLevel=All&SearchField=All&DisplaySubCategory=True&DisplayDescription=True&DisplayDistance=True&DisplayClosingDate=True&DisplayStartDate=True&DisplayApprenticeshipLevel=False&DisplayWage=False&SearchAction=Search&LocationType=NonNational"); }
public void TruncatedSubCategoriesFullNames_Seven() { var savedSearch = new SavedSearchBuilder().WithSubCategoriesFullNames(GetSubCategoriesFullNames(7, "|")).Build(); var truncatedSubCategoriesFullNames = savedSearch.TruncatedSubCategoriesFullNames(5); truncatedSubCategoriesFullNames.Should().NotBeNull(); truncatedSubCategoriesFullNames.Should().Be("Sub Category 01, Sub Category 02, Sub Category 03, Sub Category 04, Sub Category 05 and 2 more"); }
public void TruncatedSubCategoriesFullNames_One() { var savedSearch = new SavedSearchBuilder().WithSubCategoriesFullNames(GetSubCategoriesFullNames(1, ", ")).Build(); var truncatedSubCategoriesFullNames = savedSearch.TruncatedSubCategoriesFullNames(5); truncatedSubCategoriesFullNames.Should().NotBeNull(); truncatedSubCategoriesFullNames.Should().Be("Sub Category 01"); }
public void SectorFrameworkSearchUrl() { var savedSearch = new SavedSearchBuilder().WithSearchMode(ApprenticeshipSearchMode.Category).WithLocation("CV1 2WT").WithCategory("CST").WithSubCategories(new[] { "522", "532" }).WithinDistance(10).Build(); var searchUrl = savedSearch.SearchUrl(); searchUrl.Should().NotBeNull(); searchUrl.Value.Should().Be("/apprenticeships?SearchMode=Category&Location=CV1+2WT&Hash=0&WithinDistance=10&ApprenticeshipLevel=All&Category=CST&SearchField=All&DisplaySubCategory=True&DisplayDescription=True&DisplayDistance=True&DisplayClosingDate=True&DisplayStartDate=True&DisplayApprenticeshipLevel=False&DisplayWage=False&SearchAction=Search&LocationType=NonNational&SubCategories=522&SubCategories=532"); }
public void SectorSearchUrl() { var savedSearch = new SavedSearchBuilder().WithSearchMode(ApprenticeshipSearchMode.Category).WithCategory("CST").WithinDistance(0).Build(); var searchUrl = savedSearch.SearchUrl(); searchUrl.Should().NotBeNull(); searchUrl.Value.Should().Be("/apprenticeships?SearchMode=Category&Hash=0&WithinDistance=0&ApprenticeshipLevel=All&Category=CST&SearchField=All&DisplaySubCategory=True&DisplayDescription=True&DisplayDistance=True&DisplayClosingDate=True&DisplayStartDate=True&DisplayApprenticeshipLevel=False&DisplayWage=False&SearchAction=Search&LocationType=NonNational"); }
public void EnglandSearchUrl() { var savedSearch = new SavedSearchBuilder().WithKeywords("engineering").WithinDistance(0).WithLocation("CV1 2WT").Build(); var searchUrl = savedSearch.SearchUrl(); searchUrl.Should().NotBeNull(); searchUrl.Value.Should().Be("/apprenticeships?SearchMode=Keyword&Location=CV1+2WT&Hash=0&Keywords=engineering&WithinDistance=0&ApprenticeshipLevel=All&SearchField=All&DisplaySubCategory=True&DisplayDescription=True&DisplayDistance=True&DisplayClosingDate=True&DisplayStartDate=True&DisplayApprenticeshipLevel=False&DisplayWage=False&SearchAction=Search&LocationType=NonNational"); }
public void LatLongTest() { var savedSearch = new SavedSearchBuilder().WithLatLong(1.1, 2.1).Build(); var parameters = SearchParametersFactory.Create(savedSearch); parameters.Location.Should().NotBeNull(); parameters.Location.GeoPoint.Should().NotBeNull(); parameters.Location.GeoPoint.Latitude.Should().Be(1.1); parameters.Location.GeoPoint.Longitude.Should().Be(2.1); }
public void DefaultsTest() { var savedSearch = new SavedSearchBuilder().Build(); var parameters = SearchParametersFactory.Create(savedSearch); parameters.Should().NotBeNull(); parameters.PageSize.Should().Be(5); parameters.PageNumber.Should().Be(1); parameters.SortType.Should().Be(VacancySearchSortType.RecentlyAdded); parameters.VacancyLocationType.Should().Be(ApprenticeshipLocationType.NonNational); }
public void LocationLatLongSearchUrl() { var savedSearch = new SavedSearchBuilder().WithinDistance(10).WithLocation("Coventry").WithLatLong(1.1d, 2.1d).Build(); var searchUrl = savedSearch.SearchUrl(); searchUrl.Should().NotBeNull(); searchUrl.Value.Should().BeOneOf( "/apprenticeships?SearchMode=Keyword&Location=Coventry&Longitude=2.1&Latitude=1.1&Hash=-1434161545&WithinDistance=10&ApprenticeshipLevel=All&SearchField=All&DisplaySubCategory=True&DisplayDescription=True&DisplayDistance=True&DisplayClosingDate=True&DisplayStartDate=True&DisplayApprenticeshipLevel=False&DisplayWage=False&SearchAction=Search&LocationType=NonNational", "/apprenticeships?SearchMode=Keyword&Location=Coventry&Longitude=2.1&Latitude=1.1&Hash=-94534883&WithinDistance=10&ApprenticeshipLevel=All&SearchField=All&DisplaySubCategory=True&DisplayDescription=True&DisplayDistance=True&DisplayClosingDate=True&DisplayStartDate=True&DisplayApprenticeshipLevel=False&DisplayWage=False&SearchAction=Search&LocationType=NonNational"); }
public void DuplicatesAreReplaced() { var candidateId = Guid.NewGuid(); const ApprenticeshipSearchMode searchMode = ApprenticeshipSearchMode.Category; const string keywords = "chef"; const string location = "Warwick"; const double latitude = 1.1; const double longitude = 2.1; const int withinDistance = 15; const string apprenticeshipLevel = "Advanced"; const string category = "MFP"; const string categoryFullName = "Engineering and Manufacturing Technologies"; var subCategories = new[] { "513", "540" }; const string subCategoriesFullNames = "Surveying, Construction Civil Engineering"; const string searchField = "JobTitle"; var categories = new List <Category> { new Category(17, category, categoryFullName, CategoryType.SectorSubjectAreaTier1, CategoryStatus.Active, new List <Category> { new Category(255, "513", "Surveying", CategoryType.Framework, CategoryStatus.Active), new Category(273, "540", "Construction Civil Engineering", CategoryType.Framework, CategoryStatus.Active) } ) }; var existingSavedSearch = new SavedSearchBuilder() .WithSearchMode(searchMode) .WithKeywords(keywords) .WithLocation(location) .WithLatLong(latitude, longitude) .WithinDistance(withinDistance) .WithApprenticeshipLevel(apprenticeshipLevel) .WithCategory(category) .WithCategoryFullName(categoryFullName) .WithSubCategories(subCategories) .WithSubCategoriesFullNames(subCategoriesFullNames) .WithSearchField(searchField) .Build(); var candidateService = new Mock <ICandidateService>(); candidateService.Setup(cs => cs.GetSavedSearches(candidateId)).Returns(new List <SavedSearch> { existingSavedSearch }); var provider = new CandidateServiceProviderBuilder().With(candidateService).Build(); var viewModel = new ApprenticeshipSearchViewModelBuilder() .WithSearchMode(searchMode) .WithKeywords(keywords) .WithLocation(location) .WithLatLong(latitude, longitude) .WithinDistance(withinDistance) .WithApprenticeshipLevel(apprenticeshipLevel) .WithCategory(category) .WithSubCategories(subCategories) .WithSearchField(searchField) .WithCategories(categories) .Build(); var response = provider.CreateSavedSearch(candidateId, viewModel); response.Should().NotBeNull(); candidateService.Verify(cs => cs.GetSavedSearches(candidateId), Times.Once); //Should only replace search if it is new candidateService.Verify(cs => cs.CreateSavedSearch(It.IsAny <SavedSearch>()), Times.Never); }