public void Can_Build_Correct_Model_For_10_Items_With_2_Item_Per_Page() { // Assemble var expectedPagination = new List <PaginationLink>() { new PaginationLink { Active = true, Text = "«", PageNumber = 2, Url = "/test/2" }, new PaginationLink { Active = true, Text = "1", PageNumber = 1, Url = "/test/1" }, new PaginationLink { Active = true, Text = "2", PageNumber = 2, Url = "/test/2" }, new PaginationLink { Active = true, Text = "3", PageNumber = 3, Url = "/test/3", IsCurrent = true }, new PaginationLink { Active = true, Text = "4", PageNumber = 4, Url = "/test/4" }, new PaginationLink { Active = true, Text = "5", PageNumber = 5, Url = "/test/5" }, new PaginationLink { Active = true, Text = "»", PageNumber = 4, Url = "/test/4" } }; var settings = new PaginationSettings { CurrentPage = 3, ItemsPerPage = 2, TotalItems = 10 }; var builder = new PaginationLinkBuilder(); //Act var result = builder.BuildPaginationLinks( settings, generateUrl, firstPageText, firstPageTitle, previousPageText, previousPageTitle, nextPageText, nextPageTitle, lastPageText, lastPageTitle, spacerText); //Assert Assert.Equal(expectedPagination.Count, result.Count); PaginationComparer comparer = new PaginationComparer(); for (int i = 0; i < expectedPagination.Count; i++) { Assert.Equal(expectedPagination[i], result[i], comparer); } }
public void Can_Build_Correct_Model_For_33_Items_With_2_Item_Per_Page() { // Assemble var expectedPagination = new List <PaginationLink>() { new PaginationLink { Active = true, Text = "«", PageNumber = 12, Url = "/test/12" }, new PaginationLink { Active = true, Text = "1", PageNumber = 1, Url = "/test/1" }, new PaginationLink { Active = true, Text = "2", PageNumber = 2, Url = "/test/2" }, new PaginationLink { Active = false, Text = "...", Url = "", IsSpacer = true }, new PaginationLink { Active = true, Text = "8", PageNumber = 8, Url = "/test/8" }, new PaginationLink { Active = true, Text = "9", PageNumber = 9, Url = "/test/9" }, new PaginationLink { Active = true, Text = "10", PageNumber = 10, Url = "/test/10" }, new PaginationLink { Active = true, Text = "11", PageNumber = 11, Url = "/test/11" }, new PaginationLink { Active = true, Text = "12", PageNumber = 12, Url = "/test/12" }, new PaginationLink { Active = true, Text = "13", PageNumber = 13, Url = "/test/13", IsCurrent = true }, new PaginationLink { Active = true, Text = "14", PageNumber = 14, Url = "/test/14" }, new PaginationLink { Active = true, Text = "15", PageNumber = 15, Url = "/test/15" }, new PaginationLink { Active = true, Text = "16", PageNumber = 16, Url = "/test/16" }, new PaginationLink { Active = true, Text = "17", PageNumber = 17, Url = "/test/17" }, new PaginationLink { Active = true, Text = "»", PageNumber = 14, Url = "/test/14" } }; var settings = new PaginationSettings { CurrentPage = 13, ItemsPerPage = 2, TotalItems = 33 }; var builder = new PaginationLinkBuilder(); //Act var result = builder.BuildPaginationLinks( settings, generateUrl, firstPageText, firstPageTitle, previousPageText, previousPageTitle, nextPageText, nextPageTitle, lastPageText, lastPageTitle, spacerText); //Assert Assert.Equal(expectedPagination.Count, result.Count); PaginationComparer comparer = new PaginationComparer(); for (int i = 0; i < expectedPagination.Count; i++) { Assert.Equal(expectedPagination[i], result[i], comparer); } }