public void ValidateTopQueryValidator_PassWhenQuerySettingsLimitIsNotReached() { // Arrange ODataValidationSettings settings = new ODataValidationSettings() { MaxTop = 20 }; ModelBoundQuerySettings modelBoundQuerySettings = new ModelBoundQuerySettings(); modelBoundQuerySettings.MaxTop = 20; ODataQueryContext context = ValidationTestHelper.CreateCustomerContext(); context.Model.SetAnnotationValue(context.ElementType as IEdmStructuredType, modelBoundQuerySettings); // Act & Assert ExceptionAssert.DoesNotThrow(() => _validator.Validate(new TopQueryOption("20", context), settings)); }
public void ValidateTopQueryValidator_ThrowsWhenQuerySettingsLimitIsExceeded() { // Arrange ODataValidationSettings settings = new ODataValidationSettings() { MaxTop = 20 }; ModelBoundQuerySettings modelBoundQuerySettings = new ModelBoundQuerySettings(); modelBoundQuerySettings.MaxTop = 10; ODataQueryContext context = ValidationTestHelper.CreateCustomerContext(); context.Model.SetAnnotationValue(context.ElementType as IEdmStructuredType, modelBoundQuerySettings); // Act & Assert ExceptionAssert.Throws <ODataException>(() => _validator.Validate(new TopQueryOption("11", context), settings), "The limit of '10' for Top query has been exceeded. The value from the incoming request is '11'."); }
public OrderByQueryValidatorTest() { _context = ValidationTestHelper.CreateCustomerContext(); _validator = new OrderByQueryValidator(_context.DefaultQuerySettings); }
public ODataQueryValidatorTest() { _validator = new ODataQueryValidator(); _context = ValidationTestHelper.CreateCustomerContext(false); }
public SkipQueryValidatorTest() { _validator = new SkipQueryValidator(); _context = ValidationTestHelper.CreateCustomerContext(); }
public OrderByQueryValidatorTest() { _context = ValidationTestHelper.CreateCustomerContext(); _validator = new OrderByQueryValidator(); }