public LarsSearchController( ISearchClient <Lars> searchClient, IOptions <LarsSearchSettings> larsSearchSettings) { _searchClient = searchClient ?? throw new ArgumentNullException(nameof(searchClient)); _larsSearchSettings = larsSearchSettings?.Value ?? throw new ArgumentNullException(nameof(larsSearchSettings)); }
private void ResetMocks() { AddressSearchService.Reset(); BlobServiceClient.Reset(); ProviderSearchClient.Reset(); BinaryStorageProvider.Reset(); LarsSearchClient.Reset(); LarsSearchSettings.Reset(); }
private async Task ChooseQualification_NotionalNVQLevelv2FiltersCount_IsCorrect() { // Arrange var provider = await TestData.CreateProvider(); var notionalNVQLevelv2Facets = new Dictionary <object, long?> { { new Object(), 343 }, { new Object(), 3433 }, { new Object(), 341 } }; var awardOrgCodeFacets = new Dictionary <object, long?>(); dfc.SearchResult <Lars> res = new dfc.SearchResult <Lars> { Items = new ReadOnlyCollection <dfc.SearchResultItem <Lars> >(new List <dfc.SearchResultItem <Lars> >() { new dfc.SearchResultItem <Lars>() { Record = new Lars(), }, new dfc.SearchResultItem <Lars>() { Record = new Lars(), } }), TotalCount = 2, Facets = new Dictionary <string, IReadOnlyDictionary <object, long?> > { { "AwardOrgCode", awardOrgCodeFacets }, { "NotionalNVQLevelv2", notionalNVQLevelv2Facets } } }; LarsSearchClient.Setup(x => x.Search(It.IsAny <dfc.LarsSearchQuery>())).ReturnsAsync(res); LarsSearchSettings.Setup(x => x.Value).Returns(new Core.Configuration.LarsSearchSettings() { ItemsPerPage = 20 }); var request = new HttpRequestMessage(HttpMethod.Get, $"/courses/search?SearchTerm=test&providerId={provider.ProviderId}"); // Act var response = await HttpClient.SendAsync(request); // Assert var doc = await response.GetDocument(); using (new AssertionScope()) { doc.GetElementsByClassName("NotionalNVQLevelv2FilterOption").Length.Should().Be(3); doc.GetElementsByClassName("AwardingOrganisationFilterOption").Length.Should().Be(0); } response.StatusCode.Should().Be(HttpStatusCode.OK); }
private async Task ChooseQualification_SearchTermLengthInvalid_RendersError(string term) { // Arrange var provider = await TestData.CreateProvider(); var notionalNVQLevelv2Facets = new Dictionary <object, long?>(); var awardOrgCodeFacets = new Dictionary <object, long?> { { new Object(), 343 }, { new Object(), 3433 } }; dfc.SearchResult <Lars> res = new dfc.SearchResult <Lars> { Items = new ReadOnlyCollection <dfc.SearchResultItem <Lars> >(new List <dfc.SearchResultItem <Lars> >() { new dfc.SearchResultItem <Lars>() { Record = new Lars(), }, new dfc.SearchResultItem <Lars>() { Record = new Lars(), } }), TotalCount = 2, Facets = new Dictionary <string, IReadOnlyDictionary <object, long?> > { { "AwardOrgCode", awardOrgCodeFacets }, { "NotionalNVQLevelv2", notionalNVQLevelv2Facets } } }; LarsSearchClient.Setup(x => x.Search(It.IsAny <dfc.LarsSearchQuery>())).ReturnsAsync(res); LarsSearchSettings.Setup(x => x.Value).Returns(new Core.Configuration.LarsSearchSettings() { ItemsPerPage = 20 }); var request = new HttpRequestMessage(HttpMethod.Get, $"/courses/search?SearchTerm={term}&providerId={provider.ProviderId}"); // Act var response = await HttpClient.SendAsync(request); // Assert var doc = await response.GetDocument(); using (new AssertionScope()) { doc.GetElementByTestId("SearchErrorMessage").TextContent.Should().Be("Enter search criteria"); } response.StatusCode.Should().Be(HttpStatusCode.BadRequest); }
private async Task ChooseQualification_SearchReturnsNoResults_RendersNoResultsMessage() { // Arrange var provider = await TestData.CreateProvider(); var notionalNVQLevelv2Facets = new Dictionary <object, long?>(); var awardOrgCodeFacets = new Dictionary <object, long?>(); dfc.SearchResult <Lars> res = new dfc.SearchResult <Lars> { Items = new ReadOnlyCollection <dfc.SearchResultItem <Lars> >(new List <dfc.SearchResultItem <Lars> >() { }), TotalCount = 0, Facets = new Dictionary <string, IReadOnlyDictionary <object, long?> > { { "AwardOrgCode", awardOrgCodeFacets }, { "NotionalNVQLevelv2", notionalNVQLevelv2Facets } } }; LarsSearchClient.Setup(x => x.Search(It.IsAny <dfc.LarsSearchQuery>())).ReturnsAsync(res); LarsSearchSettings.Setup(x => x.Value).Returns(new Core.Configuration.LarsSearchSettings() { ItemsPerPage = 20 }); var request = new HttpRequestMessage(HttpMethod.Get, $"/courses/search?SearchTerm=test&providerId={provider.ProviderId}"); // Act var response = await HttpClient.SendAsync(request); // Assert var doc = await response.GetDocument(); using (new AssertionScope()) { doc.GetElementByTestId("NoResults").Should().NotBeNull(); } response.StatusCode.Should().Be(HttpStatusCode.OK); }
public Handler(JourneyInstanceProvider journeyInstanceProvider, ISearchClient <Lars> search, IOptions <LarsSearchSettings> larsSearchSettings) { _journeyInstanceProvider = journeyInstanceProvider; _searchClient = search; _larsSearchSettings = larsSearchSettings?.Value ?? throw new ArgumentNullException(nameof(larsSearchSettings)); }