public void SortedBy_GivenInvalidNestedProperty_ThrowsArgumentException() { // Arrange var paginator = new SortingPaginator <Person>(); // Act void action() => paginator.SortedBy("FavoriteBook.UndefinedProperty"); // Assert var exception = Assert.ThrowsException <ArgumentException>(action); Assert.AreEqual("No property 'UndefinedProperty' on type 'Book'. (Parameter 'propertyName')", exception.Message); }
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_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()); }