public void BasicObjectRendersNamespaces() { var obj = new OpenGraphObject("my super title", new Uri("http://test.org/my-super-title")); var expected = " xmlns:og=\"http://ogp.me/ns#\" "; Assert.AreEqual(expected, obj.ToHtmlAttributeNamespaces()); }
public void BasicObjectRendersTags() { var obj = new OpenGraphObject("my super title", new Uri("http://test.org/my-super-title")); var expected = Meta("og:title", "my super title") + Meta("og:url", "http://test.org/my-super-title"); Assert.AreEqual(expected, obj.ToString()); }
protected virtual LinkPreviewEntity Map(OpenGraphObject graph) => new LinkPreviewEntity { OgDescription = graph.Description, Title = graph.Title, Uri = graph.Url, MediaId = graph.MediaId };
public void RendersMultipleNamespaces() { var obj = new OpenGraphObject("my super title", new Uri("http://test.org/my-super-title")); obj.Add(new OpenGraphTag(new OpenGraphName("key", "xxx", "http://xxx/aaa/#"), "value")); var expected = " xmlns:og=\"http://ogp.me/ns#\" xmlns:xxx=\"http://xxx/aaa/#\" "; Assert.AreEqual(expected, obj.ToHtmlAttributeNamespaces()); }
protected virtual OpenGraphObject GetDefaultObject(string defaultUrl = null) { var obj = new OpenGraphObject() { SiteName = RequestUrl.Host, Type = "website", Url = defaultUrl.IsNullOrWhiteSpace() ? RequestUrl.AbsoluteUri : defaultUrl }; return(obj); }
protected virtual LinkPreviewEntity Map(OpenGraphObject obj) { var entity = new LinkPreviewEntity() { OgDescription = obj.Description, Title = obj.Title, Uri = obj.Url, MediaId = obj.MediaId }; return(entity); }
public void TypicalHomepageWithLogo() { var obj = new OpenGraphObject("welcome to mysite", new Uri("http://mysite.com/")); obj.IsImage(imageUri: new Uri("http://mysite.com/Content/loog.png")); obj.SetDescription("With mysite, build your blog in 2 minutes"); var expected = Meta("og:title", "welcome to mysite") + Meta("og:url", "http://mysite.com/") + Meta("og:image", "http://mysite.com/Content/loog.png") + Meta("og:description", "With mysite, build your blog in 2 minutes"); Assert.AreEqual(expected, obj.ToString()); }
public void EmptyObjectRendersNothing() { var obj = new OpenGraphObject(); Assert.AreEqual(string.Empty, obj.ToString()); }