public void PagingOptions_Apply_Will_Set_TotalItems_With_Multiple_Sort()
        {
            var contacts = new List <Contact>();

            for (int i = 1; i <= 5; i++)
            {
                contacts.Add(new Contact {
                    Name = "Test User " + i
                });
            }

            const int resultingPage = 2;
            const int pageSize      = 2;
            var       qo            = new PagingOptions <Contact>(resultingPage, pageSize, "Name", isDescending: true);

            qo.ThenSortBy("ContactTypeId");
            qo.Apply(contacts.AsQueryable());
            qo.TotalItems.ShouldBe(5);

            var qo2 = new PagingOptions <Contact, string>(resultingPage, pageSize, x => x.Name, isDescending: true);

            qo2.ThenSortBy(x => x.ContactTypeId);
            qo2.Apply(contacts.AsQueryable());
            qo2.TotalItems.ShouldBe(5);
        }
        public void PagingOptions_Apply_Return_Requested_Page_With_Multiple_Sort()
        {
            var contacts = new List<Contact>();
            for (int i = 1; i <= 5; i++)
            {
                contacts.Add(new Contact { Name = "Test User " + (i % 2), ContactTypeId = i});
            }

            const int resultingPage = 2;
            const int pageSize = 2;

            var qo = new PagingOptions<Contact>(resultingPage, pageSize, "Name", isDescending: true);
            qo.ThenSortBy("ContactTypeId", isDescending: true);

            IQueryable<Contact> queryable = qo.Apply(contacts.AsQueryable());
            queryable.Count().ShouldEqual(2);

            var contact = queryable.First();
            contact.Name.ShouldEqual("Test User 1");
            contact.ContactTypeId.ShouldEqual(1);

            var qo2 = new PagingOptions<Contact, string>(resultingPage, pageSize, x => x.Name, isDescending: true);
            qo2.ThenSortBy(x => x.ContactTypeId, isDescending: true);

            queryable = qo2.Apply(contacts.AsQueryable());
            queryable.Count().ShouldEqual(2);

            contact = queryable.First();
            contact.Name.ShouldEqual("Test User 1");
            contact.ContactTypeId.ShouldEqual(1);
        }
        public void PagingOptions_Apply_Return_Requested_Page_With_Multiple_Sort()
        {
            var contacts = new List <Contact>();

            for (int i = 1; i <= 5; i++)
            {
                contacts.Add(new Contact {
                    Name = "Test User " + (i % 2), ContactTypeId = i
                });
            }

            const int resultingPage = 2;
            const int pageSize      = 2;

            var qo = new PagingOptions <Contact>(resultingPage, pageSize, "Name", isDescending: true);

            qo.ThenSortBy("ContactTypeId", isDescending: true);

            IQueryable <Contact> queryable = qo.Apply(contacts.AsQueryable());

            queryable.Count().ShouldBe(2);

            var contact = queryable.First();

            contact.Name.ShouldBe("Test User 1");
            contact.ContactTypeId.ShouldBe(1);

            var qo2 = new PagingOptions <Contact, string>(resultingPage, pageSize, x => x.Name, isDescending: true);

            qo2.ThenSortBy(x => x.ContactTypeId, isDescending: true);

            queryable = qo2.Apply(contacts.AsQueryable());
            queryable.Count().ShouldBe(2);

            contact = queryable.First();
            contact.Name.ShouldBe("Test User 1");
            contact.ContactTypeId.ShouldBe(1);
        }
        public void PagingOptions_Apply_Will_Set_TotalItems_With_Multiple_Sort()
        {
            var contacts = new List<Contact>();
            for (int i = 1; i <= 5; i++)
            {
                contacts.Add(new Contact { Name = "Test User " + i });
            }

            const int resultingPage = 2;
            const int pageSize = 2;
            var qo = new PagingOptions<Contact>(resultingPage, pageSize, "Name", isDescending: true);
            qo.ThenSortBy("ContactTypeId");
            qo.Apply(contacts.AsQueryable());
            qo.TotalItems.ShouldEqual(5);

            var qo2 = new PagingOptions<Contact, string>(resultingPage, pageSize, x => x.Name, isDescending: true);
            qo2.ThenSortBy(x => x.ContactTypeId);
            qo2.Apply(contacts.AsQueryable());
            qo2.TotalItems.ShouldEqual(5);
        }