Esempio n. 1
0
        public void SkipExceededValidTake()
        {
            int skip = 4, take = 2;
            var target = new BlogPostsPagingSpecification(skip, take);

            var result = GetTestBlogPostCollection()
                         .AsQueryable()
                         .Where(target.Criteria)
                         .OrderByDescending(target.OrderByDescending)
                         .Skip(target.Skip)
                         .Take(target.Take)
                         .ToList();

            Assert.Empty(result);
        }
Esempio n. 2
0
        public void ValidSkipTakeExceeded()
        {
            int skip = 2, take = 4;
            var target = new BlogPostsPagingSpecification(skip, take);

            var result = GetTestBlogPostCollection()
                         .AsQueryable()
                         .Where(target.Criteria)
                         .OrderByDescending(target.OrderByDescending)
                         .Skip(target.Skip)
                         .Take(target.Take)
                         .ToList();

            Assert.Equal(2, result.Count);
            Assert.Equal(102, result.First().Id);
            Assert.Equal(101, result.Last().Id);
        }
Esempio n. 3
0
        public void ValidSkipTake()
        {
            int skip = 1, take = 2;

            var target = new BlogPostsPagingSpecification(skip, take);

            Assert.True(target.IsPagingEnabled);
            Assert.Null(target.OrderBy);
            Assert.NotNull(target.OrderByDescending);
            var result = GetTestBlogPostCollection()
                         .AsQueryable()
                         .Where(target.Criteria)
                         .OrderByDescending(target.OrderByDescending)
                         .Skip(target.Skip)
                         .Take(target.Take)
                         .ToList();

            Assert.Equal(take, result.Count);
            Assert.Equal(103, result.First().Id);
            Assert.Equal(102, result.Last().Id);
            Assert.True(result.First().CreatedOn > result.Last().CreatedOn);
        }