Exemplo n.º 1
0
        public void Generates_Sitemap_With_Image()
        {
            var urls = new List <Url>();

            urls.Add(Url.CreateUrl("https://example.com"));
            urls[0].AddImage("https://example.com/image.jpg", "Caption of the image", "Title of the image");

            var result = _sitemapGenerator.GenerateSitemaps(urls, new DirectoryInfo("GenerateSitemapsTests"), "file_with_image");

            Assert.AreEqual(1, result.Count);
        }
Exemplo n.º 2
0
        public void It_Only_Saves_One_Sitemap_If_There_Are_Less_Than_50001_Urls()
        {
            var filesCount   = 4;
            var recordsCount = (Sitemap.MaxNumberOfUrlsPerSitemap * 3) + 5;
            var urls         = new List <Url>();

            for (var i = 0; i < recordsCount; i++)
            {
                urls.Add(new Url());
            }

            var result = _sitemapGenerator.GenerateSitemaps(urls, new DirectoryInfo("x"), "file");

            Assert.AreEqual(filesCount, result.Count);
        }
        public void It_Only_Saves_One_Sitemap_If_There_Are_Less_Than_50001_Urls()
        {
            //--arrange
            var maxNumberOfUrlsForOneSitemap = Sitemap.MaxNumberOfUrlsPerSitemap;
            var urls = new List <Url>(maxNumberOfUrlsForOneSitemap);
            var now  = DateTime.UtcNow;

            for (var i = 0; i < maxNumberOfUrlsForOneSitemap; i++)
            {
                urls.Add(Url.CreateUrl("https://example.com/" + i, now));
            }

            //--act
            _sitemapGenerator.GenerateSitemaps(urls, new DirectoryInfo(_sitemapLocation), "sitemap_from_test_1");

            //--assert
            //--go look in the {sitemapLocation} directory!
        }
Exemplo n.º 4
0
        public void It_Only_Saves_One_Sitemap_If_There_Are_Less_Than_50001_Urls()
        {
            //--arrange
            var maxNumberOfUrlsForOneSitemap = SitemapGenerator.MaxNumberOfUrlsPerSitemap;
            var urls = new List <Url>(maxNumberOfUrlsForOneSitemap);

            for (var i = 0; i < maxNumberOfUrlsForOneSitemap; i++)
            {
                urls.Add(new Url());
            }

            //--act
            _sitemapGenerator.GenerateSitemaps(urls, new DirectoryInfo("x"), "file");

            //--assert
            _sitemapSerializerMock
            .Received(1)
            .SerializeAndSave(Arg.Is <Sitemap>(x => x.Count == maxNumberOfUrlsForOneSitemap), Arg.Any <DirectoryInfo>(), Arg.Any <string>());
        }
        public void Generates_Sitemap_With_Image()
        {
            var url = Url.CreateUrl("https://example.com");

            url.AddImage("https://example.com/image1.jpg", "Caption of the image1", "Title of the image1");
            url.AddImage("https://example.com/image2.jpg", "Caption of the image2", "Title of the image2");
            var sitemap = new Sitemap();

            sitemap.Add(url);

            var result = _sitemapGenerator.GenerateSitemaps(sitemap, new DirectoryInfo("GenerateFullSitemapsTests"), "full_file");

            Assert.AreEqual(1, result.Count);
        }