public void ValidatePassWhenQuerySettingsLimitIsNotReached()
        {
            // 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 ValidateThrowsWhenQuerySettingsLimitIsExceeded()
        {
            // 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 ComputeQueryValidatorTest()
 {
     _context        = ValidationTestHelper.CreateCustomerContext();
     _productContext = ValidationTestHelper.CreateDerivedProductsContext();
     _validator      = new MyComputeValidator(_productContext.DefaultQuerySettings);
 }
 public SkipQueryValidatorTest()
 {
     _validator = new SkipQueryValidator();
     _context   = ValidationTestHelper.CreateCustomerContext();
 }