示例#1
0
        public void CanGetPostsByCategoryArchive()
        {
            UnitTestHelper.SetupBlog();
            var repository = new DatabaseObjectProvider();
            ICollection<ArchiveCount> counts = repository.GetPostCountsByCategory();
            Assert.AreEqual(0, counts.Count);

            Entry entry = UnitTestHelper.CreateEntryInstanceForSyndication("me", "title", "body");
            int categoryId = UnitTestHelper.CreateCategory(Config.CurrentBlog.Id, "Test");
            int entryId = UnitTestHelper.Create(entry);
            repository.SetEntryCategoryList(entryId, new[] { categoryId });
            counts = repository.GetPostCountsByCategory();
            Assert.AreEqual(1, counts.Count);

            foreach (ArchiveCount archiveCount in counts)
            {
                Assert.AreEqual(1, archiveCount.Count, "Expected one post in the archive.");
                return;
            }
        }