public void Ctor_Uri_String(Uri url, string mediaType) { var content = new UrlSyndicationContent(url, mediaType); Assert.Empty(content.AttributeExtensions); Assert.Equal(url, content.Url); Assert.Equal(mediaType, content.Type); }
public void CreateUrlContent_Invoke_ReturnsExpected(Uri url, string mediaType) { UrlSyndicationContent syndicationContent = SyndicationContent.CreateUrlContent(url, mediaType); Assert.Empty(syndicationContent.AttributeExtensions); Assert.Equal(url, syndicationContent.Url); Assert.Equal(mediaType, syndicationContent.Type); }
public void Clone_Empty_ReturnsExpected() { var original = new UrlSyndicationContent(new Uri("http://microsoft.com"), "mediaType"); UrlSyndicationContent clone = Assert.IsType <UrlSyndicationContent>(original.Clone()); Assert.Empty(clone.AttributeExtensions); Assert.Equal("mediaType", clone.Type); Assert.Equal(new Uri("http://microsoft.com"), clone.Url); }
public void Ctor_UrlSyndicationContent_Empty() { var original = new UrlSyndicationContent(new Uri("http://microsoft.com"), "mediaType"); var clone = new UrlSyndicationContentSubclass(original); Assert.Empty(clone.AttributeExtensions); Assert.Equal("mediaType", clone.Type); Assert.Equal(new Uri("http://microsoft.com"), clone.Url); }
public void Clone() { Uri uri = new Uri("http://mono-project.com"); UrlSyndicationContent t = new UrlSyndicationContent(uri, "text/plain"); t = t.Clone() as UrlSyndicationContent; Assert.AreEqual(uri, t.Url, "#1"); Assert.AreEqual("text/plain", t.Type, "#2"); }
public void Constructor() { Uri uri = new Uri("http://example.com"); UrlSyndicationContent t = new UrlSyndicationContent(uri, null); t = new UrlSyndicationContent(uri, "text/plain"); Assert.AreEqual(uri, t.Url, "#1"); Assert.AreEqual("text/plain", t.Type, "#2"); }
public void Simple() { Uri suri = new Uri(url); UrlSyndicationContent surl = new UrlSyndicationContent(suri, media_type); Assert.AreEqual(typeof(UrlSyndicationContent), surl.GetType(), "#S1"); // check for content and type Assert.AreEqual(url.ToLower(), surl.Url.ToString(), "#S2"); Assert.AreEqual(media_type, surl.Type.ToString(), "#S3"); }
public void Clone_Full_ReturnsExpected() { var original = new UrlSyndicationContent(new Uri("http://microsoft.com"), "mediaType"); original.AttributeExtensions.Add(new XmlQualifiedName("name"), "value"); UrlSyndicationContent clone = Assert.IsType <UrlSyndicationContent>(original.Clone()); Assert.NotSame(clone.AttributeExtensions, original.AttributeExtensions); Assert.Equal(1, clone.AttributeExtensions.Count); Assert.Equal("value", clone.AttributeExtensions[new XmlQualifiedName("name")]); Assert.Equal("mediaType", clone.Type); Assert.Equal(new Uri("http://microsoft.com"), clone.Url); }
public void Ctor_UrlSyndicationContent_Full() { var original = new UrlSyndicationContent(new Uri("http://microsoft.com"), "mediaType"); original.AttributeExtensions.Add(new XmlQualifiedName("name"), "value"); var clone = new UrlSyndicationContentSubclass(original); Assert.NotSame(clone.AttributeExtensions, original.AttributeExtensions); Assert.Equal(1, clone.AttributeExtensions.Count); Assert.Equal("value", clone.AttributeExtensions[new XmlQualifiedName("name")]); Assert.Equal("mediaType", clone.Type); Assert.Equal(new Uri("http://microsoft.com"), clone.Url); }
public void WriteTo() { Uri uri = new Uri("http://mono-project.com/"); UrlSyndicationContent t = new UrlSyndicationContent(uri, null); StringWriter sw = new StringWriter(); using (XmlWriter w = CreateWriter(sw)) t.WriteTo(w, "root", String.Empty); Assert.AreEqual("<root type=\"\" src=\"http://mono-project.com/\" />", sw.ToString()); t = new UrlSyndicationContent(uri, "application/xml+svg"); sw = new StringWriter(); using (XmlWriter w = CreateWriter(sw)) t.WriteTo(w, "root", String.Empty); Assert.AreEqual("<root type=\"application/xml+svg\" src=\"http://mono-project.com/\" />", sw.ToString()); }
private SyndicationItem MapEntryToSyndicationItem(Identity topicId, FeedEntry e) { var messageLink = ResourceLocation.OfMessageByTopic(topicId, e.MessageId); var message = messageByMessageKey.Get(new MessageKey { TopicId = topicId, MessageId = e.MessageId }); var contentType = message.Headers.FirstOrDefault(h => h.Key == "Content-Type"); var content = new UrlSyndicationContent(messageLink, contentType.Value.Aggregate((a, b) => a + "," + b)); return(new SyndicationItem(string.Format("Message {0}", e.MessageId), content, null, e.MessageId.ToString(), e.TimeStamp) { Links = { new SyndicationLink(messageLink) }, LastUpdatedTime = e.TimeStamp }); }
public static void Snippet3() { // <Snippet3> UrlSyndicationContent urlContent = new UrlSyndicationContent(new Uri("http://localhost/content"), "text/html"); // </Snippet3> }
public UrlSyndicationContentSubclass(UrlSyndicationContent source) : base(source) { }
/// <summary> /// Updates the resource property. /// </summary> /// <param name="context">The context.</param> /// <param name="resource">The resource.</param> /// <param name="atomEntry">The atom entry.</param> private static void UpdateResourceProperty( ZentityContext context, ScholarlyWork resource, AtomEntryDocument atomEntry) { resource.Title = atomEntry.Title.Text; SetContentType(context, resource, atomEntry.Title.Type, AtomPubConstants.TitleTypeProperty); resource.DateModified = DateTime.Now; Publication publication = resource as Publication; if (null != publication && atomEntry.PublishDate != DateTimeOffset.MinValue) { publication.DatePublished = atomEntry.PublishDate.DateTime; } if (null != atomEntry.Copyright) { resource.Copyright = atomEntry.Copyright.Text; SetContentType(context, resource, atomEntry.Copyright.Type, AtomPubConstants.CopyrightTypeProperty); } if (null != atomEntry.Summary && !string.IsNullOrEmpty(atomEntry.Summary.Text)) { SetExtensionProperty(context, resource, AtomPubConstants.SummaryProperty, atomEntry.Summary.Text); SetContentType(context, resource, atomEntry.Summary.Type, AtomPubConstants.SummaryTypeProperty); } if (null != atomEntry.Content) { UrlSyndicationContent urlContent = atomEntry.Content as UrlSyndicationContent; if (null != urlContent) { resource.Description = null; SetExtensionProperty(context, resource, AtomPubConstants.ContentUrlProperty, urlContent.Url.AbsoluteUri); } else { ResourceProperty urlContentProperty = ZentityAtomPubStoreReader.GetResourceProperty(resource, AtomPubConstants.ContentUrlProperty); if (null != urlContentProperty) { resource.ResourceProperties.Remove(urlContentProperty); } TextSyndicationContent textDescription = atomEntry.Content as TextSyndicationContent; if (null != textDescription) { resource.Description = textDescription.Text; } else { XmlSyndicationContent content = atomEntry.Content as XmlSyndicationContent; if (null != content) { XmlDictionaryReader contentReader = content.GetReaderAtContent(); StringBuilder contentValue = new StringBuilder(151); try { while (contentReader.Read()) { contentValue.Append(contentReader.Value); } } finally { contentReader.Close(); } resource.Description = contentValue.ToString(); } } } SetContentType(context, resource, atomEntry.Content.Type, AtomPubConstants.DescriptionTypeProperty); } if (null != atomEntry.Source) { ResourceProperty source = ZentityAtomPubStoreReader.GetResourceProperty(resource, AtomPubConstants.SourceProperty); if (null == source) { Property sourceProperty = GetProperty(context, AtomPubConstants.SourceProperty); source = new ResourceProperty { Property = sourceProperty, Resource = resource, }; } source.Value = atomEntry.Source; } #region Add Links List <ResourceProperty> links = ZentityAtomPubStoreReader.GetResourceProperties(resource, AtomPubConstants.LinksProperty); if (0 == atomEntry.XmlLinks.Count && null != links) { foreach (var item in links) { resource.ResourceProperties.Remove(item); } } Property linkProperty = GetProperty(context, AtomPubConstants.LinksProperty); foreach (string xmlLink in atomEntry.XmlLinks) { resource.ResourceProperties.Add(new ResourceProperty { Resource = resource, Property = linkProperty, Value = xmlLink }); } #endregion var authors = atomEntry.Authors.Select(author => new Person { Title = author.Name, Email = author.Email, Uri = author.Uri }); // Bug Fix : 177689 - AtomPub (M2): Author node is appending after every PUT request instead // of overwriting it. // Remove previous authors. resource.Authors.Clear(); AddPersons(context, resource.Authors, authors); resource.Contributors.Clear(); var contributors = atomEntry.Contributors.Select(author => new Person { Title = author.Name, Email = author.Email, Uri = author.Uri }); AddPersons(context, resource.Contributors, contributors); }