public void ReadBatchWithHttpSimulatingStream() { EdmModel model = new EdmModel(); IEnumerable <PayloadTestDescriptor> batchRequestDescriptors = TestBatches.CreateBatchRequestTestDescriptors(this.RequestManager, model, /*withTypeNames*/ true); IEnumerable <PayloadReaderTestDescriptor> requestTestDescriptors = batchRequestDescriptors.Select(bd => (PayloadReaderTestDescriptor) new BatchMessageHttpSimulationTestDescriptor(this.PayloadReaderSettings) { PayloadDescriptor = bd, SkipTestConfiguration = tc => !tc.IsRequest || (tc.Format != ODataFormat.Json) }); IEnumerable <PayloadTestDescriptor> batchResponseDescriptors = TestBatches.CreateBatchResponseTestDescriptors(this.RequestManager, model, /*withTypeNames*/ true); IEnumerable <PayloadReaderTestDescriptor> responseTestDescriptors = batchResponseDescriptors.Select(bd => (PayloadReaderTestDescriptor) new BatchMessageHttpSimulationTestDescriptor(this.PayloadReaderSettings) { PayloadDescriptor = bd, SkipTestConfiguration = tc => tc.IsRequest || (tc.Format != ODataFormat.Json) }); IEnumerable <PayloadReaderTestDescriptor> testDescriptors = requestTestDescriptors.Concat(responseTestDescriptors); this.CombinatorialEngineProvider.RunCombinations( testDescriptors, this.ReaderTestConfigurationProvider.DefaultFormatConfigurations, (testDescriptor, testConfiguration) => { testDescriptor.RunTest(testConfiguration); }); }
/// <summary> /// Generates deterministic payloads for checkin run otherwise generates arbitrary payloads. /// </summary> /// <typeparam name="T">Must be a PayloadTestDescriptor.</typeparam> /// <param name="payload">Payload to generate payloads from. If checkin suite only the model will be used.</param> /// <returns>IEnumerable of generated payloads.</returns> public IEnumerable <T> GeneratePayloads <T>(T payload) where T : PayloadTestDescriptor { if (this.RunKind == TestRunKind.CheckinSuite) { return((IEnumerable <T>)TestBatches.CreateBatchRequestTestDescriptors(this.RequestManager, (EdmModel)payload.PayloadEdmModel, true) .Concat(TestBatches.CreateBatchResponseTestDescriptors(this.RequestManager, (EdmModel)payload.PayloadEdmModel, true))); } else { return(GenerateArbitraryPayloads(payload)); } }
public void BatchResponseMessageSizeLimitReadTest() { var model = new EdmModel(); PayloadTestDescriptor batchResponseDescriptor; var transformScope = this.Settings.PayloadTransformFactory.EmptyScope(); using (transformScope.Apply()) { batchResponseDescriptor = TestBatches.CreateBatchResponseTestDescriptors(this.RequestManager, model, /*withTypeNames*/ true).Last(); } ODataPayloadElement payload = batchResponseDescriptor.PayloadElement; model = (EdmModel)batchResponseDescriptor.PayloadEdmModel; var testCases = new MessageSizeLimitTestCase[] { // Single byte size should fail new MessageSizeLimitTestCase { MaxMessageSize = 1, RawSizes = new RequestResponseSizes { RequestSize = -1, ResponseSize = 4515 }, }, // Small number should fail new MessageSizeLimitTestCase { MaxMessageSize = 20, RawSizes = new RequestResponseSizes { RequestSize = -1, ResponseSize = 4515 }, }, // Large number should work new MessageSizeLimitTestCase { MaxMessageSize = 10000, }, // Default should work new MessageSizeLimitTestCase { MaxMessageSize = -1, }, }; this.RunRawMessageSizeLimitTests(model, payload, testCases, tc => tc.IsRequest || (tc.Format != ODataFormat.Json || tc.Format != ODataFormat.Atom)); }