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