public void UrlNavigator_Construct_NavigatorSizeBiggerThenPageCount()
        {
            // arrange / act
            UrlNavigator nav = UrlNavigatorBuilder.Build(url, 4, 8, 10);

            // assert
            Assert.Equal(10, nav.NavigatorSize);
            Assert.Equal(8, nav.Numerics.Count);
        }
        public void UrlNavigator_Construct_LastPage()
        {
            // arrange / act
            UrlNavigator nav  = UrlNavigatorBuilder.Build(url, 4, 10, null);
            PageLink     page = nav.Last;

            // assert
            Assert.Equal(10, page.Number);
            Assert.Equal(page.Url, url + "?pageNumber=10");
        }
        public void UrlNavigator_Construct_PreviousPage()
        {
            // arrange / act
            UrlNavigator nav  = UrlNavigatorBuilder.Build(url, 4, 10, null);
            PageLink     page = nav.Previous;

            // assert
            Assert.Equal(3, page.Number);
            Assert.Equal(page.Url, url + "?pageNumber=3");
        }
        public void UrlNavigator_Construct_NumericPages()
        {
            // arrange / act
            UrlNavigator    nav      = UrlNavigatorBuilder.Build(url, 37, 300, 10);
            List <PageLink> numPages = nav.Numerics;

            // assert
            Assert.Equal(10, nav.NavigatorSize);
            Assert.Equal(10, nav.Numerics.Count);
            Assert.Equal(42, numPages[9].Number);
        }
示例#5
0
 /// <summary>
 /// Contructor - Set configuration for mounting paged list
 /// </summary>
 /// <param name="OriginUrl">Origin url - full or only path</param>
 /// <param name="itemCount">Items count total </param>
 /// <param name="pageNumber">Current page</param>
 /// <param name="pageSize">Page max size</param>
 /// <param name="navigatorSize">Numeric navigator size, if null, this is not generated </param>
 public PagedList(
     string originUrl,
     long itemCount,
     int pageNumber,
     int pageSize,
     int?navigatorSize = null
     )
 {
     this.Options   = PageOptionsBuilder.Build(itemCount, pageNumber, pageSize);
     originUrl      = UrlHelper.GetUrlBaseToPagingWithoutPagingParams(originUrl, pageSize);
     this.Navigator = UrlNavigatorBuilder.Build(originUrl, Options.PageNumber, Options.PageCount, navigatorSize);
 }
        public void UrlNavigator_Construct_InvalidNavigatorSize()
        {
            // arrange / act
            UrlNavigator nav1 = UrlNavigatorBuilder.Build(url, 4, 10, null);
            UrlNavigator nav2 = UrlNavigatorBuilder.Build(url, 4, 10, 0);
            UrlNavigator nav3 = UrlNavigatorBuilder.Build(url, 4, 10, -2);

            // assert
            Assert.Null(nav1.NavigatorSize);
            Assert.Null(nav1.Numerics);
            Assert.Null(nav2.NavigatorSize);
            Assert.Null(nav2.Numerics);
            Assert.Null(nav3.NavigatorSize);
            Assert.Null(nav3.Numerics);
        }