diff --git a/QueryKit.UnitTests/FilterParsingRegressionTests.cs b/QueryKit.UnitTests/FilterParsingRegressionTests.cs index f9e814e..6c23b3b 100644 --- a/QueryKit.UnitTests/FilterParsingRegressionTests.cs +++ b/QueryKit.UnitTests/FilterParsingRegressionTests.cs @@ -341,6 +341,16 @@ public void unknown_logical_operator_throws_query_kit_parsing_exception() act.Should().Throw().WithMessage("Operator xor is not supported"); } + [Theory] + [InlineData("Age sideways")] + [InlineData("Title, Age up")] + public void invalid_sort_direction_throws_query_kit_parsing_exception(string input) + { + var act = () => SortParser.ParseSort(input); + + act.Should().Throw().WithMessage("Invalid direction: *"); + } + private static TResult WithCulture(string cultureName, Func action) { var originalCulture = CultureInfo.CurrentCulture; diff --git a/QueryKit/SortParser.cs b/QueryKit/SortParser.cs index 22a915a..593ea6e 100644 --- a/QueryKit/SortParser.cs +++ b/QueryKit/SortParser.cs @@ -52,7 +52,7 @@ private static SortExpressionInfo CreateSortExpression(string sortClause, if (direction != Ascending && direction != Descending) { - throw new ArgumentException($"Invalid direction: {direction}. Allowed values are '{Ascending}' and '{Descending}'."); + throw new QueryKitParsingException($"Invalid direction: {direction}. Allowed values are '{Ascending}' and '{Descending}'."); } var propertyPath = config?.GetPropertyPathByQueryName(propertyName) ?? propertyName;