예제 #1
0
        public void InStreamJsonLightErrorTest()
        {
            IEnumerable <PayloadReaderTestDescriptor> testDescriptors = PayloadReaderTestDescriptorGenerator.CreateErrorReaderTestDescriptors(this.Settings);

            // convert the payload element to a JSON representation usable for in-stream error testing
            testDescriptors = testDescriptors.Select(td =>
            {
                AnnotatedPayloadElementToJsonLightConverter payloadElementToJsonConverter = new AnnotatedPayloadElementToJsonLightConverter();
                JsonObject jsonObject = (JsonObject)payloadElementToJsonConverter.ConvertToJsonLightValue(td.PayloadElement);
                Debug.Assert(td.ExpectedException == null, "Don't expect errors for regular payloads (without annotation).");

                return(new PayloadReaderTestDescriptor(td)
                {
                    PayloadElement = td.PayloadElement.JsonRepresentation(jsonObject)
                });
            });

            testDescriptors = testDescriptors.Select(td => td.ToInStreamErrorTestDescriptor(ODataFormat.Json));

            this.CombinatorialEngineProvider.RunCombinations(
                testDescriptors,
                this.ReaderTestConfigurationProvider.JsonLightFormatConfigurations.Where(tc => !tc.IsRequest),
                (testDescriptor, testConfiguration) =>
            {
                // These descriptors are already tailored specifically for Json Light and
                // do not require normalization.
                testDescriptor.TestDescriptorNormalizers.Clear();
                testDescriptor.RunTest(testConfiguration);
            });
        }
예제 #2
0
        public void TopLevelErrorReaderTest()
        {
            IEdmModel model = Microsoft.Test.OData.Utils.Metadata.TestModels.BuildTestModel();

            // Use some standard complex value payloads first
            IEnumerable <PayloadReaderTestDescriptor> testDescriptors = PayloadReaderTestDescriptorGenerator.CreateErrorReaderTestDescriptors(this.Settings);

            // make sure reading errors works with and without model
            testDescriptors = testDescriptors.Concat(testDescriptors.Select(td => new PayloadReaderTestDescriptor(td)
            {
                PayloadEdmModel = model
            }));

            // add the normalizer for ATOM error payloads
            testDescriptors = testDescriptors.Select(td =>
            {
                td.ExpectedResultNormalizers.Add(
                    tc => (Func <ODataPayloadElement, ODataPayloadElement>)null);
                return(td);
            });

            this.CombinatorialEngineProvider.RunCombinations(
                testDescriptors,
                this.ReaderTestConfigurationProvider.ExplicitFormatConfigurations,
                (testDescriptor, testConfiguration) =>
            {
                testDescriptor.RunTest(testConfiguration);
            });
        }
예제 #3
0
        public void InStreamAtomErrorTest()
        {
            IEnumerable <PayloadReaderTestDescriptor> testDescriptors = PayloadReaderTestDescriptorGenerator.CreateErrorReaderTestDescriptors(this.Settings);

            // convert the payload element to an Xml representation usable for in-stream error testing
            testDescriptors = testDescriptors.Select(td =>
            {
                XElement xmlPayload = this.PayloadElementToXmlConverter.ConvertToXml(td.PayloadElement);
                Debug.Assert(td.ExpectedException == null, "Don't expect errors for regular payloads (without annotation).");

                return(new PayloadReaderTestDescriptor(td)
                {
                    PayloadElement = td.PayloadElement.XmlRepresentation(xmlPayload)
                });
            });

            testDescriptors = testDescriptors.Select(td => td.ToInStreamErrorTestDescriptor(ODataFormat.Atom));

            this.CombinatorialEngineProvider.RunCombinations(
                testDescriptors,
                this.ReaderTestConfigurationProvider.AtomFormatConfigurations.Where(tc => !tc.IsRequest),
                (testDescriptor, testConfiguration) =>
            {
                testDescriptor.RunTest(testConfiguration);
            });
        }