Example #1
0
        /// <summary>
        /// Validator for collections of primitive and complex types.
        /// </summary>
        /// <param name="payloadElement">The payload element to validate.</param>
        /// <param name="testConfigLimits">The test configuration limits to modify.</param>
        public static void NonEntityCollectionValidator(ODataPayloadElement payloadElement, TestConfigurationLimits testConfigLimits)
        {
            ExceptionUtilities.Assert(payloadElement is PrimitiveMultiValue || payloadElement is ComplexMultiValue, "This validator only works on collection values.");

            // Collection values require V3.
            testConfigLimits.RaiseMinPayloadVersion(ODataVersion.V4);
        }
Example #2
0
        /// <summary>
        /// Validator for stream properties in requests.
        /// </summary>
        /// <param name="payloadElement">The payload element to validate.</param>
        /// <param name="testConfigLimits">The test configuration limits to modify.</param>
        public static void StreamPropertyValidator(ODataPayloadElement payloadElement, TestConfigurationLimits testConfigLimits)
        {
            ExceptionUtilities.Assert(payloadElement is NamedStreamInstance, "This validator only works on stream properties.");

            // Stream properties are not allowed in requests.
            testConfigLimits.DisallowRequest();

            // Stream properties are only allowed in >=V3 requests.
            testConfigLimits.RaiseMinPayloadVersion(ODataVersion.V4);
        }
Example #3
0
        /// <summary>
        /// Validator for spatial values.
        /// </summary>
        /// <param name="payloadElement">The payload element to validate.</param>
        /// <param name="testConfigLimits">The test configuration limits to modify.</param>
        public static void SpatialValueValidator(ODataPayloadElement payloadElement, TestConfigurationLimits testConfigLimits)
        {
            PrimitiveValue primitiveValue = payloadElement as PrimitiveValue;

            ExceptionUtilities.Assert(primitiveValue != null, "This validator only works on primitive values.");

            if (primitiveValue.ClrValue is ISpatial)
            {
                // Spatial values require V3.
                testConfigLimits.RaiseMinPayloadVersion(ODataVersion.V4);
            }
            else if (primitiveValue.ClrValue == null)
            {
                EntityModelTypeAnnotation typeAnnotation = primitiveValue.GetAnnotation <EntityModelTypeAnnotation>();
                if (typeAnnotation != null && typeAnnotation.EdmModelType.Definition.IsSpatial())
                {
                    testConfigLimits.RaiseMinPayloadVersion(ODataVersion.V4);
                }
            }
        }
Example #4
0
        /// <summary>
        /// Validator for actions and functions.
        /// </summary>
        /// <param name="payloadElement">The payload element to validate.</param>
        /// <param name="testConfigLimits">The test configuration limits to modify.</param>
        public static void ActionAndFunctionValidator(ODataPayloadElement payloadElement, TestConfigurationLimits testConfigLimits)
        {
            EntityInstance entityInstance = payloadElement as EntityInstance;

            ExceptionUtilities.Assert(entityInstance != null, "This validator only works on entity instances.");

            if (entityInstance.ServiceOperationDescriptors.Any())
            {
                // Actions and Functions require V3 response payloads.
                testConfigLimits.DisallowRequest();
                testConfigLimits.RaiseMinPayloadVersion(ODataVersion.V4);
            }
        }
Example #5
0
        /// <summary>
        /// Validator for stream properties in requests.
        /// </summary>
        /// <param name="payloadElement">The payload element to validate.</param>
        /// <param name="testConfigLimits">The test configuration limits to modify.</param>
        public static void AssociationLinkValidator(ODataPayloadElement payloadElement, TestConfigurationLimits testConfigLimits)
        {
            NavigationPropertyInstance navigationProperty = payloadElement as NavigationPropertyInstance;

            ExceptionUtilities.Assert(navigationProperty != null, "This validator only works on navigation properties.");

            if (navigationProperty.AssociationLink != null)
            {
                // Association links are not allowed in requests.
                testConfigLimits.DisallowRequest();

                // Association links can only be read if MPV >= V3, they are recognized even in <V3 payloads
                // but we don't have a way to specify this here, so just mark them as >=V3 as well.
                testConfigLimits.RaiseMinPayloadVersion(ODataVersion.V4);
            }
        }
        /// <summary>
        /// Validator for actions and functions.
        /// </summary>
        /// <param name="payloadElement">The payload element to validate.</param>
        /// <param name="testConfigLimits">The test configuration limits to modify.</param>
        public static void ActionAndFunctionValidator(ODataPayloadElement payloadElement, TestConfigurationLimits testConfigLimits)
        {
            EntityInstance entityInstance = payloadElement as EntityInstance;
            ExceptionUtilities.Assert(entityInstance != null, "This validator only works on entity instances.");

            if (entityInstance.ServiceOperationDescriptors.Any())
            {
                // Actions and Functions require V3 response payloads.
                testConfigLimits.DisallowRequest();
                testConfigLimits.RaiseMinPayloadVersion(ODataVersion.V4);
            }
        }
        /// <summary>
        /// Validator for spatial values.
        /// </summary>
        /// <param name="payloadElement">The payload element to validate.</param>
        /// <param name="testConfigLimits">The test configuration limits to modify.</param>
        public static void SpatialValueValidator(ODataPayloadElement payloadElement, TestConfigurationLimits testConfigLimits)
        {
            PrimitiveValue primitiveValue = payloadElement as PrimitiveValue;
            ExceptionUtilities.Assert(primitiveValue != null, "This validator only works on primitive values.");

            if (primitiveValue.ClrValue is ISpatial)
            {
                // Spatial values require V3.
                testConfigLimits.RaiseMinPayloadVersion(ODataVersion.V4);
            }
            else if (primitiveValue.ClrValue == null)
            {
                EntityModelTypeAnnotation typeAnnotation = primitiveValue.GetAnnotation<EntityModelTypeAnnotation>();
                if (typeAnnotation != null && typeAnnotation.EdmModelType.Definition.IsSpatial())
                {
                    testConfigLimits.RaiseMinPayloadVersion(ODataVersion.V4);
                }
            }
        }
        /// <summary>
        /// Validator for stream properties in requests.
        /// </summary>
        /// <param name="payloadElement">The payload element to validate.</param>
        /// <param name="testConfigLimits">The test configuration limits to modify.</param>
        public static void AssociationLinkValidator(ODataPayloadElement payloadElement, TestConfigurationLimits testConfigLimits)
        {
            NavigationPropertyInstance navigationProperty = payloadElement as NavigationPropertyInstance;
            ExceptionUtilities.Assert(navigationProperty != null, "This validator only works on navigation properties.");

            if (navigationProperty.AssociationLink != null)
            {
                // Association links are not allowed in requests.
                testConfigLimits.DisallowRequest();

                // Association links can only be read if MPV >= V3, they are recognized even in <V3 payloads
                // but we don't have a way to specify this here, so just mark them as >=V3 as well.
                testConfigLimits.RaiseMinPayloadVersion(ODataVersion.V4);
            }
        }
        /// <summary>
        /// Validator for stream properties in requests.
        /// </summary>
        /// <param name="payloadElement">The payload element to validate.</param>
        /// <param name="testConfigLimits">The test configuration limits to modify.</param>
        public static void StreamPropertyValidator(ODataPayloadElement payloadElement, TestConfigurationLimits testConfigLimits)
        {
            ExceptionUtilities.Assert(payloadElement is NamedStreamInstance, "This validator only works on stream properties.");

            // Stream properties are not allowed in requests.
            testConfigLimits.DisallowRequest();

            // Stream properties are only allowed in >=V3 requests.
            testConfigLimits.RaiseMinPayloadVersion(ODataVersion.V4);
        }
        /// <summary>
        /// Validator for collections of primitive and complex types.
        /// </summary>
        /// <param name="payloadElement">The payload element to validate.</param>
        /// <param name="testConfigLimits">The test configuration limits to modify.</param>
        public static void NonEntityCollectionValidator(ODataPayloadElement payloadElement, TestConfigurationLimits testConfigLimits)
        {
            ExceptionUtilities.Assert(payloadElement is PrimitiveMultiValue || payloadElement is ComplexMultiValue, "This validator only works on collection values.");

            // Collection values require V3.
            testConfigLimits.RaiseMinPayloadVersion(ODataVersion.V4);
        }