예제 #1
0
        public ActionResult Faqs()
        {
            var categories = _faqsQuery.GetCategories();

            return(View(new FaqsModel
            {
                Categories = _faqsQuery.GetCategories(),
                TopCandidateFaqs = _faqsQuery.GetHelpfulFaqs(categories.Single(c => c.Name == CandidatesCategory).Id, TopFaqsCount),
                TopEmployerFaqs = _faqsQuery.GetHelpfulFaqs(categories.Single(c => c.Name == EmployersCategory).Id, TopFaqsCount),
                CandidatesSubcategory = categories.Single(c => c.Name == CandidatesCategory).Subcategories[0],
                EmployersSubcategory = categories.Single(c => c.Name == EmployersCategory).Subcategories[0],
                SecuritySubcategory = categories.Single(c => c.Name == SecurityCategory).Subcategories[0],
            }));
        }
예제 #2
0
파일: FaqsTests.cs 프로젝트: formist/LinkMe
        public void TestHelpfulFaqs()
        {
            var categories = _faqsQuery.GetCategories();
            var faqs       = _faqsQuery.GetFaqs();

            var category1 = categories.Single(c => c.Name == "Candidates");
            var faq1      = (from f in faqs where f.Title == Title1 select f).Single();

            // These titles all belong to the same category.

            var category2 = categories.Single(c => c.Name == "Employers");
            var faq2      = (from f in faqs where f.Title == Title2 select f).Single();
            var faq3      = (from f in faqs where f.Title == Title3 select f).Single();
            var faq4      = (from f in faqs where f.Title == Title4 select f).Single();

            MarkHelpful(faq1.Id);

            MarkHelpful(faq2.Id);
            MarkHelpful(faq2.Id);
            MarkNotHelpful(faq2.Id);
            MarkHelpful(faq2.Id);

            MarkHelpful(faq3.Id);
            MarkHelpful(faq3.Id);
            MarkHelpful(faq3.Id);

            MarkHelpful(faq4.Id);

            faqs = _faqsQuery.GetHelpfulFaqs(category1.Id, 1);
            Assert.AreEqual(1, faqs.Count);
            Assert.AreEqual(faq1.Id, faqs[0].Id);

            faqs = _faqsQuery.GetHelpfulFaqs(category2.Id, 3);
            Assert.AreEqual(3, faqs.Count);
            Assert.AreEqual(faq3.Id, faqs[0].Id);
            Assert.AreEqual(faq2.Id, faqs[1].Id);
            Assert.AreEqual(faq4.Id, faqs[2].Id);

            faqs = _faqsQuery.GetHelpfulFaqs(category2.Id, 2);
            Assert.AreEqual(2, faqs.Count);
            Assert.AreEqual(faq3.Id, faqs[0].Id);
            Assert.AreEqual(faq2.Id, faqs[1].Id);

            faqs = _faqsQuery.GetHelpfulFaqs(category2.Id, 1);
            Assert.AreEqual(1, faqs.Count);
            Assert.AreEqual(faq3.Id, faqs[0].Id);
        }