public void TestFaqs() { var categories = _faqsQuery.GetCategories(); var subcategory1 = categories.Single(c => c.Name == "Candidates").Subcategories.Single(s => s.Name == "About LinkMe"); var subcategory2 = categories.Single(c => c.Name == "Employers").Subcategories.Single(s => s.Name == "Folders and notes"); // GetFaqs() var faqs = _faqsQuery.GetFaqs(); Assert.AreEqual(173, faqs.Count); var faq1 = (from f in faqs where f.Title == Title1 select f).Single(); var faq2 = (from f in faqs where f.Title == Title2 select f).Single(); AssertFaq(Title1, Text1, subcategory1, faq1); AssertFaq(Title2, Text2, subcategory2, faq2); // GetFaq(id) AssertFaq(Title1, Text1, subcategory1, _faqsQuery.GetFaq(faq1.Id)); AssertFaq(Title2, Text2, subcategory2, _faqsQuery.GetFaq(faq2.Id)); Assert.IsNull(_faqsQuery.GetFaq(Guid.NewGuid())); // GetFaqs(ids) faqs = _faqsQuery.GetFaqs(new[] { faq1.Id }); Assert.AreEqual(1, faqs.Count); AssertFaq(Title1, Text1, subcategory1, faqs[0]); faqs = _faqsQuery.GetFaqs(new[] { faq1.Id, faq2.Id }); Assert.AreEqual(2, faqs.Count); AssertFaq(Title1, Text1, subcategory1, (from f in faqs where f.Id == faq1.Id select f).Single()); AssertFaq(Title2, Text2, subcategory2, (from f in faqs where f.Id == faq2.Id select f).Single()); Assert.AreEqual(0, _faqsQuery.GetFaqs(new[] { Guid.NewGuid() }).Count); }
private FaqListModel GetFaqList(FaqSearchCriteria criteria, IList <Category> categories) { var execution = _executeFaqSearchCommand.Search(criteria, null); return(new FaqListModel { Categories = categories, Criteria = execution.Criteria, UserType = GetUserType(categories, criteria.CategoryId), IsSingleFaq = false, Results = new FaqListResultsModel { TotalFaqs = execution.Results.ResourceIds.Count, FaqIds = execution.Results.ResourceIds, Faqs = _faqsQuery.GetFaqs(execution.Results.ResourceIds).ToDictionary(f => f.Id, f => f), }, }); }
public void TestFaqs() { var categories = _faqsQuery.GetCategories(); var candidatesCategory = categories.First(c => c.Name == "Candidates").Subcategories[0]; var employersSubcategory = categories.First(c => c.Name == "Employers").Subcategories[0]; var securitySubcategory = categories.First(c => c.Name == "Online Security").Subcategories[0]; // Top 5 FAQs. var membersFaqs = (from f in _faqsQuery.GetFaqs() where f.SubcategoryId == candidatesCategory.Id select f).Take(5).ToList(); var employersFaqs = (from f in _faqsQuery.GetFaqs() where f.SubcategoryId == employersSubcategory.Id select f).Take(5).ToList(); // Make sure they are helpful. for (var index = 0; index < membersFaqs.Count; ++index) { for (var count = 0; count < 10 - index; ++count) { _faqsCommand.MarkHelpful(membersFaqs[index].Id); } } for (var index = 0; index < employersFaqs.Count; ++index) { for (var count = 0; count < 10 - index; ++count) { _faqsCommand.MarkHelpful(employersFaqs[index].Id); } } // Get the page. Get(_faqsUrl); AssertBreadcrumbs(); // Looking for ... AssertLink("//a[@class='button forcandidates']", GetSubcategoryUrl(candidatesCategory), ""); AssertLink("//a[@class='button foremployers']", GetSubcategoryUrl(employersSubcategory), ""); AssertLink("//a[@class='button onlinesecurity']", GetSubcategoryUrl(securitySubcategory), ""); // Members. var nodes = Browser.CurrentHtml.DocumentNode.SelectNodes("//div[@id='top5c']//a"); Assert.AreEqual(membersFaqs.Count, nodes.Count); for (var index = 0; index < nodes.Count; ++index) { Assert.IsTrue(string.Equals(GetFaqUrl(membersFaqs[index], null, categories).PathAndQuery, nodes[index].Attributes["href"].Value, StringComparison.CurrentCultureIgnoreCase)); Assert.AreEqual(membersFaqs[index].Title, nodes[index].InnerText); } // Employers. nodes = Browser.CurrentHtml.DocumentNode.SelectNodes("//div[@id='top5e']//a"); Assert.AreEqual(employersFaqs.Count, nodes.Count); for (var index = 0; index < nodes.Count; ++index) { Assert.IsTrue(string.Equals(GetFaqUrl(employersFaqs[index], null, categories).PathAndQuery, nodes[index].Attributes["href"].Value, StringComparison.CurrentCultureIgnoreCase)); Assert.AreEqual(employersFaqs[index].Title, nodes[index].InnerText); } }