public void ValidateOperationShouldThrowWhenOperationMetadataIsNull()
        {
            ODataOperation operation = new ODataAction();
            Action         action    = () => ODataJsonLightValidationUtils.ValidateOperation(metadataDocumentUri, operation);

            action.ShouldThrow <ODataException>().WithMessage(ErrorStrings.ValidationUtils_ActionsAndFunctionsMustSpecifyMetadata(operation.GetType().Name));
        }
        public void ValidateOperationShouldNotThrowWhenOperationMetadataIsNotOpenAndOperationTargetNull()
        {
            ODataOperation operation = new ODataAction {
                Metadata = new Uri(metadataDocumentUri.OriginalString + "#baz")
            };

            ODataJsonLightValidationUtils.ValidateOperation(metadataDocumentUri, operation);
        }
        public void ValidateOperationShouldThrowWhenOperationMetadataIsOpenAndOperationTargetIsNotNull()
        {
            ODataOperation operation = new ODataAction {
                Metadata = new Uri("http://www.example.com/foo#baz"), Target = new Uri("http://www.example.com")
            };
            Action action = () => ODataJsonLightValidationUtils.ValidateOperation(metadataDocumentUri, operation);

            action.ShouldThrow <ODataException>().WithMessage(ErrorStrings.ODataJsonLightValidationUtils_OpenMetadataReferencePropertyNotSupported("http://www.example.com/foo#baz", metadataDocumentUri.AbsoluteUri));
        }
        public void ValidateOperationShouldThrowWhenOperationMetadataIsNotMetadataReferenceProperty()
        {
            ODataOperation operation = new ODataAction {
                Metadata = new Uri("foobaz", UriKind.Relative)
            };
            Action action = () => ODataJsonLightValidationUtils.ValidateOperation(metadataDocumentUri, operation);

            action.ShouldThrow <ODataException>().WithMessage(ErrorStrings.ValidationUtils_InvalidMetadataReferenceProperty("foobaz"));
        }
Exemple #5
0
        /// <summary>
        /// Sets the metadata builder for this operation.
        /// </summary>
        /// <param name="builder">The metadata builder used to compute values from model annotations.</param>
        /// <param name="metadataDocumentUri">The metadata document Uri.</param>
        internal void SetMetadataBuilder(ODataEntityMetadataBuilder builder, Uri metadataDocumentUri)
        {
            Debug.Assert(metadataDocumentUri != null, "metadataDocumentUri != null");
            Debug.Assert(metadataDocumentUri.IsAbsoluteUri, "metadataDocumentUri.IsAbsoluteUri");

            ODataJsonLightValidationUtils.ValidateOperation(metadataDocumentUri, this);
            this.metadataBuilder   = builder;
            this.operationFullName = ODataJsonLightUtils.GetFullyQualifiedOperationName(metadataDocumentUri, UriUtils.UriToString(this.Metadata), out this.parameterNames);
            this.computedTitle     = null;
            this.computedTarget    = null;
        }
Exemple #6
0
        /// <summary>
        /// Sets the metadata builder for this operation.
        /// </summary>
        /// <param name="builder">The metadata builder used to compute values from model annotations.</param>
        /// <param name="metadataDocumentUri">The metadata document Uri.</param>
        internal void SetMetadataBuilder(ODataEntityMetadataBuilder builder, Uri metadataDocumentUri)
        {
            DebugUtils.CheckNoExternalCallers();
            Debug.Assert(metadataDocumentUri != null, "metadataDocumentUri != null");
            Debug.Assert(metadataDocumentUri.IsAbsoluteUri, "metadataDocumentUri.IsAbsoluteUri");

            ODataJsonLightValidationUtils.ValidateOperation(metadataDocumentUri, this);
            this.metadataBuilder   = builder;
            this.operationFullName = ODataJsonLightUtils.GetFullyQualifiedFunctionImportName(metadataDocumentUri, UriUtilsCommon.UriToString(this.Metadata), out this.bindingParameterTypeName);
            this.computedTitle     = null;
            this.computedTarget    = null;
        }