public void CountByCategory_Should_Return_Correct_Result() { using (BeginTransaction()) { GenerateStories(true, false, true); _database.SubmitChanges(); var categoryName = CreateNewCategory().Name; var id = _database.CategoryDataSource.First(c => c.Name == categoryName).Id; var count = _storyRepository.CountByCategory(id); Assert.Equal(10, count); } }
public void CountByCategory_Should_Return_Correct_Result() { var story1 = CreateStory(); var story2 = CreateStory(); var story3 = CreateStory(); var rnd = new Random(); Stories.AddRange(new[] { story1 as Story, story2 as Story, story3 as Story }); Stories.ForEach(s => s.Publish(SystemTime.Now().AddDays(-rnd.Next(1, 5)), rnd.Next(1, 10))); var result = _storyRepository.CountByCategory(Stories[0].CategoryId); Assert.Equal(1, result); }
private void AddCategoryPagesInRegularSiteMap(HttpContextBase context, bool forMobile, XContainer target, IFormattable currentDate) { int rowPerPage = Settings.HtmlStoryPerPage; string rootUrl = Settings.RootUrl; foreach (ICategory category in CategoryRepository.FindAll()) { int categoryPageCount = PageCalculator.TotalPage(StoryRepository.CountByCategory(category.Id), rowPerPage); int categoryPageCounter = 1; while (categoryPageCounter <= categoryPageCount) { target.Add(CreateEntry(context, rootUrl, "Story", "Category", new { name = category.UniqueName, page = categoryPageCounter }, currentDate, SiteMapChangeFrequency.Daily, ((categoryPageCounter <= CriticalPriorityPageLimit) ? SiteMapUpdatePriority.High : SiteMapUpdatePriority.Normal), forMobile)); categoryPageCounter += 1; } } }