public void FaqsPageViewModel_search_for_word_returns_expected_two_faqs_in_weight_order_descending() { // Given var faqViewModels = allFaqs.Select(f => new SearchableFaq(f)).ToList(); var expectedFirstFaq = new SearchableFaqViewModel( DlsSubApplication.TrackingSystem, faqViewModels.ElementAt(4) ); var expectedSecondFaq = new SearchableFaqViewModel( DlsSubApplication.TrackingSystem, faqViewModels.ElementAt(1) ); // When var result = new FaqsPageViewModel( DlsSubApplication.TrackingSystem, SupportPage.HelpDocumentation, "currentSystemBaseUrl", faqViewModels, 1, "word" ); // Then var faqs = result.Faqs.ToList(); faqs.Should().HaveCount(2); faqs.ElementAt(0).Should().BeEquivalentTo(expectedFirstFaq); faqs.ElementAt(1).Should().BeEquivalentTo(expectedSecondFaq); }
public void FaqsPageViewModel_search_for_help_returns_expected_six_faqs() { // Given var faqViewModels = allFaqs.Select(f => new SearchableFaq(f)).ToList(); var expectedFaqIds = new List <int> { 1, 2, 5, 7, 9, 10 }; // When var result = new FaqsPageViewModel( DlsSubApplication.TrackingSystem, SupportPage.HelpDocumentation, "currentSystemBaseUrl", faqViewModels, 1, "help" ); // Then var faqs = result.Faqs.ToList(); faqs.Should().HaveCount(6); faqs.Should().OnlyHaveUniqueItems() .And.OnlyContain(f => expectedFaqIds.Contains(f.Faq.FaqId)); }
public IActionResult Index() { var faqs = faqsService.GetAllFaqs() .OrderByDescending(f => f.CreatedDate) .Select(f => new SearchableFaq(f)) .Take(10); var model = new FaqsPageViewModel(faqs); return(View("SuperAdminFaqs", model)); }
public void FaqsPageViewModel_search_for_document_page_one_returns_expected_first_ten_faqs() { // Given var faqViewModels = allFaqs.Select(f => new SearchableFaq(f)); // When var result = new FaqsPageViewModel( DlsSubApplication.TrackingSystem, SupportPage.HelpDocumentation, "currentSystemBaseUrl", faqViewModels, 1, "document" ); // Then var faqs = result.Faqs.ToList(); faqs.Should().HaveCount(10); }
public IActionResult Index( DlsSubApplication dlsSubApplication, int page = 1, string?searchString = null ) { var faqs = faqsService.GetPublishedFaqsForTargetGroup(dlsSubApplication.FaqTargetGroupId !.Value) .Select(f => new SearchableFaq(f)); var model = new FaqsPageViewModel( dlsSubApplication, SupportPage.Faqs, configuration.GetCurrentSystemBaseUrl(), faqs, page, searchString ); return(View("Faqs", model)); }
public void FaqsPageViewModel_search_for_document_page_two_returns_expected_one_faq() { // Given var faqViewModels = allFaqs.Select(f => new SearchableFaq(f)).ToList(); var expectedFaq = new SearchableFaqViewModel(DlsSubApplication.TrackingSystem, faqViewModels.ElementAt(8)); // When var result = new FaqsPageViewModel( DlsSubApplication.TrackingSystem, SupportPage.HelpDocumentation, "currentSystemBaseUrl", faqViewModels, 2, "document" ); // Then var faqs = result.Faqs.ToList(); faqs.Should().HaveCount(1); faqs.First().Should().BeEquivalentTo(expectedFaq); }
public IActionResult Index( DlsSubApplication dlsSubApplication, int page = 1, string?searchString = null ) { // A MatchCutOffScore of 65 is being used here rather than the default 80. // The default Fuzzy Search configuration does not reliably bring back expected FAQs. // Through trial and error a combination of the PartialTokenSetScorer ratio scorer // and this cut off score bring back reliable results comparable to the JS search. const int matchCutOffScore = 65; const string faqSortBy = "Weighting,FaqId"; var faqs = faqsService.GetPublishedFaqsForTargetGroup(dlsSubApplication.FaqTargetGroupId !.Value) .Select(f => new SearchableFaq(f)); var searchSortPaginationOptions = new SearchSortFilterAndPaginateOptions( new SearchOptions(searchString, matchCutOffScore, true), new SortOptions(faqSortBy, GenericSortingHelper.Descending), null, new PaginationOptions(page) ); var result = searchSortFilterPaginateService.SearchFilterSortAndPaginate( faqs, searchSortPaginationOptions ); var model = new FaqsPageViewModel( dlsSubApplication, SupportPage.Faqs, configuration.GetCurrentSystemBaseUrl(), result ); return(View("Faqs", model)); }