public void Paginate_WithNoSortProperties_ReturnsUnorderedPage() { // Arrange var paginator = new SortingPaginator <Person>(pageNumber: 1, pageSize: 5); // Act var result = paginator.Paginate(People); // Assert Assert.AreEqual(5, result.Count()); Assert.AreEqual("Welsh", result.First().FamilyName); Assert.AreEqual("Hensley", result.Last().FamilyName); }
public void HasPreviousPage_AfterPaginatingStartingAtFirstPage_ReturnsFalse() { // Arrange var paginator = new SortingPaginator <Person>(pageNumber: 1, pageSize: 5); paginator.Paginate(People); // Act var result = paginator.HasPreviousPage(); // Assert Assert.IsFalse(result); }
public void HasNextPage_AfterPaginating_ReturnsTrue() { // Arrange var paginator = new SortingPaginator <Person>(pageNumber: 1, pageSize: 5); paginator.Paginate(People); // Act var result = paginator.HasNextPage(); // Assert Assert.IsTrue(result); }
public void MoveNextPage_AfterPaginating_MovesToNextPage() { // Arrange var paginator = new SortingPaginator <Person>(pageNumber: 1, pageSize: 5); paginator.Paginate(People); // Act var result = paginator.MoveNextPage(); // Assert Assert.IsTrue(result); Assert.AreEqual(2, paginator.PageNumber); }
public void Paginate_SortedByAgeDescendingUsingExpression_ReturnsExpectedResult() { // Arrange var paginator = new SortingPaginator <Person>().StartingAt(1).WithPageSizeOf(2); paginator.SortedBy(p => p.Age, SortDirection.Descending); // Act var result = paginator.Paginate(People); // Assert Assert.AreEqual(2, result.Count()); Assert.AreEqual("Edgar Bernard", result.First().FullName()); Assert.AreEqual("Randall Bloom", result.Last().FullName()); }
public void Paginate_SortedByFamilyNameDescending_ReturnsExpectedResult() { // Arrange var paginator = new SortingPaginator <Person>(pageNumber: 1, pageSize: 2); paginator.SortDirectives.Add(new SortProperty <Person>("FamilyName", SortDirection.Descending)); // Act var result = paginator.Paginate(People); // Assert Assert.AreEqual(2, result.Count()); Assert.AreEqual("Welsh", result.First().FamilyName); Assert.AreEqual("Stuart", result.Last().FamilyName); }
public void Paginate_SortedByGivenNameAscending_ReturnsExpectedResult() { // Arrange var paginator = new SortingPaginator <Person>(pageNumber: 1, pageSize: 2); paginator.SortDirectives.Add(new SortProperty <Person>("GivenName", SortDirection.Ascending)); // Act var result = paginator.Paginate(People); // Assert Assert.AreEqual(2, result.Count()); Assert.AreEqual("Ana", result.First().GivenName); Assert.AreEqual("Dwayne", result.Last().GivenName); }
public void MovePreviousPage_AfterPaginatingStartingAtLastPage_MovesToPreviousPage() { // Arrange var paginator = new SortingPaginator <Person>(pageNumber: 1, pageSize: 5); paginator.Paginate(People); paginator.PageNumber = paginator.PageCount; // Act var result = paginator.MovePreviousPage(); // Assert Assert.IsTrue(result); Assert.AreEqual(paginator.PageCount - 1, paginator.PageNumber); }
public void Paginate_SortedByAgeAscending_ReturnsExpectedResult() { // Arrange var paginator = new SortingPaginator <Person>().StartingAt(1).WithPageSizeOf(3); paginator.SortedBy("Age", SortDirection.Ascending); // Act var result = paginator.Paginate(People); // Assert Assert.AreEqual(3, result.Count()); Assert.AreEqual("Phillipa Connor", result.First().FullName()); // null < any other value Assert.AreEqual("Peter Connor", result.ElementAt(1).FullName()); Assert.AreEqual("Dwayne Welsh", result.Last().FullName()); }
public void Paginate_SortedByFamilyNameAscendingThenGivenNameDescending_ReturnsExpectedResult() { // Arrange var paginator = new SortingPaginator <Person>(pageNumber: 2, pageSize: 3); paginator.SortDirectives.Add(new SortProperty <Person>("FamilyName", SortDirection.Ascending)); paginator.SortDirectives.Add(new SortProperty <Person>("GivenName", SortDirection.Descending)); // Act var result = paginator.Paginate(People); // Assert Assert.AreEqual(3, result.Count()); Assert.AreEqual("Phillipa", result.First().GivenName); Assert.AreEqual("Peter", result.ElementAt(1).GivenName); Assert.AreEqual("Glenn", result.Last().GivenName); }