Beispiel #1
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 It_Saves_A_Generated_Sitemap_Index_File_From_The_Specified_Sitemaps()
        {
            //--arrange
            var sitemaps = new List <SitemapInfo>
            {
                new SitemapInfo(new Uri("https://example.com"), DateTime.UtcNow),
                new SitemapInfo(new Uri("https://example2.com"), DateTime.UtcNow.AddDays(-1))
            };
            var expectedDirectory = new DirectoryInfo(@"C:\temp\sitemaptests\");
            var expectedFilename  = "testSitemapIndex1.xml";

            //--act
            _sitemapIndexGenerator.GenerateSitemapIndex(sitemaps, expectedDirectory, expectedFilename);

            //--assert
            _sitemapIndexSerializerMock
            .Received()
            .SerializeAndSave(
                Arg.Is <SitemapIndex>(x => AssertCorrectSitemapIndexWasSerialized(sitemaps, x)),
                Arg.Is <DirectoryInfo>(x => x == expectedDirectory),
                Arg.Is <string>(x => x == expectedFilename));
        }