コード例 #1
0
        public void Can_Get_Posts_By_Category_Id_Paged_And_It_Works_Correctly()
        {
            Initialize(true);

            using (var repository = new NHibernateBlogService())
            {
                var category = new Category() { Name = "Test" };

                for (int i = 0; i < 17; i++)
                {
                    var post = DummyLivePost();

                    post.Categories.Add(category);

                    repository.Save(post);
                }

                repository.Save(category);

                repository.CommitChanges();

                Assert.AreEqual(5, repository.GetPostsByCategoryPaged(category.Id, 5, 1).Count);
                Assert.AreEqual(5, repository.GetPostsByCategoryPaged(category.Id, 5, 2).Count);
                Assert.AreEqual(5, repository.GetPostsByCategoryPaged(category.Id, 5, 3).Count);
                Assert.AreEqual(2, repository.GetPostsByCategoryPaged(category.Id, 5, 4).Count);
            }
        }