コード例 #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));
        }
コード例 #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'.");
        }
コード例 #3
0
 public OrderByQueryValidatorTest()
 {
     _context   = ValidationTestHelper.CreateCustomerContext();
     _validator = new OrderByQueryValidator(_context.DefaultQuerySettings);
 }
コード例 #4
0
 public ODataQueryValidatorTest()
 {
     _validator = new ODataQueryValidator();
     _context   = ValidationTestHelper.CreateCustomerContext(false);
 }
コード例 #5
0
 public SkipQueryValidatorTest()
 {
     _validator = new SkipQueryValidator();
     _context   = ValidationTestHelper.CreateCustomerContext();
 }
コード例 #6
0
 public OrderByQueryValidatorTest()
 {
     _context   = ValidationTestHelper.CreateCustomerContext();
     _validator = new OrderByQueryValidator();
 }