コード例 #1
0
            /// <summary>
            /// Called to create the input message for the reader test.
            /// </summary>
            /// <param name="testConfiguration">The test configuration.</param>
            /// <returns>The newly created test message to use.</returns>
            protected override TestMessage CreateInputMessage(ReaderTestConfiguration testConfiguration)
            {
                bool originalApplyTransformValue = false;
                var  odataTransformFactory       = this.settings.PayloadTransformFactory as ODataLibPayloadTransformFactory;

                try
                {
                    if (this.ApplyPayloadTransformations.HasValue && odataTransformFactory != null)
                    {
                        originalApplyTransformValue          = odataTransformFactory.ApplyTransform;
                        odataTransformFactory.ApplyTransform = this.ApplyPayloadTransformations.Value;
                    }

                    MemoryStream memoryStream  = new MemoryStream(TestReaderUtils.GetPayload(testConfiguration, this.PayloadNormalizers, this.settings, this.PayloadElement));
                    TestStream   messageStream = new BatchReaderTestStream(memoryStream);
                    if (testConfiguration.Synchronous)
                    {
                        messageStream.FailAsynchronousCalls = true;
                    }
                    else
                    {
                        messageStream.FailSynchronousCalls = true;
                    }

                    TestMessage testMessage = TestReaderUtils.CreateInputMessageFromStream(
                        messageStream,
                        testConfiguration,
                        this.PayloadElement.GetPayloadKindFromPayloadElement(),
                        this.PayloadElement.GetCustomContentTypeHeader(),
                        this.UrlResolver);

                    return(testMessage);
                }
                finally
                {
                    if (this.ApplyPayloadTransformations.HasValue && odataTransformFactory != null)
                    {
                        odataTransformFactory.ApplyTransform = originalApplyTransformValue;
                    }
                }
            }
コード例 #2
0
            /// <summary>
            /// Called to create the input message for the reader test.
            /// </summary>
            /// <param name="testConfiguration">The test configuration.</param>
            /// <returns>The newly created test message to use.</returns>
            protected override TestMessage CreateInputMessage(ReaderTestConfiguration testConfiguration)
            {
                bool originalApplyTransformValue = false;
                var odataTransformFactory = this.settings.PayloadTransformFactory as ODataLibPayloadTransformFactory;

                try
                {
                    if (this.ApplyPayloadTransformations.HasValue && odataTransformFactory != null)
                    {
                        originalApplyTransformValue = odataTransformFactory.ApplyTransform;
                        odataTransformFactory.ApplyTransform = this.ApplyPayloadTransformations.Value;
                    }

                    MemoryStream memoryStream = new MemoryStream(TestReaderUtils.GetPayload(testConfiguration,this.PayloadNormalizers, this.settings, this.PayloadElement));
                    TestStream messageStream = new BatchReaderTestStream(memoryStream);
                    if (testConfiguration.Synchronous)
                    {
                        messageStream.FailAsynchronousCalls = true;
                    }
                    else
                    {
                        messageStream.FailSynchronousCalls = true;
                    }

                    TestMessage testMessage = TestReaderUtils.CreateInputMessageFromStream(
                        messageStream,
                        testConfiguration,
                        this.PayloadElement.GetPayloadKindFromPayloadElement(),
                        this.PayloadElement.GetCustomContentTypeHeader(),
                        this.UrlResolver);

                    return testMessage;
                }
                finally
                {
                    if (this.ApplyPayloadTransformations.HasValue && odataTransformFactory != null)
                    {
                        odataTransformFactory.ApplyTransform = originalApplyTransformValue;
                    }
                }
            }