static void TestIQueryablePaginated(int page, int total = 5)
        {
            using (DatabaseContext db = new DatabaseContext())
            {
                var count = db.People.Count();
                Paginated <People> listOfQueryable0 = db.People
                                                      .OrderBy(x => x.Name)
                                                      .ToPaginated(page, total);

                Paginated <People> listOfQueryable1 = db.People
                                                      .OrderBy(x => x.Name)
                                                      .ToPaginated((page + 1), total);

                PaginatedMetaData am0 = listOfQueryable0.ToPaginatedMetaData();
                PaginatedMetaData am1 = listOfQueryable1.ToPaginatedMetaData();

                int[] ap0 = listOfQueryable0.Pages.ToArray();
                int[] ap1 = listOfQueryable1.Pages.ToArray();

                listOfQueryable0.SetPages(1);
                int[] ap3 = listOfQueryable0.Pages.ToArray();

                listOfQueryable1.SetPages(1);
                int[] ap4 = listOfQueryable1.Pages.ToArray();
            }
        }
Esempio n. 2
0
        public void TestPaginatedWithIQuerable()
        {
            int pageNumber = 1;
            int pageSize   = 2;

            Paginated <People> st = Database.People.ToPaginated(pageNumber, pageSize);


            PaginatedMetaData metaData = st.ToPaginatedMetaData();

            Assert.IsInstanceOfType(st, typeof(Paginated <People>));
            Assert.IsInstanceOfType(st, typeof(IPaginated));
            Assert.IsInstanceOfType(st, typeof(IPaginated <People>));
            Assert.IsInstanceOfType(st, typeof(IList));
            Assert.IsInstanceOfType(st, typeof(IList <People>));
            Assert.IsInstanceOfType(st, typeof(List <People>));
            Assert.IsInstanceOfType(st, typeof(PaginatedBase <People>));
            Assert.IsInstanceOfType(metaData, typeof(PaginatedMetaData));
            Assert.AreEqual(metaData.FirstItemOnPage, 1);
            Assert.IsTrue(metaData.HasNextPage);
            Assert.IsFalse(metaData.HasPreviousPage);
            Assert.IsTrue(metaData.IsFirstPage);
            Assert.IsFalse(metaData.IsLastPage);
            Assert.AreEqual(metaData.LastItemOnPage, 2);
            Assert.AreEqual(metaData.MaximumPageNumbersToDisplay, 8);
            Assert.AreEqual(metaData.PageCount, 5);
            Assert.AreEqual(metaData.Pages.Count, 5);
            Assert.AreEqual(metaData.PageNumber, 1);
            Assert.AreEqual(metaData.PageSize, 2);
            Assert.AreEqual(metaData.TotalItemCount, st.TotalItemCount);
        }