public async Task SearchByPostCodeShouldIndicateIfANullOrEmptyPostCodeIsPassed(string postcode) { var service = new ProviderSearchServiceBuilder().Build(); var result = await service.SearchProviders("123-2-1", postcode, _pageZeroWithTenItems, null, false, false); Assert.That(result.PostCodeMissing, Is.True); }
public async Task SearchByPostCodeShouldIndicateThereWasAnErrorIfSearchThrowsAnException() { ProviderSearchService service = new ProviderSearchServiceBuilder() .SetupFrameworkRepository(m => m.GetFrameworkById(It.IsAny <string>()), new Framework()) .SetupPostCodeLookup(x => x.GetLatLongFromPostCode(It.IsAny <string>()), Task.FromResult(_testPostCodeCoordinate)) .SetupProviderSearchProviderException <SearchException>(x => x. SearchProvidersByLocation(It.IsAny <string>(), It.IsAny <Coordinate>(), It.IsAny <int>(), It.IsAny <int>(), It.IsAny <ProviderSearchFilter>(), 0)); var result = await service.SearchProviders("-1", "AS3 4AS", _pageZeroWithTenItems, null, false, false); result.ResponseCode.Should().Be(LocationLookupResponse.ApprenticeshipNotFound); }
public async Task SearchByPostCodeShouldAlwaysReturnTheFrameworkId(string postcode) { const string TestApprenticeshipId = "123-2-1"; var searchResults = new ProviderSearchResult <ProviderSearchResultItem> { Hits = null, Total = 0 }; ProviderSearchService service = new ProviderSearchServiceBuilder() .SetupPostCodeLookup(x => x.GetLatLongFromPostCode(It.IsAny <string>()), Task.FromResult(_testPostCodeCoordinate)) .SetupProviderSearchProvider(x => x.SearchProvidersByLocation(It.IsAny <string>(), It.IsAny <Coordinate>(), It.IsAny <int>(), It.IsAny <int>(), It.IsAny <ProviderSearchFilter>(), 0), Task.FromResult(searchResults)); var result = await service.SearchProviders(TestApprenticeshipId, postcode, _pageZeroWithTenItems, null, false, false); result.ApprenticeshipId.Should().Be(TestApprenticeshipId); }
public async Task SearchByPostCodeShouldIncludeFrameworkTitle() { const string TestApprenticeshipTitle = "Test Title"; var searchResults = new ProviderSearchResult <ProviderSearchResultItem> { Hits = null, Total = 0 }; ProviderSearchService service = new ProviderSearchServiceBuilder() .SetupPostCodeLookup(x => x.GetLatLongFromPostCode(It.IsAny <string>()), Task.FromResult(_testPostCodeCoordinate)) .SetupFrameworkRepository(x => x.GetFrameworkById(It.IsAny <string>()), new Framework() { Title = TestApprenticeshipTitle }) .SetupProviderSearchProvider(x => x.SearchProvidersByLocation(It.IsAny <string>(), It.IsAny <Coordinate>(), It.IsAny <int>(), It.IsAny <int>(), It.IsAny <ProviderSearchFilter>(), 0), Task.FromResult(searchResults)); var result = await service.SearchProviders("123-2-1", "AS3 4AS", _pageZeroWithTenItems, null, false, false); result.Title.Should().Be(TestApprenticeshipTitle); }
public async Task SearchByPostCodeShouldIncludeCountOfResults() { const long testTotalResults = 5; var frameworkId = "123-1-2"; var framework = new Framework { FrameworkId = "123-1-2", FrameworkName = "Test framework name" }; var searchResults = new ProviderSearchResult <ProviderSearchResultItem> { Hits = null, Total = testTotalResults }; ProviderSearchService service = new ProviderSearchServiceBuilder() .SetupFrameworkRepository(x => x.GetFrameworkById(It.IsAny <string>()), framework) .SetupPostCodeLookup(x => x.GetLatLongFromPostCode(It.IsAny <string>()), Task.FromResult(_testPostCodeCoordinate)) .SetupProviderSearchProvider(x => x.SearchProvidersByLocation(It.IsAny <string>(), It.IsAny <Coordinate>(), It.IsAny <int>(), It.IsAny <int>(), It.IsAny <ProviderSearchFilter>(), 0), Task.FromResult(searchResults)); var result = await service.SearchProviders(frameworkId, "AS2 3SS", _pageZeroWithTenItems, null, false, false); result.TotalResults.Should().Be(testTotalResults); }