private bool ValidateSorting <T, TNext>(TestGrid grid, Func <TestModel, T> orderExpression, string columnName, GridSortDirection direction, Func <TestModel, TNext> thenByExpression, GridSortDirection?thenByDirection) { grid.AddQueryParameter(((QueryStringSortSettings)grid.Settings.SortSettings) .ColumnQueryParameterName, columnName); grid.AddQueryParameter(((QueryStringSortSettings)grid.Settings.SortSettings) .DirectionQueryParameterName, direction.ToString("d")); grid.UpdateGrid().Wait(); IEnumerable <TestModel> resultCollection = grid.GetItemsToDisplay(); IOrderedEnumerable <TestModel> etalonCollection; switch (direction) { case GridSortDirection.Ascending: etalonCollection = _repo.GetAll().OrderBy(orderExpression); break; case GridSortDirection.Descending: etalonCollection = _repo.GetAll().OrderByDescending(orderExpression); break; default: throw new ArgumentOutOfRangeException("direction"); } if (thenByExpression != null) { switch (thenByDirection) { case GridSortDirection.Ascending: etalonCollection = etalonCollection.ThenBy(thenByExpression); break; case GridSortDirection.Descending: etalonCollection = etalonCollection.ThenByDescending(thenByExpression); break; default: throw new ArgumentOutOfRangeException("thenByDirection"); } } if (!ValidateCollectionsTheSame(resultCollection, etalonCollection)) { return(false); } return(true); }
public override string ToString() { return(ColumnName + SortingDataDelimeter + Direction.ToString("D") + SortingDataDelimeter + Id.ToString()); }