コード例 #1
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="other">The <see cref="ReaderTestConfiguration"/> instance used to initialize the new instance.</param>
 /// <param name="behaviorKind">The behavior to use when running this test.</param>
 private ReaderTestConfiguration(ReaderTestConfiguration other, TestODataBehaviorKind behaviorKind)
     : base(other.Format, other.Version, other.IsRequest, behaviorKind)
 {
     this.MessageReaderSettings         = other.MessageReaderSettings.Clone();
     this.Synchronous                   = other.Synchronous;
     this.SkipStateValidationBeforeRead = other.SkipStateValidationBeforeRead;
 }
コード例 #2
0
            /// <summary>
            /// Computes the expected exception for this test case.
            /// </summary>
            /// <param name="behaviorKind">The <see cref="TestODataBehaviorKind"/> used by this test variation.</param>
            /// <param name="version">The <see cref="ODataVersion"/> used by this test variation.</param>
            /// <param name="ignoredOnServer">true if the payload value is ignored on the server; otherwise false.</param>
            /// <returns>The expected exception for a test variation using the specified parameter values; null if no exception is expected.</returns>
            public ExpectedException ComputeExpectedException(TestODataBehaviorKind behaviorKind, ODataVersion version, bool ignoredOnServer)
            {
                bool settingsBaseIsNullOrRelative = this.SettingsBaseUri == null || !(new Uri(this.SettingsBaseUri, UriKind.RelativeOrAbsolute).IsAbsoluteUri);
                bool xmlBaseIsNullOrRelative      = this.XmlBaseUri == null || !(new Uri(this.XmlBaseUri, UriKind.RelativeOrAbsolute).IsAbsoluteUri);
                bool ignoreXmlBase = false;

                // If both the settings base URI and an xml:base are relative we will fail when we detect the xml:base.
                if (settingsBaseIsNullOrRelative && xmlBaseIsNullOrRelative && !ignoreXmlBase)
                {
                    string relativeBase = this.XmlBaseUri == null ? string.Empty : this.XmlBaseUri;
                    return(ODataExpectedExceptions.ODataException("ODataAtomDeserializer_RelativeUriUsedWithoutBaseUriSpecified", relativeBase));
                }

                // Special rules for WCF DS server behavior.
                if (behaviorKind == TestODataBehaviorKind.WcfDataServicesServer)
                {
                    // If the payload is ignored on the server, we expect no exception.
                    if (ignoredOnServer)
                    {
                        return(null);
                    }
                }

                return(null);
            }
コード例 #3
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="format">The format used for the test.</param>
 /// <param name="version">The OData protocol version to be used for the payload.</param>
 /// <param name="request">True if the test is reading a request. Otherwise false if it's reading a response.</param>
 public TestConfiguration(ODataFormat format, ODataVersion version, bool request, TestODataBehaviorKind behaviorKind)
 {
     this.Format = format;
     this.Version = version;
     this.IsRequest = request;
     this.RunBehaviorKind = behaviorKind;
 }
コード例 #4
0
        /// <summary>
        /// Applies the specified behavior with default settings.
        /// </summary>
        /// <param name="behaviorKind">The behavior kind to apply.</param>
        /// <returns>A copy of this configuration with the new behavior applied.</returns>
        public ReaderTestConfiguration CloneAndApplyBehavior(TestODataBehaviorKind behaviorKind)
        {
            ReaderTestConfiguration testConfiguration = new ReaderTestConfiguration(this, behaviorKind);

            switch (behaviorKind)
            {
            case TestODataBehaviorKind.Default:
                break;

            case TestODataBehaviorKind.WcfDataServicesClient:
                testConfiguration.MessageReaderSettings.Validations &= ~ValidationKinds.ThrowOnDuplicatePropertyNames;
                testConfiguration.MessageReaderSettings.ClientCustomTypeResolver = null;
                testConfiguration.MessageReaderSettings.Validations &= ~ValidationKinds.ThrowIfTypeConflictsWithMetadata;
                break;

            case TestODataBehaviorKind.WcfDataServicesServer:
                testConfiguration.MessageReaderSettings.Validations &= ~ValidationKinds.ThrowOnDuplicatePropertyNames;
                testConfiguration.MessageReaderSettings.ClientCustomTypeResolver = null;
                testConfiguration.MessageReaderSettings.Validations &= ~ValidationKinds.ThrowIfTypeConflictsWithMetadata;
                // EnableReadingEntryContentInEntryStartState == true
                break;
            }

            return(testConfiguration);
        }
コード例 #5
0
            /// <summary>
            /// Computes the expected exception for this test case.
            /// </summary>
            /// <param name="behaviorKind">The <see cref="TestODataBehaviorKind"/> used by this test variation.</param>
            /// <param name="version">The <see cref="ODataVersion"/> used by this test variation.</param>
            /// <param name="ignoredOnServer">true if the payload value is ignored on the server; otherwise false.</param>
            /// <returns>The expected exception for a test variation using the specified parameter values; null if no exception is expected.</returns>
            public ExpectedException ComputeExpectedException(TestODataBehaviorKind behaviorKind, ODataVersion version, bool ignoredOnServer)
            {
                bool settingsBaseIsNullOrRelative = this.SettingsBaseUri == null || !(new Uri(this.SettingsBaseUri, UriKind.RelativeOrAbsolute).IsAbsoluteUri);
                bool xmlBaseIsNullOrRelative = this.XmlBaseUri == null || !(new Uri(this.XmlBaseUri, UriKind.RelativeOrAbsolute).IsAbsoluteUri);
                bool ignoreXmlBase = false;

                // If both the settings base URI and an xml:base are relative we will fail when we detect the xml:base.
                if (settingsBaseIsNullOrRelative && xmlBaseIsNullOrRelative && !ignoreXmlBase)
                {
                    string relativeBase = this.XmlBaseUri == null ? string.Empty : this.XmlBaseUri;
                    return ODataExpectedExceptions.ODataException("ODataAtomDeserializer_RelativeUriUsedWithoutBaseUriSpecified", relativeBase);
                }

                // Special rules for WCF DS server behavior.
                if (behaviorKind == TestODataBehaviorKind.WcfDataServicesServer)
                {
                    // If the payload is ignored on the server, we expect no exception.
                    if (ignoredOnServer)
                    {
                        return null;
                    }
                }

                return null;
            }
コード例 #6
0
            /// <summary>
            /// Computes the expected result URI for this test case and a specified test variation.
            /// </summary>
            /// <param name="behaviorKind">The <see cref="TestODataBehaviorKind"/> used by this test variation.</param>
            /// <param name="version">The <see cref="ODataVersion"/> used by this test variation.</param>
            /// <param name="ignoredOnServer">true if the payload value is ignored on the server; otherwise false.</param>
            /// <returns>The expected result URI from processing the relative URI in the payload.</returns>
            public string ComputeExpectedResultUri(TestODataBehaviorKind behaviorKind, ODataVersion version, bool ignoredOnServer)
            {
                // Special rules apply for the WCF DS server behavior.
                if (behaviorKind == TestODataBehaviorKind.WcfDataServicesServer)
                {
                    // If the payload URI is not even read in the server, we expect a null value.
                    if (ignoredOnServer)
                    {
                        return(null);
                    }

                    return(this.ResultUri);
                }

                return(this.ResultUri);
            }
コード例 #7
0
        /// <summary>
        /// Applies the specified behavior with default settings.
        /// For detailed settings the caller should use Clone and direct application of behavior to the settings.
        /// </summary>
        /// <param name="behaviorKind">The behavior kind to apply.</param>
        /// <returns>A copy of this configuration with the new behavior applied.</returns>
        public WriterTestConfiguration CloneAndApplyBehavior(TestODataBehaviorKind behaviorKind)
        {
            WriterTestConfiguration testConfiguration = this.Clone();
            switch (behaviorKind)
            {
                case TestODataBehaviorKind.Default:
                    break;
                case TestODataBehaviorKind.WcfDataServicesClient:
                    testConfiguration.MessageWriterSettings.EnableWcfDataServicesClientBehavior();
                    break;
                case TestODataBehaviorKind.WcfDataServicesServer:
                    testConfiguration.MessageWriterSettings.EnableODataServerBehavior(false);
                    break;
            }

            return testConfiguration;
        }
コード例 #8
0
        /// <summary>
        /// Applies the specified behavior with default settings.
        /// For detailed settings the caller should use Clone and direct application of behavior to the settings.
        /// </summary>
        /// <param name="behaviorKind">The behavior kind to apply.</param>
        /// <returns>A copy of this configuration with the new behavior applied.</returns>
        public WriterTestConfiguration CloneAndApplyBehavior(TestODataBehaviorKind behaviorKind)
        {
            WriterTestConfiguration testConfiguration = this.Clone();

            switch (behaviorKind)
            {
            case TestODataBehaviorKind.Default:
                break;

            case TestODataBehaviorKind.WcfDataServicesClient:
                break;

            case TestODataBehaviorKind.WcfDataServicesServer:
                testConfiguration.MessageWriterSettings.Validations &= ~ValidationKinds.ThrowOnDuplicatePropertyNames;
                break;
            }

            return(testConfiguration);
        }
コード例 #9
0
        /// <summary>
        /// Applies the specified behavior with default settings.
        /// </summary>
        /// <param name="behaviorKind">The behavior kind to apply.</param>
        /// <returns>A copy of this configuration with the new behavior applied.</returns>
        public ReaderTestConfiguration CloneAndApplyBehavior(TestODataBehaviorKind behaviorKind)
        {
            ReaderTestConfiguration testConfiguration = new ReaderTestConfiguration(this, behaviorKind);

            switch (behaviorKind)
            {
            case TestODataBehaviorKind.Default:
                break;

            case TestODataBehaviorKind.WcfDataServicesClient:
                testConfiguration.MessageReaderSettings.EnableWcfDataServicesClientBehavior(null);
                break;

            case TestODataBehaviorKind.WcfDataServicesServer:
                testConfiguration.MessageReaderSettings.EnableODataServerBehavior();
                break;
            }

            return(testConfiguration);
        }
コード例 #10
0
        /// <summary>
        /// Applies the specified behavior with default settings.
        /// For detailed settings the caller should use Clone and direct application of behavior to the settings.
        /// </summary>
        /// <param name="behaviorKind">The behavior kind to apply.</param>
        /// <returns>A copy of this configuration with the new behavior applied.</returns>
        public WriterTestConfiguration CloneAndApplyBehavior(TestODataBehaviorKind behaviorKind)
        {
            WriterTestConfiguration testConfiguration = this.Clone();

            switch (behaviorKind)
            {
            case TestODataBehaviorKind.Default:
                break;

            case TestODataBehaviorKind.WcfDataServicesClient:
                testConfiguration.MessageWriterSettings.EnableWcfDataServicesClientBehavior();
                break;

            case TestODataBehaviorKind.WcfDataServicesServer:
                testConfiguration.MessageWriterSettings.EnableODataServerBehavior(false);
                break;
            }

            return(testConfiguration);
        }
コード例 #11
0
        /// <summary>
        /// Applies the specified behavior with default settings.
        /// </summary>
        /// <param name="behaviorKind">The behavior kind to apply.</param>
        /// <returns>A copy of this configuration with the new behavior applied.</returns>
        public ReaderTestConfiguration CloneAndApplyBehavior(TestODataBehaviorKind behaviorKind)
        {
            ReaderTestConfiguration testConfiguration = new ReaderTestConfiguration(this, behaviorKind);
            switch (behaviorKind)
            {
                case TestODataBehaviorKind.Default:
                    break;
                case TestODataBehaviorKind.WcfDataServicesClient:
                    testConfiguration.MessageReaderSettings.EnableWcfDataServicesClientBehavior(null);
                    break;
                case TestODataBehaviorKind.WcfDataServicesServer:
                    testConfiguration.MessageReaderSettings.EnableODataServerBehavior();
                    break;
            }

            return testConfiguration;
        }
コード例 #12
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="other">The <see cref="ReaderTestConfiguration"/> instance used to initialize the new instance.</param>
 /// <param name="behaviorKind">The behavior to use when running this test.</param>
 private ReaderTestConfiguration(ReaderTestConfiguration other, TestODataBehaviorKind behaviorKind)
     : base(other.Format, other.Version, other.IsRequest, behaviorKind)
 {
     this.MessageReaderSettings = new ODataMessageReaderSettings(other.MessageReaderSettings);
     this.Synchronous = other.Synchronous;
 }
コード例 #13
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="other">The <see cref="ReaderTestConfiguration"/> instance used to initialize the new instance.</param>
 /// <param name="behaviorKind">The behavior to use when running this test.</param>
 private ReaderTestConfiguration(ReaderTestConfiguration other, TestODataBehaviorKind behaviorKind)
     : base(other.Format, other.Version, other.IsRequest, behaviorKind)
 {
     this.MessageReaderSettings = new ODataMessageReaderSettings(other.MessageReaderSettings);
     this.Synchronous           = other.Synchronous;
 }
コード例 #14
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="format">The format used for the test.</param>
 /// <param name="version">The OData protocol version to be used for the payload.</param>
 /// <param name="request">True if the test is reading a request. Otherwise false if it's reading a response.</param>
 public TestConfiguration(ODataFormat format, ODataVersion version, bool request, TestODataBehaviorKind behaviorKind)
 {
     this.Format          = format;
     this.Version         = version;
     this.IsRequest       = request;
     this.RunBehaviorKind = behaviorKind;
 }
コード例 #15
0
            /// <summary>
            /// Computes the expected result URI for this test case and a specified test variation.
            /// </summary>
            /// <param name="behaviorKind">The <see cref="TestODataBehaviorKind"/> used by this test variation.</param>
            /// <param name="version">The <see cref="ODataVersion"/> used by this test variation.</param>
            /// <param name="ignoredOnServer">true if the payload value is ignored on the server; otherwise false.</param>
            /// <returns>The expected result URI from processing the relative URI in the payload.</returns>
            public string ComputeExpectedResultUri(TestODataBehaviorKind behaviorKind, ODataVersion version, bool ignoredOnServer)
            {
                // Special rules apply for the WCF DS server behavior.
                if (behaviorKind == TestODataBehaviorKind.WcfDataServicesServer)
                {
                    // If the payload URI is not even read in the server, we expect a null value.
                    if (ignoredOnServer)
                    {
                        return null;
                    }

                    return this.ResultUri;
                }

                return this.ResultUri;
            }