BuildPageLinks() public method

public BuildPageLinks ( ) : void
return void
        public void BuildPageLinks_Can_Truncate_Left_And_Right_When_Current_Page_Is_Around_The_Middle_Of_Possible_Pages()
        {
            var mockPagedResult = new Mock<PagedResultBase>();
            mockPagedResult.SetupGet(c => c.PageNumber).Returns(9).Verifiable();
            mockPagedResult.SetupGet(c => c.Pages).Returns(20).Verifiable();
            mockPagedResult.SetupGet(c => c.Window).Returns(4).Verifiable();

            PagedResultBase pagedResult = mockPagedResult.Object;

            PaginationBuilder builder = new DefaultPaginationBuilder(pagedResult,
                                                                     (itemPerPage, index) =>
                                                                     string.Format("/Controller/Action/{0}/{1}",
                                                                                   itemPerPage,
                                                                                   index));
            builder.BuildPageLinks();

            var gapCount = builder.Pagination.Count(c => c is Gap);

            Assert.That(gapCount, Is.EqualTo(2));

            mockPagedResult.Verify();
        }
        public void BuildPageLinks_Can_Truncate_Right_When_Pages_Is_Greater_Than_Window_Size()
        {
            var mockPagedResult = new Mock<PagedResultBase>();
            mockPagedResult.SetupGet(c => c.PageNumber).Returns(1).Verifiable();
            mockPagedResult.SetupGet(c => c.Pages).Returns(12).Verifiable();
            mockPagedResult.SetupGet(c => c.Window).Returns(10).Verifiable();

            PagedResultBase pagedResult = mockPagedResult.Object;

            PaginationBuilder builder = new DefaultPaginationBuilder(pagedResult,
                                                                     (itemPerPage, index) =>
                                                                     string.Format("/Controller/Action/{0}/{1}",
                                                                                   itemPerPage,
                                                                                   index));
            builder.BuildPageLinks();

            var gap = builder.Pagination.FirstOrDefault(c => c is Gap);

            Assert.That(gap, Is.Not.Null
                                 .And
                                 .InstanceOf<Gap>());

            mockPagedResult.Verify();
        }
        public void When_Build_Page_Link_With_One_Page_No_Link_Should_Be_Builded()
        {
            var mockPagedResult = new Mock<PagedResultBase>();
            mockPagedResult.SetupGet(c => c.Pages).Returns(1).Verifiable();

            PagedResultBase pagedResult = mockPagedResult.Object;

            PaginationBuilder builder = new DefaultPaginationBuilder(pagedResult,
                                                                     (pages, index) =>
                                                                     string.Format("/Controller/Action/{0}/{1}", pages,
                                                                                   index));
            builder.BuildPageLinks();

            Assert.That(builder.Pagination.Count(), Is.EqualTo(0));

            mockPagedResult.Verify();
        }
        public void When_Building_Page_Links_For_3_Pages_Pagination_Current_Page_Must_Be_Of_CurrentPage_Type()
        {
            var mockPagedResult = new Mock<PagedResultBase>();
            mockPagedResult.SetupGet(c => c.Pages).Returns(3).Verifiable();
            mockPagedResult.SetupGet(c => c.PageNumber).Returns(1).Verifiable();
            mockPagedResult.SetupGet(c => c.Window).Returns(10).Verifiable();

            PagedResultBase pagedResult = mockPagedResult.Object;

            PaginationBuilder builder = new DefaultPaginationBuilder(pagedResult,
                                                                     (pages, index) =>
                                                                     string.Format("/Controller/Action/{0}/{1}", pages,
                                                                                   index));
            builder.BuildPageLinks();

            Assert.That(builder.Pagination.Count(), Is.EqualTo(3));

            bool first = true;
            foreach (var pageLink in builder.Pagination)
            {
                if (first)
                {
                    Assert.That(pageLink, Is.Not.Null
                                              .And
                                              .TypeOf<CurrentPage>());
                    first = false;
                }
                else
                {
                    Assert.That(pageLink, Is.Not.Null
                                              .And
                                              .TypeOf<PageLink>());
                }
            }

            mockPagedResult.Verify();
        }
        public void Can_Build_Page_Links_For_3_Pages_Pagination()
        {
            var mockPagedResult = new Mock<PagedResultBase>();
            mockPagedResult.SetupGet(c => c.Pages).Returns(3).Verifiable();
            mockPagedResult.SetupGet(c => c.PageNumber).Returns(1).Verifiable();
            mockPagedResult.SetupGet(c => c.Window).Returns(10).Verifiable();

            PagedResultBase pagedResult = mockPagedResult.Object;

            PaginationBuilder builder = new DefaultPaginationBuilder(pagedResult,
                                                                     (pages, index) =>
                                                                     string.Format("/Controller/Action/{0}/{1}", pages,
                                                                                   index));
            builder.BuildPageLinks();

            Assert.That(builder.Pagination.Count(), Is.EqualTo(3));

            foreach (var pageLink in builder.Pagination)
            {
                Assert.That(pageLink, Is.Not.Null);
            }

            mockPagedResult.Verify();
        }
        public void Build_Page_Link_Tag_For_10_Items_Per_Page_Must_Return_10_Item_Per_Page_On_Url()
        {
            var mockPagedResult = new Mock<PagedResultBase>();
            mockPagedResult.SetupGet(c => c.PageNumber).Returns(1).Verifiable();
            mockPagedResult.SetupGet(c => c.Pages).Returns(2).Verifiable();
            mockPagedResult.SetupGet(c => c.Window).Returns(10).Verifiable();
            mockPagedResult.SetupGet(c => c.ItemsPerPage).Returns(10).Verifiable();

            PagedResultBase pagedResult = mockPagedResult.Object;

            PaginationBuilder builder = new DefaultPaginationBuilder(pagedResult,
                                                                     (itemPerPage, index) =>
                                                                     string.Format("/Controller/Action/{0}/{1}", itemPerPage,
                                                                                   index));
            builder.BuildPageLinks();

            var i = 2;
            foreach (var pageLink in builder.Pagination.Where(c => c is PageLink))
            {
                Assert.That(pageLink.GetUrl(),
                    Is.EqualTo(string.Format("/Controller/Action/10/{0}", i)));
            }

            mockPagedResult.Verify();
        }