Example #1
0
        public void EntityReferenceLinkErrorTest()
        {
            string resultUriString = "http://odata.org/linkresult";
            ODataEntityReferenceLink resultLink = new ODataEntityReferenceLink {
                Url = new Uri(resultUriString)
            };

            PayloadWriterTestDescriptor <ODataEntityReferenceLink>[] testCases = new PayloadWriterTestDescriptor <ODataEntityReferenceLink>[]
            {
                new PayloadWriterTestDescriptor <ODataEntityReferenceLink>(this.Settings, resultLink, (string)null, (string)null),
            };

            this.CombinatorialEngineProvider.RunCombinations(
                testCases,
                this.WriterTestConfigurationProvider.ExplicitFormatConfigurationsWithIndent,
                TestWriterUtils.InvalidSettingSelectors,
                (testCase, testConfiguration, selector) =>
            {
                testConfiguration = testConfiguration.Clone();
                testConfiguration.MessageWriterSettings.SetServiceDocumentUri(ServiceDocumentUri);

                if (testConfiguration.Format == ODataFormat.Json)
                {
                    testCase.Model = CreateModelWithNavProps();
                    var edmModel   = testCase.GetMetadataProvider();
                }

                TestWriterUtils.WriteWithStreamErrors(
                    testCase,
                    selector,
                    testConfiguration,
                    (messageWriter) => messageWriter.WriteEntityReferenceLink(testCase.PayloadItems.Single()),
                    this.Assert);
            });
        }
Example #2
0
        public void EntityReferenceLinksErrorTest()
        {
            string resultUri1String             = "http://odata.org/linkresult1";
            string resultUri2String             = "http://odata.org/linkresult2";
            string resultUri3String             = "http://odata.org/linkresult3";
            ODataEntityReferenceLink resultUri1 = new ODataEntityReferenceLink {
                Url = new Uri(resultUri1String)
            };
            ODataEntityReferenceLink resultUri2 = new ODataEntityReferenceLink {
                Url = new Uri(resultUri2String)
            };
            ODataEntityReferenceLink resultUri3 = new ODataEntityReferenceLink {
                Url = new Uri(resultUri3String)
            };

            var testCase = new ODataEntityReferenceLinks
            {
                Links = new ODataEntityReferenceLink[] { resultUri1, resultUri2, resultUri3 },
            };

            PayloadWriterTestDescriptor <ODataEntityReferenceLinks>[] testCases = new PayloadWriterTestDescriptor <ODataEntityReferenceLinks>[]
            {
                new PayloadWriterTestDescriptor <ODataEntityReferenceLinks>(
                    this.Settings,
                    testCase,
                    (testConfiguration) => new WriterTestExpectedResults(this.Settings.ExpectedResultSettings)
                {
                    // Top-level EntityReferenceLinks payload write requests are not allowed.
                    ExpectedException2 = testConfiguration.IsRequest ? ODataExpectedExceptions.ODataException("ODataMessageWriter_EntityReferenceLinksInRequestNotAllowed") : null
                })
            };

            this.CombinatorialEngineProvider.RunCombinations(
                testCases,
                TestWriterUtils.InvalidSettingSelectors,
                this.WriterTestConfigurationProvider.ExplicitFormatConfigurationsWithIndent,
                (descriptor, selector, testConfiguration) =>
            {
                testConfiguration = testConfiguration.Clone();
                testConfiguration.MessageWriterSettings.SetServiceDocumentUri(ServiceDocumentUri);

                if (testConfiguration.Format == ODataFormat.Json)
                {
                    descriptor.Model = CreateModelWithNavProps();
                    var edmModel     = descriptor.GetMetadataProvider();
                }

                TestWriterUtils.WriteWithStreamErrors(
                    descriptor,
                    selector,
                    testConfiguration,
                    (messageWriter) =>
                {
                    messageWriter.WriteEntityReferenceLinks(testCase);
                },
                    this.Assert);
            });
        }