Beispiel #1
0
        public void ODataBatchWriterUserExceptionInResponseTests()
        {
            var testCases = new BatchWriterTestDescriptor.InvocationAndOperationDescriptor[][]
            {
                new BatchWriterTestDescriptor.InvocationAndOperationDescriptor[]
                { 
                    BatchWriterUtils.UserException(),
                },

                new BatchWriterTestDescriptor.InvocationAndOperationDescriptor[]
                { 
                    BatchWriterUtils.StartBatch(),
                    BatchWriterUtils.UserException(),
                },

                new BatchWriterTestDescriptor.InvocationAndOperationDescriptor[]
                { 
                    BatchWriterUtils.StartBatch(),
                    BatchWriterUtils.QueryOperationResponse(200, string.Empty),
                    BatchWriterUtils.UserException(),
                },

                new BatchWriterTestDescriptor.InvocationAndOperationDescriptor[]
                { 
                    BatchWriterUtils.StartBatch(),
                    BatchWriterUtils.QueryOperationResponse(200, string.Empty),
                    BatchWriterUtils.EndBatch(),
                    BatchWriterUtils.UserException(),
                },

                new BatchWriterTestDescriptor.InvocationAndOperationDescriptor[] 
                {
                    BatchWriterUtils.StartBatch(),
                    BatchWriterUtils.UserException(),
                },

                new BatchWriterTestDescriptor.InvocationAndOperationDescriptor[] 
                {
                    BatchWriterUtils.StartBatch(),
                    BatchWriterUtils.StartChangeSet(),
                    BatchWriterUtils.UserException(),
                },

                new BatchWriterTestDescriptor.InvocationAndOperationDescriptor[] 
                {
                    BatchWriterUtils.StartBatch(),
                    BatchWriterUtils.StartChangeSet(),
                    BatchWriterUtils.ChangeSetResponse(200, "Sample payload"),
                    BatchWriterUtils.UserException(),
                },

                new BatchWriterTestDescriptor.InvocationAndOperationDescriptor[] 
                {
                    BatchWriterUtils.StartBatch(),
                    BatchWriterUtils.StartChangeSet(),
                    BatchWriterUtils.ChangeSetResponse(200, "Sample payload"),
                    BatchWriterUtils.EndChangeSet(),
                    BatchWriterUtils.UserException(),
                },

                new BatchWriterTestDescriptor.InvocationAndOperationDescriptor[] 
                {
                    BatchWriterUtils.StartBatch(),
                    BatchWriterUtils.StartChangeSet(),
                    BatchWriterUtils.ChangeSetResponse(200, "Sample payload"),
                    BatchWriterUtils.EndChangeSet(),
                    BatchWriterUtils.EndBatch(),
                    BatchWriterUtils.UserException(),
                },
            };

            Exception expectedException = new Exception("User code triggered an exception.");

            var testDescriptors = testCases.Select(tc => new BatchWriterTestDescriptor(this.Settings, tc, expectedException));

            this.CombinatorialEngineProvider.RunCombinations(
                testDescriptors,
                this.WriterTestConfigurationProvider.DefaultFormatConfigurationsWithIndent.Where(tc => !tc.IsRequest),
                this.WriterTestConfigurationProvider.ExplicitFormatConfigurationsWithIndent.Where(tc => !tc.IsRequest),
                (testDescriptor, testConfig, payloadTestConfig) =>
                {
                    testConfig = ModifyBatchTestConfig(testConfig, testDescriptor);
                    payloadTestConfig = ModifyPayloadTestConfig(payloadTestConfig, testDescriptor.BaseUri);
                    BatchWriterUtils.WriteAndVerifyBatchPayload(testDescriptor, testConfig, payloadTestConfig, this.Assert);
                });
        }
Beispiel #2
0
        public void ODataBatchWriterUserExceptionInRequestTests()
        {
            var testCases = new BatchWriterTestDescriptor.InvocationAndOperationDescriptor[][]
            {
                new BatchWriterTestDescriptor.InvocationAndOperationDescriptor[]
                { 
                    BatchWriterUtils.UserException(),
                },

                new BatchWriterTestDescriptor.InvocationAndOperationDescriptor[]
                { 
                    BatchWriterUtils.StartBatch(),
                    BatchWriterUtils.UserException(),
                },

                new BatchWriterTestDescriptor.InvocationAndOperationDescriptor[]
                { 
                    BatchWriterUtils.StartBatch(),
                    BatchWriterUtils.QueryOperation("GET", new Uri("http://www.odata.org/")),
                    BatchWriterUtils.UserException(),
                },

                new BatchWriterTestDescriptor.InvocationAndOperationDescriptor[]
                { 
                    BatchWriterUtils.StartBatch(),
                    BatchWriterUtils.QueryOperation("GET", new Uri("http://www.odata.org/")),
                    BatchWriterUtils.EndBatch(),
                    BatchWriterUtils.UserException(),
                },

                new BatchWriterTestDescriptor.InvocationAndOperationDescriptor[] 
                {
                    BatchWriterUtils.StartBatch(),
                    BatchWriterUtils.UserException(),
                },

                new BatchWriterTestDescriptor.InvocationAndOperationDescriptor[] 
                {
                    BatchWriterUtils.StartBatch(),
                    BatchWriterUtils.StartChangeSet(),
                    BatchWriterUtils.UserException(),
                },

                new BatchWriterTestDescriptor.InvocationAndOperationDescriptor[] 
                {
                    BatchWriterUtils.StartBatch(),
                    BatchWriterUtils.StartChangeSet(),
                    BatchWriterUtils.ChangeSetRequest("POST", new Uri("http://www.odata.org/OData/OData.svc/Products"), "1", null, "First sample payload."),
                    BatchWriterUtils.UserException(),
                },

                new BatchWriterTestDescriptor.InvocationAndOperationDescriptor[] 
                {
                    BatchWriterUtils.StartBatch(),
                    BatchWriterUtils.StartChangeSet(),
                    BatchWriterUtils.ChangeSetRequest("POST", new Uri("http://www.odata.org/OData/OData.svc/Products"), "1", null, "First sample payload."),
                    BatchWriterUtils.EndChangeSet(),
                    BatchWriterUtils.UserException(),
                },

                new BatchWriterTestDescriptor.InvocationAndOperationDescriptor[] 
                {
                    BatchWriterUtils.StartBatch(),
                    BatchWriterUtils.StartChangeSet(),
                    BatchWriterUtils.ChangeSetRequest("POST", new Uri("http://www.odata.org/OData/OData.svc/Products"), "1", null, "First sample payload."),
                    BatchWriterUtils.EndChangeSet(),
                    BatchWriterUtils.EndBatch(),
                    BatchWriterUtils.UserException(),
                },
            };

            Exception expectedException = new Exception("User code triggered an exception.");

            var testDescriptors = testCases.Select(tc => new BatchWriterTestDescriptor(this.Settings, tc, expectedException));

            this.CombinatorialEngineProvider.RunCombinations(
                testDescriptors,
                this.WriterTestConfigurationProvider.DefaultFormatConfigurationsWithIndent.Where(tc => tc.IsRequest),
                this.WriterTestConfigurationProvider.ExplicitFormatConfigurationsWithIndent.Where(tc => tc.IsRequest),
                (testDescriptor, testConfig, payloadTestConfig) =>
                {
                    testConfig = ModifyBatchTestConfig(testConfig, testDescriptor);
                    payloadTestConfig = ModifyPayloadTestConfig(payloadTestConfig, testDescriptor.BaseUri);
                    BatchWriterUtils.WriteAndVerifyBatchPayload(testDescriptor, testConfig, payloadTestConfig, this.Assert);
                });
        }