Esempio n. 1
0
        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));
        }
Esempio n. 2
0
        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'.");
        }
Esempio n. 3
0
 public OrderByQueryValidatorTest()
 {
     _context   = ValidationTestHelper.CreateCustomerContext();
     _validator = new OrderByQueryValidator(_context.DefaultQuerySettings);
 }
 public ODataQueryValidatorTest()
 {
     _validator = new ODataQueryValidator();
     _context   = ValidationTestHelper.CreateCustomerContext(false);
 }
Esempio n. 5
0
 public SkipQueryValidatorTest()
 {
     _validator = new SkipQueryValidator();
     _context   = ValidationTestHelper.CreateCustomerContext();
 }
Esempio n. 6
0
 public OrderByQueryValidatorTest()
 {
     _context   = ValidationTestHelper.CreateCustomerContext();
     _validator = new OrderByQueryValidator();
 }