Esempio n. 1
0
        public IActionResult Sitemap()
        {
            var sitemapSvc = new SitemapService();
            var doc        = sitemapSvc.GenerateSitemap(actionDescriptorCollectionProvider.ActionDescriptors, urlConfig.Value);

            using (var stream = new MemoryStream())
            {
                doc.Save(stream);
                return(File(stream.ToArray(), "text/xml"));
            }
        }
Esempio n. 2
0
        public void ReturnsEntryWithExpectedValues()
        {
            //Arrange
            List <SitemapEntry> entries = new List <SitemapEntry>();

            entries.Add(new SitemapEntry("http://foo.bar", new DateTime(2020, 1, 1, 15, 00, 00), SitemapEntry.ChangeFrequencies.Monthly, 0.5m));

            //Act
            var sitemap = svc.GenerateSitemap(entries);

            //Assert
            Assert.AreEqual("<?xml version=\"1.0\"?><urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\" xmlns:image=\"http://www.google.com/schemas/sitemap-image/1.1\"><url><loc>http://foo.bar</loc><lastmod>2020-01-01</lastmod><changefreq>monthly</changefreq><priority>0.5</priority></url></urlset>", sitemap.InnerXml);
        }