public void EntryAtomMetadataLinkTest() { // Self link IEnumerable <PayloadReaderTestDescriptor> testDescriptors = this.CreateLinkEntryTestDescriptors( "self", (entity, href, rel, type, hrefLang, title, length) => { if (href != null) { entity = entity.WithSelfLink(href); } return(entity.AtomSelfLink(href, type, hrefLang, title, length)); }); // Edit link testDescriptors = testDescriptors.Concat( this.CreateLinkEntryTestDescriptors( "edit", (entity, href, rel, type, hrefLang, title, length) => { if (href != null) { entity = entity.WithEditLink(href); } return(entity.AtomEditLink(href, type, hrefLang, title, length)); })); // Edit-media link testDescriptors = testDescriptors.Concat( this.CreateLinkEntryTestDescriptors( "edit-media", (entity, href, rel, type, hrefLang, title, length) => entity.AsMediaLinkEntry().StreamEditLink(href).SetAnnotation( new NamedStreamAtomLinkMetadataAnnotation { Href = href, HrefLang = hrefLang, Length = length, Relation = rel, Title = title, Type = type, }))); // Stream property self link testDescriptors = testDescriptors.Concat( this.CreateLinkEntryTestDescriptors( "http://docs.oasis-open.org/odata/ns/mediaresource/StreamProperty", (entity, href, rel, type, hrefLang, title, length) => entity.StreamProperty(PayloadBuilder.StreamProperty("StreamProperty", href, null, type) .AtomNamedStreamSourceLink(href, type, hrefLang, title, length)), titleAttributeOverride: "StreamProperty", skipIanaPrefix: true)); // Stream property edit link testDescriptors = testDescriptors.Concat( this.CreateLinkEntryTestDescriptors( "http://docs.oasis-open.org/odata/ns/edit-media/StreamProperty", (entity, href, rel, type, hrefLang, title, length) => entity.StreamProperty(PayloadBuilder.StreamProperty("StreamProperty", null, href, type) .AtomNamedStreamEditLink(href, type, hrefLang, title, length)), titleAttributeOverride: "StreamProperty", skipIanaPrefix: true)); // TODO: Association Link - Add back support for customizing association link element in Atom // Navigation link testDescriptors = testDescriptors.Concat( this.CreateLinkEntryTestDescriptors( "http://docs.oasis-open.org/odata/ns/related/NavProp", (entity, href, rel, type, hrefLang, title, length) => entity.NavigationProperty( PayloadBuilder.DeferredNavigationProperty( "NavProp", new DeferredLink { UriString = href }.AtomLinkAttributes(href, rel, type, hrefLang, title, length), null)), titleAttributeOverride: "NavProp", typeAttributeOverride: "application/atom+xml;type=entry", skipIanaPrefix: true)); // Non-OData link testDescriptors = testDescriptors.Concat( this.CreateLinkEntryTestDescriptors( "http://some.uri", (entity, href, rel, type, hrefLang, title, length) => entity.AtomLink(href, rel, type, hrefLang, title, length), skipIanaPrefix: true)); // Add some custom payloads. testDescriptors = testDescriptors.Concat(new PayloadReaderTestDescriptor[] { #region stream property tests // Stream property with both read link and edit link new PayloadReaderTestDescriptor(this.Settings) { PayloadElement = PayloadBuilder.Entity() .StreamProperty(PayloadBuilder.StreamProperty("StreamProperty", "http://odata.org/readlink", "http://odata.org/editlink") .AtomNamedStreamSourceLink("http://odata.org/readlink", null) .AtomNamedStreamEditLink("http://odata.org/editlink", null)), }, #endregion stream property tests #region navigation property tests // Navigation link with association link // TODO: Association Link - Add back support for customizing association link element in Atom new PayloadReaderTestDescriptor(this.Settings) { PayloadElement = PayloadBuilder.Entity() .NavigationProperty(PayloadBuilder.DeferredNavigationProperty( "NavProp", new DeferredLink { UriString = "http://odata.org/navlink" } .AtomLinkAttributes("http://odata.org/navlink", "http://docs.oasis-open.org/odata/ns/related/NavProp", "application/atom+xml;type=entry"))) .XmlRepresentation(@"<entry> <link rel='http://docs.oasis-open.org/odata/ns/related/NavProp' href='http://odata.org/navlink' type='application/atom+xml;type=entry'/> </entry>"), }, #endregion navigation property tests }); this.RunAtomMetadataReaderTests(testDescriptors); }