Esempio n. 1
0
        public void CreateCollectionReaderArgumentTest()
        {
            IEdmEntityType      entityType                         = null;
            IEdmComplexType     complexType                        = null;
            IEdmModel           model                              = this.CreateTestMetadata(out entityType, out complexType);
            IEdmEntityContainer defaultContainer                   = model.FindEntityContainer("TestNS.TestContainer");
            IEdmOperationImport primitiveValueFunctionImport       = defaultContainer.FindOperationImports("PrimitiveValueFunctionImport").Single();
            IEdmOperationImport collectionOfEntitiesFunctionImport = defaultContainer.FindOperationImports("CollectionOfEntitiesFunctionImport").Single();

            this.CombinatorialEngineProvider.RunCombinations(
                this.ReaderTestConfigurationProvider.ExplicitFormatConfigurations,
                (testConfiguration) =>
            {
                TestMessage message = TestReaderUtils.CreateInputMessageFromStream(new TestStream(), testConfiguration);
                ODataMessageReaderTestWrapper messageReader = TestReaderUtils.CreateMessageReader(message, null, testConfiguration);
                this.Assert.ExpectedException(
                    () => messageReader.CreateODataCollectionReader(new EdmComplexTypeReference(complexType, false)),
                    ODataExpectedExceptions.ArgumentException("ODataMessageReader_ExpectedTypeSpecifiedWithoutMetadata", "expectedItemTypeReference"),
                    this.ExceptionVerifier);

                messageReader = TestReaderUtils.CreateMessageReader(message, model, testConfiguration);
                this.Assert.ExpectedException(
                    () => messageReader.CreateODataCollectionReader(new EdmEntityTypeReference(entityType, false)),
                    ODataExpectedExceptions.ArgumentException("ODataMessageReader_ExpectedCollectionTypeWrongKind", "Entity"),
                    this.ExceptionVerifier);

                messageReader = TestReaderUtils.CreateMessageReader(message, model, testConfiguration);
                this.Assert.ExpectedException(
                    () => messageReader.CreateODataCollectionReader(collectionOfEntitiesFunctionImport),
                    ODataExpectedExceptions.ArgumentException("ODataMessageReader_ExpectedCollectionTypeWrongKind", "Entity"),
                    this.ExceptionVerifier);
            });
        }
        /// <summary>
        /// Called to write the payload to the specified <paramref name="messageWriter"/>.
        /// </summary>
        /// <param name="messageWriter">The <see cref="ODataMessageWriterTestWrapper"/> to use for writing the payload.</param>
        /// <param name="testConfiguration">The test configuration to generate the payload for.</param>
        protected override void WritePayload(ODataMessageWriterTestWrapper messageWriter, WriterTestConfiguration testConfiguration)
        {
            Debug.Assert(this.messageStream != null, "Streaming test stream must have been created.");
            TestMessage testMessage = this.CreateInputMessageFromStream((TestStream)this.messageStream, testConfiguration, this.PayloadKind, string.Empty, this.UrlResolver);

            testMessage.SetContentType(testConfiguration.Format, this.PayloadKind);

            Exception exception = TestExceptionUtils.RunCatching(() =>
            {
                ODataMessageReaderSettings readerSettings  = this.settings.MessageReaderSettings.Clone();
                readerSettings.EnableMessageStreamDisposal = testConfiguration.MessageWriterSettings.EnableMessageStreamDisposal;

                ReaderTestConfiguration readerConfig = new ReaderTestConfiguration(
                    testConfiguration.Format,
                    readerSettings,
                    testConfiguration.IsRequest,
                    testConfiguration.Synchronous);

                IEdmModel model = this.GetMetadataProvider();
                using (ODataMessageReaderTestWrapper messageReaderWrapper = TestReaderUtils.CreateMessageReader(testMessage, model, readerConfig))
                {
                    ODataPayloadElementToObjectModelConverter payloadElementToOMConverter = new ODataPayloadElementToObjectModelConverter(!testConfiguration.IsRequest);
                    ObjectModelToPayloadElementConverter reverseConverter = new ObjectModelToPayloadElementConverter();
                    ObjectModelWriteReadStreamer streamer = new ObjectModelWriteReadStreamer();

                    this.readObject = reverseConverter.Convert(streamer.WriteMessage(messageWriter, messageReaderWrapper, this.PayloadKind, payloadElementToOMConverter.Convert(this.PayloadElement)), !testConfiguration.IsRequest);
                }
            });
        }
        public void ContentTypeHeaderParsingErrorTest()
        {
            var testCases = new ContentTypeTestCase[]
            {
                new ContentTypeTestCase
                {
                    ContentType       = null,
                    ExpectedException = ODataExpectedExceptions.ODataContentTypeException("ODataMessageReader_NoneOrEmptyContentTypeHeader")
                },
                new ContentTypeTestCase
                {
                    ContentType       = string.Empty,
                    ExpectedException = ODataExpectedExceptions.ODataContentTypeException("ODataMessageReader_NoneOrEmptyContentTypeHeader")
                },
                new ContentTypeTestCase
                {
                    ContentType       = ";foo=bar",
                    ExpectedException = ODataExpectedExceptions.ODataContentTypeException("HttpUtils_MediaTypeRequiresSlash", ";foo=bar")
                },
                new ContentTypeTestCase
                {
                    ContentType       = "application/*",
                    ExpectedException = ODataExpectedExceptions.ODataContentTypeException("ODataMessageReader_WildcardInContentType", "application/*")
                },
                new ContentTypeTestCase
                {
                    ContentType       = "*/*",
                    ExpectedException = ODataExpectedExceptions.ODataContentTypeException("ODataMessageReader_WildcardInContentType", "*/*")
                },
                new ContentTypeTestCase
                {
                    ContentType       = "application/json, application/xml",
                    ExpectedException = ODataExpectedExceptions.ODataContentTypeException("MediaTypeUtils_NoOrMoreThanOneContentTypeSpecified", "application/json, application/xml")
                },
            };

            this.CombinatorialEngineProvider.RunCombinations(
                testCases,
                this.ReaderTestConfigurationProvider.AllFormatConfigurations.Where(tc => tc.Format != ODataFormat.Json),
                (testCase, testConfiguration) =>
            {
                // create a message reader and call GetFormat; this should fail with the expected error message
                TestMessage testMessage = TestReaderUtils.CreateInputMessageFromStream(new TestStream(), testConfiguration);
                testMessage.SetHeader(Microsoft.OData.Core.ODataConstants.ContentTypeHeader, testCase.ContentType);
                testMessage.SetHeader(Microsoft.OData.Core.ODataConstants.ContentLengthHeader, testCase.ContentLength.ToString());

                TestExceptionUtils.ExpectedException(
                    this.Assert,
                    () =>
                {
                    using (ODataMessageReaderTestWrapper messageReader = TestReaderUtils.CreateMessageReader(testMessage, null, testConfiguration))
                    {
                        ODataFormat actualFormat = messageReader.DetectPayloadKind().Single().Format;
                    }
                },
                    testCase.ExpectedException,
                    this.ExceptionVerifier);
            });
        }
Esempio n. 4
0
        public override void RunTest(ReaderTestConfiguration testConfiguration)
        {
            //TODO: Use Logger to verify result, right now this change is only to unblock writer testcase checkin
            BaselineLogger logger = null;

            if (this.ShouldSkipForTestConfiguration(testConfiguration))
            {
                return;
            }

            var originalPayload = this.PayloadElement;

            this.PayloadElement = this.PayloadElement.DeepCopy();

            // Create messages (payload gets serialized in createInputMessage)
            TestMessage readerMessage = this.CreateInputMessage(testConfiguration);
            var         settings      = new ODataMessageWriterSettings()
            {
                Version = testConfiguration.Version,
                BaseUri = testConfiguration.MessageReaderSettings.BaseUri,
                EnableMessageStreamDisposal = testConfiguration.MessageReaderSettings.EnableMessageStreamDisposal,
            };

            settings.SetContentType(testConfiguration.Format);

            WriterTestConfiguration writerConfig  = new WriterTestConfiguration(testConfiguration.Format, settings, testConfiguration.IsRequest, testConfiguration.Synchronous);
            TestMessage             writerMessage = TestWriterUtils.CreateOutputMessageFromStream(new TestStream(new MemoryStream()), writerConfig, this.PayloadKind, String.Empty, this.UrlResolver);

            IEdmModel model = this.GetMetadataProvider(testConfiguration);
            WriterTestExpectedResults expectedResult = this.GetExpectedResult(writerConfig);

            ExceptionUtilities.Assert(expectedResult != null, "The expected result could not be determined for the test. Did you specify it?");

            Exception exception = TestExceptionUtils.RunCatching(() =>
            {
                using (ODataMessageReaderTestWrapper messageReaderWrapper = TestReaderUtils.CreateMessageReader(readerMessage, model, testConfiguration))
                    using (ODataMessageWriterTestWrapper messageWriterWrapper = TestWriterUtils.CreateMessageWriter(writerMessage, model, writerConfig, this.settings.Assert))
                    {
                        var streamer = new ObjectModelReadWriteStreamer();
                        streamer.StreamMessage(messageReaderWrapper, messageWriterWrapper, this.PayloadKind, writerConfig);
                        expectedResult.VerifyResult(writerMessage, this.PayloadKind, writerConfig, logger);
                    }
            });

            this.PayloadElement = originalPayload;

            try
            {
                expectedResult.VerifyException(exception);
            }
            catch (Exception)
            {
                this.TraceFailureInformation(testConfiguration);
                throw;
            }
        }
Esempio n. 5
0
        public void CreateParameterReaderTest()
        {
            IEdmOperationImport functionImport;
            IEdmModel           model = this.CreateTestMetadata(out functionImport);

            var testConfigurations = this.ReaderTestConfigurationProvider.JsonLightFormatConfigurations.Where(c => c.IsRequest);

            this.CombinatorialEngineProvider.RunCombinations(
                testConfigurations,
                (testConfiguration) =>
            {
                TestMessage message;
                ODataMessageReaderTestWrapper messageReader;

                // Specifying a non-null functionImport without an EdmModel should fail.
                message       = TestReaderUtils.CreateInputMessageFromStream(new TestStream(), testConfiguration, ODataPayloadKind.Parameter, /*customContentTypeHeader*/ null, /*urlResolver*/ null);
                messageReader = TestReaderUtils.CreateMessageReader(message, null, testConfiguration);
                this.Assert.ExpectedException(
                    () => messageReader.CreateODataParameterReader(functionImport),
                    ODataExpectedExceptions.ArgumentException("ODataMessageReader_OperationSpecifiedWithoutMetadata", "operation"),
                    this.ExceptionVerifier);

                // Specifying a null functionImport should fail.
                message       = TestReaderUtils.CreateInputMessageFromStream(new TestStream(), testConfiguration, ODataPayloadKind.Parameter, /*customContentTypeHeader*/ null, /*urlResolver*/ null);
                messageReader = TestReaderUtils.CreateMessageReader(message, model, testConfiguration);
                this.Assert.ExpectedException(
                    () => messageReader.CreateODataParameterReader(null),
                    ODataExpectedExceptions.ArgumentNullException("ODataJsonLightInputContext_OperationCannotBeNullForCreateParameterReader", "operation"),
                    this.ExceptionVerifier);

                message       = TestReaderUtils.CreateInputMessageFromStream(new TestStream(), testConfiguration, ODataPayloadKind.Parameter, /*customContentTypeHeader*/ null, /*urlResolver*/ null);
                messageReader = TestReaderUtils.CreateMessageReader(message, model, testConfiguration);
                if (testConfiguration.IsRequest)
                {
                    // CreateParameterReader should succeed.
                    messageReader.CreateODataParameterReader(functionImport);
                }
                else
                {
                    // CreateODataParameterReader on a response message should fail.
                    this.Assert.ExpectedException(
                        () => messageReader.CreateODataParameterReader(functionImport),
                        ODataExpectedExceptions.ODataException("ODataMessageReader_ParameterPayloadInResponse"),
                        this.ExceptionVerifier);
                }
            });
        }
Esempio n. 6
0
        public void CreateResourceReaderArgumentTest()
        {
            IEdmEntityType  entityType  = null;
            IEdmComplexType complexType = null;
            IEdmModel       model       = this.CreateTestMetadata(out entityType, out complexType);

            this.CombinatorialEngineProvider.RunCombinations(
                this.ReaderTestConfigurationProvider.ExplicitFormatConfigurations,
                (testConfiguration) =>
            {
                TestMessage message = TestReaderUtils.CreateInputMessageFromStream(new TestStream(), testConfiguration);
                ODataMessageReaderTestWrapper messageReader = TestReaderUtils.CreateMessageReader(message, null, testConfiguration);
                this.Assert.ExpectedException(
                    () => messageReader.CreateODataResourceReader(entityType),
                    ODataExpectedExceptions.ArgumentException("ODataMessageReader_ExpectedTypeSpecifiedWithoutMetadata", "resourceType"),
                    this.ExceptionVerifier);
            });
        }
Esempio n. 7
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;
                    }
                }
            }
Esempio n. 8
0
        /// <summary>
        /// Creates an ODataParameterReader with the given input.
        /// </summary>
        /// <param name="model">Model containing the function import.</param>
        /// <param name="functionImport">function import whose parameters are being read.</param>
        /// <param name="testConfiguration">test configuration.</param>
        /// <param name="payload">optional parameter payload.</param>
        /// <returns>Returns the created ODataParameterReader</returns>
        internal static ODataParameterReaderTestWrapper CreateODataParameterReader(IEdmModel model, IEdmOperationImport functionImport, ReaderTestConfiguration testConfiguration, string payload = null)
        {
            // TODO: ODataLib test item: Add new ODataPayloadElement for parameters payload
            // Once the bug is fixed, we should generate the parameters payload from the new ODataPayloadElement to make
            // tests in this file format agnostic.
            TestStream messageStream;

            if (payload != null)
            {
                messageStream = new TestStream(new MemoryStream(Encoding.UTF8.GetBytes(payload)));
            }
            else
            {
                messageStream = new TestStream();
            }

            TestMessage message = TestReaderUtils.CreateInputMessageFromStream(messageStream, testConfiguration, ODataPayloadKind.Parameter, /*customContentTypeHeader*/ null, /*urlResolver*/ null);
            ODataMessageReaderTestWrapper messageReader = TestReaderUtils.CreateMessageReader(message, model, testConfiguration);

            return(messageReader.CreateODataParameterReader(functionImport));
        }
Esempio n. 9
0
            protected override TestMessage CreateInputMessage(ReaderTestConfiguration testConfiguration)
            {
                MemoryStream memoryStream  = new MemoryStream(this.RawMessage);
                TestStream   messageStream = new TestStream(memoryStream);

                if (testConfiguration.Synchronous)
                {
                    messageStream.FailAsynchronousCalls = true;
                }
                else
                {
                    messageStream.FailSynchronousCalls = true;
                }

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

                return(testMessage);
            }
Esempio n. 10
0
        public void SyncAsyncMismatchTest()
        {
            var model = new EdmModel();
            var payloadDescriptors = Test.OData.Utils.ODataLibTest.TestFeeds.GetFeeds(model, true /*withTypeNames*/);
            var testDescriptors    = this.PayloadDescriptorsToReaderDescriptors(payloadDescriptors);

            this.CombinatorialEngineProvider.RunCombinations(
                testDescriptors,
                this.ReaderTestConfigurationProvider.ExplicitFormatConfigurations,
                (testDescriptor, testConfiguration) =>
            {
                var message = TestReaderUtils.CreateInputMessage(testConfiguration, testDescriptor, this.Settings, false);
                message.IgnoreSynchronousError            = true;
                message.TestStream.IgnoreSynchronousError = true;

                Exception exception = TestExceptionUtils.RunCatching(() =>
                {
                    using (ODataMessageReaderTestWrapper messageReaderWrapper = TestReaderUtils.CreateMessageReader(message, model, testConfiguration))
                    {
                        var feedReader = messageReaderWrapper.MessageReader.CreateODataResourceSetReader(model.EntityContainer.FindEntitySet("MyBaseType"), model.EntityTypes().FirstOrDefault());
                        if (testConfiguration.Synchronous)
                        {
                            feedReader.Read();
                            feedReader.ReadAsync();
                        }
                        else
                        {
                            feedReader.ReadAsync();
                            feedReader.Read();
                        }
                    }
                });

                var expected = ODataExpectedExceptions.ODataException("ODataReaderCore_AsyncCallOnSyncReader");
                ExceptionVerifier.VerifyExceptionResult(expected, exception);
            });
        }
Esempio n. 11
0
        public void ReadPropertyArgumentTest()
        {
            IEdmEntityType      entityType  = null;
            IEdmComplexType     complexType = null;
            IEdmModel           model       = this.CreateTestMetadata(out entityType, out complexType);
            IEdmEntityContainer container   = model.FindEntityContainer("TestContainer");
            IEdmOperationImport entityValueFunctionImport           = container.FindOperationImports("EntityValueFunctionImport").Single();
            IEdmOperationImport entityCollectionValueFunctionImport = container.FindOperationImports("CollectionOfEntitiesFunctionImport").Single();

            IEdmStructuralProperty entityValueStructuralProperty           = (IEdmStructuralProperty)complexType.FindProperty("EntityProp");
            IEdmStructuralProperty entityCollectionValueStructuralProperty = (IEdmStructuralProperty)complexType.FindProperty("EntityCollectionProp");

            this.CombinatorialEngineProvider.RunCombinations(
                this.ReaderTestConfigurationProvider.ExplicitFormatConfigurations,
                (testConfiguration) =>
            {
                TestMessage message = TestReaderUtils.CreateInputMessageFromStream(new TestStream(), testConfiguration);

                ODataMessageReaderTestWrapper messageReader = TestReaderUtils.CreateMessageReader(message, null, testConfiguration);
                this.Assert.ExpectedException(
                    () => messageReader.ReadProperty(new EdmComplexTypeReference(complexType, false)),
                    ODataExpectedExceptions.ArgumentException("ODataMessageReader_ExpectedTypeSpecifiedWithoutMetadata", "expectedPropertyTypeReference"),
                    this.ExceptionVerifier);

                messageReader = TestReaderUtils.CreateMessageReader(message, model, testConfiguration);
                this.Assert.ExpectedException(
                    () => messageReader.ReadProperty(new EdmEntityTypeReference(entityType, false)),
                    ODataExpectedExceptions.ArgumentException("ODataMessageReader_ExpectedPropertyTypeEntityKind"),
                    this.ExceptionVerifier);

                messageReader = TestReaderUtils.CreateMessageReader(message, model, testConfiguration);
                this.Assert.ExpectedException(
                    () => messageReader.ReadProperty(new EdmCollectionType(new EdmEntityTypeReference(entityType, false)).ToTypeReference()),
                    ODataExpectedExceptions.ArgumentException("ODataMessageReader_ExpectedPropertyTypeEntityCollectionKind"),
                    this.ExceptionVerifier);

                messageReader = TestReaderUtils.CreateMessageReader(message, model, testConfiguration);
                this.Assert.ExpectedException(
                    () => messageReader.ReadProperty(entityValueFunctionImport),
                    ODataExpectedExceptions.ArgumentException("ODataMessageReader_ExpectedPropertyTypeEntityKind"),
                    this.ExceptionVerifier);

                messageReader = TestReaderUtils.CreateMessageReader(message, model, testConfiguration);
                this.Assert.ExpectedException(
                    () => messageReader.ReadProperty(entityCollectionValueFunctionImport),
                    ODataExpectedExceptions.ArgumentException("ODataMessageReader_ExpectedPropertyTypeEntityCollectionKind"),
                    this.ExceptionVerifier);

                messageReader = TestReaderUtils.CreateMessageReader(message, model, testConfiguration);
                this.Assert.ExpectedException(
                    () => messageReader.ReadProperty(entityValueStructuralProperty),
                    ODataExpectedExceptions.ArgumentException("ODataMessageReader_ExpectedPropertyTypeEntityKind"),
                    this.ExceptionVerifier);

                messageReader = TestReaderUtils.CreateMessageReader(message, model, testConfiguration);
                this.Assert.ExpectedException(
                    () => messageReader.ReadProperty(entityCollectionValueStructuralProperty),
                    ODataExpectedExceptions.ArgumentException("ODataMessageReader_ExpectedPropertyTypeEntityCollectionKind"),
                    this.ExceptionVerifier);
            });
        }
Esempio n. 12
0
        public void BatchContentTypeHeaderParsingTest()
        {
            IEnumerable <ContentTypeTestCase> testCases = new ContentTypeTestCase[]
            {
                // correct batch content type
                new ContentTypeTestCase
                {
                    ContentType    = "multipart/mixed;boundary=--aa_bb_cc--",
                    ExpectedFormat = ODataFormat.Batch,
                },

                // missing batch boundary
                new ContentTypeTestCase
                {
                    ContentType       = "multipart/mixed",
                    ExpectedFormat    = ODataFormat.Batch,
                    ExpectedException = ODataExpectedExceptions.ODataException("MediaTypeUtils_BoundaryMustBeSpecifiedForBatchPayloads", "multipart/mixed", "boundary")
                },

                // multiple batch boundary parameters
                new ContentTypeTestCase
                {
                    ContentType       = "multipart/mixed;boundary=boundary1;boundary=boundary2",
                    ExpectedFormat    = ODataFormat.Batch,
                    ExpectedException = ODataExpectedExceptions.ODataException("MediaTypeUtils_BoundaryMustBeSpecifiedForBatchPayloads", "multipart/mixed;boundary=boundary1;boundary=boundary2", "boundary")
                },

                // invalid batch content types
                new ContentTypeTestCase
                {
                    ContentType       = "multipart/bar",
                    ExpectedFormat    = ODataFormat.Batch,
                    ExpectedException = ODataExpectedExceptions.ODataContentTypeException("MediaTypeUtils_CannotDetermineFormatFromContentType", TestMediaTypeUtils.GetSupportedMediaTypes(ODataPayloadKind.Batch), "multipart/bar")
                },
                new ContentTypeTestCase
                {
                    ContentType       = "foo/mixed",
                    ExpectedFormat    = ODataFormat.Batch,
                    ExpectedException = ODataExpectedExceptions.ODataContentTypeException("MediaTypeUtils_CannotDetermineFormatFromContentType", TestMediaTypeUtils.GetSupportedMediaTypes(ODataPayloadKind.Batch), "foo/mixed")
                },
                new ContentTypeTestCase
                {
                    ContentType       = "abc/pqr",
                    ExpectedFormat    = ODataFormat.Batch,
                    ExpectedException = ODataExpectedExceptions.ODataContentTypeException("MediaTypeUtils_CannotDetermineFormatFromContentType", TestMediaTypeUtils.GetSupportedMediaTypes(ODataPayloadKind.Batch), "abc/pqr")
                },
                new ContentTypeTestCase
                {
                    ContentType       = ApplicationJson,
                    ExpectedFormat    = ODataFormat.Batch,
                    ExpectedException = ODataExpectedExceptions.ODataContentTypeException("MediaTypeUtils_CannotDetermineFormatFromContentType", TestMediaTypeUtils.GetSupportedMediaTypes(ODataPayloadKind.Batch), ApplicationJson)
                }
            };

            this.CombinatorialEngineProvider.RunCombinations(
                testCases,
                this.ReaderTestConfigurationProvider.DefaultFormatConfigurations,
                (testCase, testConfiguration) =>
            {
                // create a message reader and call GetFormat; this should fail with the expected error message
                TestMessage testMessage = TestReaderUtils.CreateInputMessageFromStream(new TestStream(), testConfiguration);
                testMessage.SetHeader(Microsoft.OData.Core.ODataConstants.ContentTypeHeader, testCase.ContentType);

                TestExceptionUtils.ExpectedException(
                    this.Assert,
                    () =>
                {
                    using (ODataMessageReaderTestWrapper messageReader = TestReaderUtils.CreateMessageReader(testMessage, null, testConfiguration))
                    {
                        messageReader.CreateODataBatchReader();
                        ODataFormat actualFormat = ODataUtils.GetReadFormat(messageReader.MessageReader);
                        this.Assert.AreEqual(testCase.ExpectedFormat, actualFormat, "Formats don't match.");
                    }
                },
                    testCase.ExpectedException,
                    this.ExceptionVerifier);
            });
        }