コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        public static void PageSize()
        {
            // Arrange
            var state = new PagedListState(1, 10, 250, false);

            // Act
            var actual = state.PageSize;

            // Assert
            Assert.Equal(10, actual);
        }
コード例 #4
0
        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);
        }
コード例 #5
0
        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);
        }
コード例 #6
0
        public static void TotalItemCount()
        {
            // Arrange
            var state = new PagedListState(0, 10, 250, false);

            // Act
            var actual = state.TotalItemCount;

            // Assert
            Assert.Equal(250, actual);
        }
コード例 #7
0
        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);
        }
コード例 #8
0
        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);
        }
コード例 #9
0
        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);
        }
コード例 #10
0
        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);
        }
コード例 #11
0
        public static void HasMore()
        {
            // Arrange
            var state = new PagedListState(1, 10, 250, false);

            // Act
            var actual = state.HasMore;

            // Assert
            Assert.Equal(false, actual);
        }
コード例 #12
0
        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);
        }
コード例 #13
0
        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);
        }
コード例 #14
0
ファイル: PagedList.cs プロジェクト: kouweizhong/relib
        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());
            }
        }
コード例 #15
0
        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());
            }
        }
コード例 #16
0
        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);
        }
コード例 #17
0
        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);
        }