public void MetadataDocumentReaderTest()
        {
            // TODO: add more interesting metadata payloads
            IEnumerable <MetadataReaderTestDescriptor> metadataDescriptors = MetadataReaderTestDescriptorGenerator.CreateMetadataDocumentReaderDescriptors(this.Settings);

            MetadataReaderTestDescriptor[] manualDescriptors = new MetadataReaderTestDescriptor[]
            {
            };

            IEnumerable <MetadataReaderTestDescriptor> testDescriptors = metadataDescriptors.Concat(manualDescriptors);

            this.CombinatorialEngineProvider.RunCombinations(
                testDescriptors,
                this.ReaderTestConfigurationProvider.DefaultFormatConfigurations.Where(tc => !tc.IsRequest && tc.Synchronous),
                (testDescriptor, testConfiguration) => testDescriptor.RunTest(testConfiguration));
        }
        public void MetadataDocumentReaderContentTypeErrorTest()
        {
            MetadataReaderTestDescriptor[] errorDescriptors = new MetadataReaderTestDescriptor[]
            {
                new MetadataReaderTestDescriptor(this.Settings)
                {
                    PayloadEdmModel   = new EdmModel().Fixup(),
                    ContentType       = "application/unsupported",
                    ExpectedException = ODataExpectedExceptions.ODataContentTypeException("MediaTypeUtils_CannotDetermineFormatFromContentType", "application/xml", "application/unsupported"),
                },
            };

            this.CombinatorialEngineProvider.RunCombinations(
                errorDescriptors,
                this.ReaderTestConfigurationProvider.JsonLightFormatConfigurations.Where(tc => tc.Synchronous && !tc.IsRequest),
                (testDescriptor, testConfiguration) => testDescriptor.RunTest(testConfiguration));
        }
        private void RunMetadataMessageSizeLimitTests(IEdmModel model, MessageSizeLimitTestCase[] testCases)
        {
            this.CombinatorialEngineProvider.RunCombinations(
                testCases,
                this.ReaderTestConfigurationProvider.DefaultFormatConfigurations.Where(tc => !tc.IsRequest && tc.Synchronous),
                (testCase, testConfiguration) =>
            {
                int size = -1;
                if (testConfiguration.Format == ODataFormat.Atom && testCase.AtomSizes != null)
                {
                    size = testConfiguration.IsRequest ? testCase.AtomSizes.RequestSize : testCase.AtomSizes.ResponseSize;
                }
                else if (testConfiguration.Format == ODataFormat.Json && testCase.JsonLightSizes != null)
                {
                    size = testConfiguration.IsRequest ? testCase.JsonLightSizes.RequestSize : testCase.JsonLightSizes.ResponseSize;
                }
                else if (testCase.RawSizes != null)
                {
                    size = testConfiguration.IsRequest ? testCase.RawSizes.RequestSize : testCase.RawSizes.ResponseSize;
                }

                ExpectedException expectedException = size < 0
                        ? null
                        : ODataExpectedExceptions.ODataException("MessageStreamWrappingStream_ByteLimitExceeded", size.ToString(), testCase.MaxMessageSize.ToString());

                var testDescriptor = new MetadataReaderTestDescriptor(this.MetadataSettings)
                {
                    PayloadEdmModel   = model,
                    ExpectedException = expectedException,
                };

                if (testCase.MaxMessageSize > 0)
                {
                    testConfiguration = new ReaderTestConfiguration(testConfiguration);
                    testConfiguration.MessageReaderSettings.MessageQuotas.MaxReceivedMessageSize = testCase.MaxMessageSize;
                }

                testDescriptor.RunTest(testConfiguration);
            });
        }