Example #1
0
        public void RespectsOrderedQueryable()
        {
            var obj = new NotOrderedQueryable <Person>(Get.People(100).AsQueryable())
                      .OrderByDescending(p => p.Identifier);
            var result = (Query.ApplyPagination(obj, DefaultContext, new PersonResource())
                          as IEnumerable <Person>)?.ToList();

            Assert.Equal("99", result?.FirstOrDefault()?.Identifier);
            Assert.Equal("98", result?.Skip(1).FirstOrDefault()?.Identifier);
        }
        public void RespectsOrderedQueryable()
        {
            var obj = new NotOrderedQueryable<Person>(Get.People(100).AsQueryable())
                .OrderByDescending(p => p.Identifier);
            var result = (Query.ApplyPagination(obj, DefaultContext, new PersonResource())
                as IEnumerable<Person>)?.ToList();

            Assert.Equal("99", result?.FirstOrDefault()?.Identifier);
            Assert.Equal("98", result?.Skip(1).FirstOrDefault()?.Identifier);
        }
Example #3
0
        public void ThrowsWhenNoId()
        {
            var people = new NotOrderedQueryable <PersonWithNoId>(new[]
            {
                new PersonWithNoId(),
                new PersonWithNoId(),
                new PersonWithNoId(),
                new PersonWithNoId()
            }.AsQueryable());
            var target = new PaginationInterpreter(DefaultContext, new PersonResource());

            Assert.Throws <JsonApiException>(() => target.Apply(people));
        }
        public void ThrowsWhenNoId()
        {
            var people = new NotOrderedQueryable<PersonWithNoId>(new[]
            {
                new PersonWithNoId(),
                new PersonWithNoId(),
                new PersonWithNoId(),
                new PersonWithNoId()
            }.AsQueryable());
            var target = new PaginationInterpreter(DefaultContext, new PersonResource());

            Assert.Throws<JsonApiException>(() => target.Apply(people));
        }