public void PagesGetCorrectItems() { var comments = new Comment[12]; for(int i = 0; i < 12; i++) { comments[i] = new Comment() {Text = "This is comment " + i.ToString("D2"), Author = "Chuck Finley"}; } var postId = CreatePost("Comments Test", "Comments Test", DateTime.Now, comments); var repo = new CommentRepository(new BlogContext()); int virtualItemCount; int pageSize = 5; var criteria = new CommentCriteria() { PostId = postId }; var order = Order<Comment>.By(c => c.Text); var page0 = repo.Retrieve(pageSize, 0, out virtualItemCount, criteria, order).ToList(); page0.Count().Should().Be(5); page0.First().Text.Should().EndWith("00"); page0.Last().Text.Should().EndWith("04"); var page1 = repo.Retrieve(pageSize, 1, out virtualItemCount, criteria, order).ToList(); page1.Count().Should().Be(5); page1.First().Text.Should().EndWith("05"); page1.Last().Text.Should().EndWith("09"); var page2 = repo.Retrieve(pageSize, 2, out virtualItemCount, criteria, order).ToList(); page2.Count().Should().Be(2); page2.First().Text.Should().EndWith("10"); page2.Last().Text.Should().EndWith("11"); }
public IEnumerable <Comment> Retrieve(int pageSize, int pageIndex, out int virtualCount, CommentCriteria criteria = null, params Order <Comment>[] orderBy) { return(_pagedRepository.Retrieve(pageSize, pageIndex, out virtualCount, criteria, orderBy)); }
public void VirtualCountEqualsTotalItems() { var comments = new Comment[12]; for (int i = 0; i < 12; i++) { comments[i] = new Comment() { Text = "This is comment " + i.ToString("D2"), Author = "Chuck Finley" }; } var postId = CreatePost("Comments Test", "Comments Test", DateTime.Now, comments); var repo = new CommentRepository(new BlogContext()); int virtualItemCount; int pageSize = 5; var criteria = new CommentCriteria() {PostId = postId}; var order = Order<Comment>.By(c => c.Text); var page0 = repo.Retrieve(pageSize, 0, out virtualItemCount, criteria, order).ToList(); virtualItemCount.Should().Be(12); var page1 = repo.Retrieve(pageSize, 1, out virtualItemCount, criteria, order).ToList(); virtualItemCount.Should().Be(12); var page2 = repo.Retrieve(pageSize, 2, out virtualItemCount, criteria, order).ToList(); virtualItemCount.Should().Be(12); }