public void HasXmlnsXhtmlAttribute() { var urlSet = new UrlSet(); var xml = urlSet.ToXml(); Assert.IsTrue(xml.Attributes().Any(attr => attr.Name == XhtmlNamespace), "xmlns:html attribute missing."); }
public void HasXmlnsAttribute() { var urlSet = new UrlSet(); var xml = urlSet.ToXml(); Assert.IsTrue(xml.Attributes().Any(attr => attr.Name == "xmlns"), "xmlns attribute missing."); }
public void HasXmlnsXhtmlDefaultValue() { const string expected = "http://www.w3.org/1999/xhtml"; var urlSet = new UrlSet(); var xml = urlSet.ToXml(); Assert.AreEqual(xml.Attributes().First(attr => attr.Name == XhtmlNamespace).Value, expected, "xmlns:html default value incorrect."); }
public void HasXmlnsDefaultValue() { const string expected = "http://www.sitemaps.org/schemas/sitemap/0.9"; var urlSet = new UrlSet(); var xml = urlSet.ToXml(); Assert.AreEqual(xml.Attributes().First(attr => attr.Name == "xmlns").Value, expected, "xmlns default value incorrect."); }
public void CanOverrideXmlnsXhtml() { const string expected = "http://www.somethingnew.com/2015/xhtml"; var urlSet = new UrlSet { XmlNamespaceXHtml = expected }; var xml = urlSet.ToXml(); Assert.AreEqual(xml.Attributes().First(attr => attr.Name == XhtmlNamespace).Value, expected, "xmlns:html default value was not overriden."); }
public void HasChildren() { var urlSet = new UrlSet(); var url1 = new UmbracoContent(); var url2 = new UmbracoContent(); urlSet.Urls.Add(url1); urlSet.Urls.Add(url2); var xml = urlSet.ToXml(); Assert.IsTrue(xml.HasElements, "xml is missing child elements"); Assert.AreEqual(xml.Elements().Count(), 2, "xml has the wrong number of elements."); }
/// <summary> /// Generates a valid xml sitemap from the supplied content. /// </summary> /// <param name="content">Content to be added to the sitemap.</param> /// <returns>An XML Sitemap.</returns> public XDocument Generate(IEnumerable <ISitemapContent> content) { if (content == null) { throw new ArgumentNullException(nameof(content)); } var urlSet = new UrlSet { Urls = content.ToList() }; var sitemap = new XDocument { Declaration = new XDeclaration(Version, Encoding, Standalone) }; sitemap.Add(urlSet.ToXml()); return(sitemap); }