public void Can_Build_Previous_Page_Tag_For_Page_Greater_Than_First_Page() { var mockPagedResult = new Mock<PagedResultBase>(); mockPagedResult.SetupGet(c => c.PageNumber).Returns(2).Verifiable(); PagedResultBase pagedResult = mockPagedResult.Object; PaginationBuilder builder = new DefaultPaginationBuilder(pagedResult, (pages, index) => string.Format("/Controller/Action/{0}/{1}", pages, index)); builder.BuildPreviousPageLink(); var previousPage = builder.Pagination.FirstOrDefault(); Assert.That(previousPage, Is.Not.Null .And .TypeOf<PreviousPage>()); mockPagedResult.Verify(); }
public void When_Building_Previous_Page_Tag_For_Page_Index_Equals_First_Page_It_Will_Not_Be_Builded() { var mockPagedResult = new Mock<PagedResultBase>(); mockPagedResult.SetupGet(c => c.PageNumber).Returns(1).Verifiable(); PagedResultBase pagedResult = mockPagedResult.Object; PaginationBuilder builder = new DefaultPaginationBuilder(pagedResult, (pages, index) => string.Format("/Controller/Action/{0}/{1}", pages, index)); builder.BuildPreviousPageLink(); var previousPage = builder.Pagination.FirstOrDefault(); Assert.That(previousPage, Is.Null); mockPagedResult.Verify(); }
public void Build_Previous_Page_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(2).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.BuildPreviousPageLink(); var previousPage = builder.Pagination.FirstOrDefault(); Assert.That(previousPage.GetUrl(), Is.EqualTo("/Controller/Action/10/1")); mockPagedResult.Verify(); }