public void XmlBaseUriHandlingTest() { var testCases = new XmlBaseUriTestCase[] { new XmlBaseUriTestCase { RelativeUri = "relative", XmlBaseUri = "http://odata.org/base", SettingsBaseUri = (string)null, ResultUri = "http://odata.org/relative", }, new XmlBaseUriTestCase { RelativeUri = "relative", XmlBaseUri = (string)null, SettingsBaseUri = (string)null, ResultUri = "http://odata.org/relative", }, new XmlBaseUriTestCase { RelativeUri = "relative", XmlBaseUri = "/baserelative/", SettingsBaseUri = "http://odata.org/base", ResultUri = "http://odata.org/baserelative/relative" }, new XmlBaseUriTestCase { RelativeUri = "relative", XmlBaseUri = string.Empty, SettingsBaseUri = "http://odata.org/", ResultUri = "http://odata.org/relative" }, new XmlBaseUriTestCase { RelativeUri = "relative", XmlBaseUri = "/baserelative/", SettingsBaseUri = "http://odata.org/base/", ResultUri = "http://odata.org/baserelative/relative" }, new XmlBaseUriTestCase { RelativeUri = "relative", XmlBaseUri = string.Empty, SettingsBaseUri = "http://odata.org/base/", ResultUri = "http://odata.org/base/relative" }, }; this.CombinatorialEngineProvider.RunCombinations( testCases, this.ReaderTestConfigurationProvider.AtomFormatConfigurations, TestReaderUtils.ODataBehaviorKinds, (testCase, testConfiguration, behavior) => { IEnumerable<PayloadReaderTestDescriptor> testDescriptors = new PayloadReaderTestDescriptor[] { // MLE with relative media source link new PayloadReaderTestDescriptor(this.Settings) { PayloadElement = PayloadBuilder.Entity().AsMediaLinkEntry().StreamSourceLink(testCase.ComputeExpectedResultUri(behavior, testConfiguration.Version, /*ignoredOnServer*/ true)) .XmlRepresentation("<entry xml:base='" + testCase.XmlBaseUri + "'><content src='" + testCase.RelativeUri +"'/></entry>"), ExpectedException = testCase.ComputeExpectedException(behavior, testConfiguration.Version, /*ignoredOnServer*/ true) }, // Navigation link with relative href new PayloadReaderTestDescriptor(this.Settings) { PayloadElement = PayloadBuilder.Entity() .NavigationProperty("NavLink", testCase.ComputeExpectedResultUri(behavior, testConfiguration.Version, /*ignoredOnServer*/ false)) .XmlRepresentation("<entry xml:base='" + testCase.XmlBaseUri + "'><content /><link rel='http://docs.oasis-open.org/odata/ns/related/NavLink' type='application/atom+xml;type=entry' title='NavLink' href='" + testCase.RelativeUri + "' /></entry>"), ExpectedException = testCase.ComputeExpectedException(behavior, testConfiguration.Version, /*ignoredOnServer*/ false) }, // TODO: Add tests like this for all URLs we can process, including ATOM Metadata ones! }; this.CombinatorialEngineProvider.RunCombinations( testDescriptors, testDescriptor => { // Clone the test configuration and set base URI and behavior. testConfiguration = new ReaderTestConfiguration(testConfiguration); testConfiguration.MessageReaderSettings.BaseUri = testCase.SettingsBaseUri == null ? null : new Uri(testCase.SettingsBaseUri); testConfiguration = testConfiguration.CloneAndApplyBehavior(behavior); testDescriptor.RunTest(testConfiguration); }); }); }
public void XmlBaseUriHandlingTest() { var testCases = new XmlBaseUriTestCase[] { new XmlBaseUriTestCase { RelativeUri = "relative", XmlBaseUri = "http://odata.org/base", SettingsBaseUri = (string)null, ResultUri = "http://odata.org/relative", }, new XmlBaseUriTestCase { RelativeUri = "relative", XmlBaseUri = (string)null, SettingsBaseUri = (string)null, ResultUri = "http://odata.org/relative", }, new XmlBaseUriTestCase { RelativeUri = "relative", XmlBaseUri = "/baserelative/", SettingsBaseUri = "http://odata.org/base", ResultUri = "http://odata.org/baserelative/relative" }, new XmlBaseUriTestCase { RelativeUri = "relative", XmlBaseUri = string.Empty, SettingsBaseUri = "http://odata.org/", ResultUri = "http://odata.org/relative" }, new XmlBaseUriTestCase { RelativeUri = "relative", XmlBaseUri = "/baserelative/", SettingsBaseUri = "http://odata.org/base/", ResultUri = "http://odata.org/baserelative/relative" }, new XmlBaseUriTestCase { RelativeUri = "relative", XmlBaseUri = string.Empty, SettingsBaseUri = "http://odata.org/base/", ResultUri = "http://odata.org/base/relative" }, }; this.CombinatorialEngineProvider.RunCombinations( testCases, this.ReaderTestConfigurationProvider.AtomFormatConfigurations, TestReaderUtils.ODataBehaviorKinds, (testCase, testConfiguration, behavior) => { IEnumerable <PayloadReaderTestDescriptor> testDescriptors = new PayloadReaderTestDescriptor[] { // MLE with relative media source link new PayloadReaderTestDescriptor(this.Settings) { PayloadElement = PayloadBuilder.Entity().AsMediaLinkEntry().StreamSourceLink(testCase.ComputeExpectedResultUri(behavior, testConfiguration.Version, /*ignoredOnServer*/ true)) .XmlRepresentation("<entry xml:base='" + testCase.XmlBaseUri + "'><content src='" + testCase.RelativeUri + "'/></entry>"), ExpectedException = testCase.ComputeExpectedException(behavior, testConfiguration.Version, /*ignoredOnServer*/ true) }, // Navigation link with relative href new PayloadReaderTestDescriptor(this.Settings) { PayloadElement = PayloadBuilder.Entity() .NavigationProperty("NavLink", testCase.ComputeExpectedResultUri(behavior, testConfiguration.Version, /*ignoredOnServer*/ false)) .XmlRepresentation("<entry xml:base='" + testCase.XmlBaseUri + "'><content /><link rel='http://docs.oasis-open.org/odata/ns/related/NavLink' type='application/atom+xml;type=entry' title='NavLink' href='" + testCase.RelativeUri + "' /></entry>"), ExpectedException = testCase.ComputeExpectedException(behavior, testConfiguration.Version, /*ignoredOnServer*/ false) }, // TODO: Add tests like this for all URLs we can process, including ATOM Metadata ones! }; this.CombinatorialEngineProvider.RunCombinations( testDescriptors, testDescriptor => { // Clone the test configuration and set base URI and behavior. testConfiguration = new ReaderTestConfiguration(testConfiguration); testConfiguration.MessageReaderSettings.BaseUri = testCase.SettingsBaseUri == null ? null : new Uri(testCase.SettingsBaseUri); testConfiguration = testConfiguration.CloneAndApplyBehavior(behavior); testDescriptor.RunTest(testConfiguration); }); }); }