/// <summary> /// Creates a set of metadata reader test descriptors. /// </summary> /// <param name="settings">The test descriptor settings to use.</param> /// <returns>List of test descriptors with metadata documents as payload.</returns> public static IEnumerable<MetadataReaderTestDescriptor> CreateMetadataDocumentReaderDescriptors(MetadataReaderTestDescriptor.Settings settings) { return Microsoft.Test.OData.Utils.Metadata.TestModels.CreateModels().Select(m => new MetadataReaderTestDescriptor(settings) { PayloadEdmModel = m }); }
/// <summary> /// Copy constructor. /// </summary> /// <param name="other">The other metadata test descriptor to copy</param> public MetadataReaderTestDescriptor(MetadataReaderTestDescriptor other) : base(other) { this.settings = other.settings; this.PayloadEdmModel = other.PayloadEdmModel; this.ExpectedPayloadEdmModel = other.ExpectedPayloadEdmModel; this.ExpectedException = other.ExpectedException; this.ContentType = other.ContentType; }
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.AtomFormatConfigurations.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); }); }