private static void AssertPagedCollection <TItem>(IPagedCollectionTester <TItem> pagedCollectionTester, int expectedPageCount, int itemsCountOnLastPage, int pageSize, int total) { //Create entries for (int i = 0; i < total; i++) { pagedCollectionTester.Create(i); } int pageCount = 0; int totalSeen = 0; for (int pageIndex = 0; pageIndex < expectedPageCount; pageIndex++) { var items = pagedCollectionTester.GetPagedItems(pageIndex, pageSize); Assert.AreEqual(total, items.MaxItems, "The paged collection got the max items wrong)"); if (pageIndex < expectedPageCount - 1) { //Expect to see pageSize number of entries. Assert.AreEqual(pageSize, pagedCollectionTester.GetCount(items), "The page at index " + pageIndex + "Did not have the correct number of records."); } else { Assert.AreEqual(itemsCountOnLastPage, pagedCollectionTester.GetCount(items), "The last page did not have the correct number of records."); } totalSeen += pagedCollectionTester.GetCount(items); pageCount++; } Assert.AreEqual(expectedPageCount, pageCount, "We did not see the expected number of pages."); Assert.AreEqual(total, totalSeen, "We did not see the expected number of records."); }
private static void AssertPagedCollection(IPagedCollectionTester pagedCollectionTester, int expectedPageCount, int itemsCountOnLastPage, int pageSize, int total) { //Create entries for(int i = 0; i < total; i++) { pagedCollectionTester.Create(i); } int pageCount = 0; int totalSeen = 0; for (int pageIndex = 0; pageIndex < expectedPageCount; pageIndex++) { IPagedCollection items = pagedCollectionTester.GetPagedItems(pageIndex, pageSize); Assert.AreEqual(total, items.MaxItems, "The paged collection got the max items wrong)"); if (pageIndex < expectedPageCount - 1) { //Expect to see pageSize number of entries. Assert.AreEqual(pageSize, pagedCollectionTester.GetCount(items), "The page at index " + pageIndex + "Did not have the correct number of records."); } else { Assert.AreEqual(itemsCountOnLastPage, pagedCollectionTester.GetCount(items), "The last page did not have the correct number of records."); } totalSeen += pagedCollectionTester.GetCount(items); pageCount++; } Assert.AreEqual(expectedPageCount, pageCount, "We did not see the expected number of pages."); Assert.AreEqual(total, totalSeen, "We did not see the expected number of records."); }