public static void Pager_HasNot_MorePages_Backward(string expected, int currentPageIndex) { // Arrange var pagedListState = new PagedListState(currentPageIndex, 10, 125, false); // Act var html = PageHelper.Pager(pagedListState, null, GetPageIndexLink).ToHtmlString(); // Assert Assert.DoesNotContain(expected, html, StringComparison.Ordinal); }
public static void PageSize_OutOfRange(string expected, int currentPageSize) { // Arrange var pagedListState = new PagedListState(0, currentPageSize, 125, false); // Act var html = PageHelper.PageSize(pagedListState, null, GetPageSizeLink).ToHtmlString(); // Assert Assert.Contains(expected, html, StringComparison.Ordinal); }
public static void PageSize() { // Arrange var state = new PagedListState(1, 10, 250, false); // Act var actual = state.PageSize; // Assert Assert.Equal(10, actual); }
public static void Pager_Inactive_PageIndex(string expected, int currentPageIndex) { // Arrange var pagedListState = new PagedListState(currentPageIndex, 10, 125, false); // Act var html = PageHelper.Pager(pagedListState, null, GetPageIndexLink).ToHtmlString(); // Assert Assert.Contains(expected, html, StringComparison.Ordinal); }
public static void PageCount(int expected, int totalItemsCount, bool hasMore) { // Arrange var state = new PagedListState(0, 10, totalItemsCount, hasMore); // Act var actual = state.PageCount; // Assert Assert.Equal(expected, actual); }
public static void TotalItemCount() { // Arrange var state = new PagedListState(0, 10, 250, false); // Act var actual = state.TotalItemCount; // Assert Assert.Equal(250, actual); }
public static void Constructor_Default_Settings() { // Arrange var state = new PagedListState(0, 10, 250, true); // Act var settings = state.Settings; // Assert Assert.Same(PagingSettings.Default, settings); }
public static void IsLastPage(bool expected, int pageIndex) { // Arrange var state = new PagedListState(pageIndex, 10, 250, false); // Act var actual = state.IsLastPage; // Assert Assert.Equal(expected, actual); }
public static void HasNextPage(bool expected, int pageIndex, int totalItemsCount) { // Arrange var state = new PagedListState(pageIndex, 10, totalItemsCount, false); // Act var actual = state.HasNextPage; // Assert Assert.Equal(expected, actual); }
public static void Pager_HasNot_Previous(string expected, int currentPageIndex) { // Arrange var pagedListState = new PagedListState(currentPageIndex, 10, 125, false); // Act var html = PageHelper.Pager(pagedListState, null, GetPageIndexLink).ToHtmlString(); // Assert Assert.DoesNotContain(Properties.Resources.PreviousPage + expected, html, StringComparison.Ordinal); }
public static void HasMore() { // Arrange var state = new PagedListState(1, 10, 250, false); // Act var actual = state.HasMore; // Assert Assert.Equal(false, actual); }
public static void Pager_Has_Previous(string expected, int currentPageIndex) { // Arrange var pagedListState = new PagedListState(currentPageIndex, 10, 125, false); // Act var html = PageHelper.Pager(pagedListState, null, GetPageIndexLink).ToHtmlString(); // Assert Assert.Contains(String.Format(CultureInfo.CurrentUICulture, expected, Properties.Resources.PreviousPageTitle, Properties.Resources.PreviousPage), html, StringComparison.Ordinal); }
public static void Pager_HasMore_NextPages(string expected, int currentPageIndex) { // Arrange var pagedListState = new PagedListState(currentPageIndex, 10, 125, false); // Act var html = PageHelper.Pager(pagedListState, null, GetPageIndexLink).ToHtmlString(); // Assert Assert.Contains(String.Format(CultureInfo.CurrentUICulture, expected, String.Format(CultureInfo.InvariantCulture, Properties.Resources.NextNPagesTitle, pagedListState.Settings.PageCount), Properties.Resources.NextNPages), html, StringComparison.Ordinal); }
public PagedList(IQueryable <T> source, int index, int pageSize, bool hasMore) { if (source == null) { source = new List <T>().AsQueryable(); } State = new PagedListState(index, pageSize, source.Count(), hasMore); if (State.TotalItemCount > 0) { AddRange(source.Skip(State.PageIndex * State.PageSize).Take(State.PageSize).ToList()); } }
public PagedOffsetList(IQueryable <T> source, int pageIndex, int pageSize, int pageIndexOffset, bool hasMore) { if (pageIndexOffset > pageIndex) { throw new ArgumentOutOfRangeException("pageIndexOffset", "PageIndexOffest can not be greater than PageIndex"); } if (source == null) { source = new List <T>().AsQueryable(); } State = new PagedListState(pageIndex, pageSize, source.Count() + (pageIndexOffset * pageSize), hasMore); if (State.TotalItemCount > 0) { AddRange(source.Skip((pageIndex - pageIndexOffset) * pageSize).Take(pageSize).ToList()); } }
public static void Pager_AlwaysVisible(string expected, bool alwaysVisible) { // Arrange var pagedListState = new PagedListState(0, 10, 5, false) { Settings = new PagingSettings() { AlwaysVisible = alwaysVisible, PageCount = 5 } }; // Act var html = PageHelper.Pager(pagedListState, null, GetPageIndexLink).ToHtmlString(); // Assert Assert.Equal(expected, html); }
public static void PageSize_AlwaysVisible(string expected, bool alwaysVisible, int pageSize) { // Arrange var pagedListState = new PagedListState(0, 10, pageSize, false) { Settings = new PagingSettings() { AlwaysVisible = alwaysVisible, PageCount = 5, DefaultItemsPerPage = 10, PageSizes = new int[] { 10 } } }; // Act var html = PageHelper.PageSize(pagedListState, null, GetPageSizeLink).ToHtmlString(); // Assert Assert.Equal(expected, html); }