本文整理汇总了C#中PagedList.Paginate方法的典型用法代码示例。如果您正苦于以下问题:C# PagedList.Paginate方法的具体用法?C# PagedList.Paginate怎么用?C# PagedList.Paginate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PagedList
的用法示例。
在下文中一共展示了PagedList.Paginate方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ShouldAcceptNullList
public void ShouldAcceptNullList()
{
// arrange
PagedList<int> pages = new PagedList<int>(null, null);
// act
pages.Paginate(null, 0, 3);
// assert
Assert.AreEqual(0, pages.Items.Count);
Assert.AreEqual(0, pages.PageCount);
}
示例2: ShouldReturnSinglePage
public void ShouldReturnSinglePage()
{
// arrange
List<int> list = new List<int> {
0, 1, 2, 3, 4, 5, 6, 7, 8, 9
};
PagedList<int> pages = new PagedList<int>(null, null);
// act
pages.Paginate(list, 0, 10);
IEnumerable<PageLink> links = pages.GetPageLinks(3);
Assert.AreEqual(1, links.Count());
PageLink link = links.First();
Assert.AreEqual(0, link.Index);
Assert.IsTrue(link.IsFirst);
Assert.IsTrue(link.IsLast);
Assert.IsTrue(link.IsSelected);
}
示例3: ShouldCalculateSinglePageItemsCorrectly
public void ShouldCalculateSinglePageItemsCorrectly()
{
// arrange
List<int> list = new List<int> {
0, 1, 2, 3, 4, 5, 6, 7, 8, 9
};
PagedList<int> pages = new PagedList<int>(null, null);
// act
pages.Paginate(list, 0, 10);
// assert
Assert.AreEqual(10, pages.Items.Count);
Assert.AreEqual(1, pages.PageCount);
for (int i = 0; i < 10; i++)
{
Assert.AreEqual(list[i], pages.Items[i]);
}
}
示例4: ShouldThrowIfNegativePageIndexGiven
public void ShouldThrowIfNegativePageIndexGiven()
{
// arrange
PagedList<int> pages = new PagedList<int>(null, null);
// act
try
{
pages.Paginate(null, -1, 3);
}
catch (ArgumentOutOfRangeException)
{
// expected
return;
}
Assert.Fail("Should throw if negative pageIndex specified");
}
示例5: ShouldThrowIfPageSizeLessThan1
public void ShouldThrowIfPageSizeLessThan1()
{
// arrange
PagedList<int> pages = new PagedList<int>(null, null);
// act
try
{
pages.Paginate(null, 0, 0);
}
catch (ArgumentOutOfRangeException)
{
// expected
return;
}
Assert.Fail("Should throw if pageSize < 1");
}
示例6: ShouldThrowIfPageIndexGreaterThanPageCountGiven
public void ShouldThrowIfPageIndexGreaterThanPageCountGiven()
{
// arrange
List<int> list = new List<int> {
0, 1, 2, 3, 4, 5, 6, 7, 8, 9
};
PagedList<int> pages = new PagedList<int>(null, null);
// act
try
{
pages.Paginate(list, 4, 3);
}
catch (ArgumentOutOfRangeException)
{
// expected
return;
}
Assert.Fail("Should throw if negative pageIndex specified");
}
示例7: ShouldThrowIfNoHtmlGeneratorWhenGettingPageLinksHtml
public void ShouldThrowIfNoHtmlGeneratorWhenGettingPageLinksHtml()
{
// arrange
List<int> list = new List<int> {
0, 1, 2, 3, 4, 5, 6, 7, 8, 9
};
PagedList<int> pages = new PagedList<int>(null, null);
// act
try
{
pages.Paginate(list, 0, 3);
pages.GetPageLinksHtml(3, x => {return "";});
}
catch (InvalidOperationException)
{
// expected
return;
}
Assert.Fail("Should throw if no html generator specified");
}
示例8: ShouldThrowIfNoAlgorithmWhenGettingPageLinks
public void ShouldThrowIfNoAlgorithmWhenGettingPageLinks()
{
// arrange
List<int> list = new List<int> {
0, 1, 2, 3, 4, 5, 6, 7, 8, 9
};
PagedList<int> pages = new PagedList<int>(null, null);
// act
try
{
pages.Paginate(list, 0, 3);
pages.GetPageLinks(3);
}
catch (InvalidOperationException)
{
// expected
return;
}
Assert.Fail("Should throw if no algorithm specified");
}