public void CanTurnOffValidationForOrderBy() { // Arrange ODataQueryContext context = ValidationTestHelper.CreateCustomerContext(); OrderByQueryOption option = new OrderByQueryOption("Name", context); ODataValidationSettings settings = new ODataValidationSettings(); settings.AllowedOrderByProperties.Add("Id"); // Act & Assert ExceptionAssert.Throws <ODataException>(() => option.Validate(settings), "Order by 'Name' is not allowed. To allow it, set the 'AllowedOrderByProperties' property on EnableQueryAttribute or QueryValidationSettings."); option.Validator = null; ExceptionAssert.DoesNotThrow(() => option.Validate(settings)); }
public void CanTurnOffValidationForOrderBy() { // Arrange ODataQueryContext context = ValidationTestHelper.CreateCustomerContext(); OrderByQueryOption option = new OrderByQueryOption("Name", context); ODataValidationSettings settings = new ODataValidationSettings(); settings.AllowedOrderByProperties.Add("Id"); // Act & Assert Assert.Throws<ODataException>(() => option.Validate(settings), "Order by 'Name' is not allowed. To allow it, set the 'AllowedOrderByProperties' property on EnableQueryAttribute or QueryValidationSettings."); option.Validator = null; Assert.DoesNotThrow(() => option.Validate(settings)); }