示例#1
0
        public void PageIndexTest()
        {
            var helper = new PagnationHelper <char>(new List <char> {
                'a', 'b', 'c', 'd',
                'e', 'f'
            }, 4);

            Assert.AreEqual(2, helper.PageCount);
            Assert.AreEqual(6, helper.ItemCount);

            Assert.AreEqual(4, helper.PageItemCount(0));  //should == 4
            Assert.AreEqual(2, helper.PageItemCount(1));  // last page - should == 2
            Assert.AreEqual(-1, helper.PageItemCount(2)); // should == -1 since the page is invalid

            // pageIndex takes an item index and returns the page that it belongs on
            Assert.AreEqual(1, helper.PageIndex(5));    //should == 1 (zero based index)
            Assert.AreEqual(0, helper.PageIndex(2));    //should == 0
            Assert.AreEqual(-1, helper.PageIndex(20));
            Assert.AreEqual(-1, helper.PageIndex(-10)); //should == -1}
        }
示例#2
0
 public void SetUp()
 {
     helper = new PagnationHelper <int>(collection, 10);
 }