public void WHEN_SitemapIsSerialized_SHOULD_RespectSitemapXsd()
        {
            // ARRANGE
            var urlSitemapXsd = "http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd";
            var @namespace    = "http://www.sitemaps.org/schemas/sitemap/0.9";

            var filePath = Path.GetTempFileName();
            var sitemap  = CreateSitemap();

            try
            {
                // ACT
                sitemap.WriteToXml(filePath);

                // ASSERT
                XsdValidator.IsValidXml(filePath, urlSitemapXsd, @namespace).Should().BeTrue("Validation against XSD failed. Check test output for more details.");
            }
            finally
            {
                File.Delete(filePath);
            }
        }
Ejemplo n.º 2
0
        public void WHEN_SitemapIsSerialized_SHOULD_RespectSitemapXsd()
        {
            // ARRANGE
            var xsdResourceName = "Orckestra.Composer.Sitemap.Tests.sitemap.xsd";
            var targetNamespace = "http://www.sitemaps.org/schemas/sitemap/0.9";

            var xmlFilePath = Path.GetTempFileName();
            var sitemap     = CreateSitemap();

            try
            {
                // ACT
                sitemap.WriteToXml(xmlFilePath);

                // ASSERT
                Assert.DoesNotThrow(() => XsdValidator.ValidateXml(xmlFilePath, xsdResourceName, targetNamespace));
            }
            finally
            {
                File.Delete(xmlFilePath);
            }
        }