Exemple #1
0
        public async Task F11_HtmlChangedGenerationAfterPostAddedTest()
        {
            var db = await Db.Context();

            var currentGenerationCount = db.GenerationLogs.Count();

            var currentGeneration = await db.GenerationLogs.OrderByDescending(x => x.GenerationVersion).FirstAsync();

            await HtmlGenerationGroups.GenerateChangedToHtml(DebugTrackers.DebugProgressTracker());

            currentGeneration = await db.GenerationLogs.OrderByDescending(x => x.GenerationVersion).FirstAsync();

            Assert.AreEqual(currentGenerationCount + 1, db.GenerationLogs.Count(),
                            $"Expected {currentGenerationCount + 1} generation logs - found {db.GenerationLogs.Count()}");

            await FileManagement.RemoveContentDirectoriesAndFilesNotFoundInCurrentDatabase(
                DebugTrackers.DebugProgressTracker());

            IronwoodHtmlHelpers.CheckIndexHtmlAndGenerationVersion(currentGeneration.GenerationVersion);

            var tagFiles = UserSettingsSingleton.CurrentSettings().LocalSiteTagsDirectory().GetFiles("*.html").ToList();

            var changedTags =
                Db.TagListParseToSlugs(await db.PostContents.SingleAsync(x => x.Title == "First Post"), false)
                .Select(x => $"TagList-{x}").ToList();

            var notChanged = tagFiles.Where(x => !changedTags.Contains(Path.GetFileNameWithoutExtension(x.Name)))
                             .ToList();

            notChanged.ForEach(x =>
                               IronwoodHtmlHelpers.CheckGenerationVersionLessThan(x, currentGeneration.GenerationVersion));

            tagFiles.Where(x => changedTags.Contains(Path.GetFileNameWithoutExtension(x.Name))).ToList().ForEach(x =>
                                                                                                                 IronwoodHtmlHelpers.CheckGenerationVersionEquals(x, currentGeneration.GenerationVersion));

            var photoContent = UserSettingsSingleton.CurrentSettings().LocalSitePhotoDirectory()
                               .GetFiles("*.html", SearchOption.AllDirectories).ToList();

            photoContent.ForEach(x =>
                                 IronwoodHtmlHelpers.CheckGenerationVersionLessThan(x, currentGeneration.GenerationVersion));

            var noteContent = UserSettingsSingleton.CurrentSettings().LocalSiteNoteDirectory()
                              .GetFiles("*.html", SearchOption.AllDirectories).Where(x => !x.Name.Contains("List")).ToList();

            noteContent.ForEach(x =>
                                IronwoodHtmlHelpers.CheckGenerationVersionEquals(x, currentGeneration.GenerationVersion));
        }
        public async Task Z10_GenerateAllHtml()
        {
            var db = await Db.Context();

            var forIndex = await db.PointContents.OrderByDescending(x => x.ContentId).Take(4).ToListAsync();

            forIndex.ForEach(x => x.ShowInMainSiteFeed = true);
            await db.SaveChangesAsync(true);

            var currentGenerationCount = db.GenerationLogs.Count();

            await HtmlGenerationGroups.GenerateAllHtml(DebugTrackers.DebugProgressTracker());

            Assert.AreEqual(currentGenerationCount + 1, db.GenerationLogs.Count(),
                            $"Expected {currentGenerationCount + 1} generation logs - found {db.GenerationLogs.Count()}");

            var currentGeneration = await db.GenerationLogs.OrderByDescending(x => x.GenerationVersion).FirstAsync();

            await FileManagement.RemoveContentDirectoriesAndFilesNotFoundInCurrentDatabase(
                DebugTrackers.DebugProgressTracker());

            IronwoodHtmlHelpers.CheckIndexHtmlAndGenerationVersion(currentGeneration.GenerationVersion);
        }
Exemple #3
0
        public async Task G10_PostUpdateChangedDetectionTest()
        {
            var db = await Db.Context();

            var wikiQuotePost = db.PostContents.Single(x => x.Slug == IronwoodPostInfo.WikiQuotePostContent01.Slug);

            var allPhotos = db.PhotoContents.ToList();

            foreach (var loopPhotos in allPhotos)
            {
                wikiQuotePost.BodyContent += BracketCodePhotos.Create(loopPhotos);
            }

            wikiQuotePost.LastUpdatedBy = "Changed Html Test";
            wikiQuotePost.LastUpdatedOn = DateTime.Now;

            var saveResult =
                await PostGenerator.SaveAndGenerateHtml(wikiQuotePost, null, DebugTrackers.DebugProgressTracker());

            Assert.IsFalse(saveResult.generationReturn.HasError);

            var currentGenerationCount = db.GenerationLogs.Count();

            var currentGeneration = await db.GenerationLogs.OrderByDescending(x => x.GenerationVersion).FirstAsync();

            await HtmlGenerationGroups.GenerateChangedToHtml(DebugTrackers.DebugProgressTracker());

            currentGeneration = await db.GenerationLogs.OrderByDescending(x => x.GenerationVersion).FirstAsync();

            Assert.AreEqual(currentGenerationCount + 1, db.GenerationLogs.Count(),
                            $"Expected {currentGenerationCount + 1} generation logs - found {db.GenerationLogs.Count()}");

            var relatedContentEntries = await db.GenerationRelatedContents
                                        .Where(x => x.GenerationVersion == currentGeneration.GenerationVersion).ToListAsync();

            Assert.AreEqual(relatedContentEntries.Count, allPhotos.Count() + 1);
            Assert.AreEqual(relatedContentEntries.Select(x => x.ContentOne).Distinct().Count(), 2);
            Assert.AreEqual(relatedContentEntries.Select(x => x.ContentTwo).Count(), allPhotos.Count() + 1);
            Assert.AreEqual(
                relatedContentEntries.Select(x => x.ContentTwo).Except(allPhotos.Select(x => x.ContentId)).Count(), 1);
            Assert.AreEqual(
                allPhotos.Select(x => x.ContentId).Except(relatedContentEntries.Select(x => x.ContentTwo)).Count(), 0);

            var photoContent = UserSettingsSingleton.CurrentSettings().LocalSitePhotoDirectory()
                               .GetFiles("*.html", SearchOption.AllDirectories).ToList().Where(x =>
                                                                                               !x.Name.Contains("Daily") && !x.Name.Contains("Roll") && !x.Name.Contains("List")).ToList();

            photoContent.ForEach(x =>
                                 IronwoodHtmlHelpers.CheckGenerationVersionEquals(x, currentGeneration.GenerationVersion));


            wikiQuotePost = db.PostContents.Single(x => x.Slug == IronwoodPostInfo.WikiQuotePostContent01.Slug);

            wikiQuotePost.BodyContent =
                wikiQuotePost.BodyContent.Replace(BracketCodePhotos.Create(allPhotos.First()), "");

            wikiQuotePost.LastUpdatedBy = "Changed Html Test 02";
            wikiQuotePost.LastUpdatedOn = DateTime.Now;

            saveResult =
                await PostGenerator.SaveAndGenerateHtml(wikiQuotePost, null, DebugTrackers.DebugProgressTracker());

            Assert.IsFalse(saveResult.generationReturn.HasError);

            currentGenerationCount = db.GenerationLogs.Count();

            currentGeneration = await db.GenerationLogs.OrderByDescending(x => x.GenerationVersion).FirstAsync();

            await HtmlGenerationGroups.GenerateChangedToHtml(DebugTrackers.DebugProgressTracker());

            currentGeneration = await db.GenerationLogs.OrderByDescending(x => x.GenerationVersion).FirstAsync();

            Assert.AreEqual(currentGenerationCount + 1, db.GenerationLogs.Count(),
                            $"Expected {currentGenerationCount + 1} generation logs - found {db.GenerationLogs.Count()}");

            relatedContentEntries = await db.GenerationRelatedContents
                                    .Where(x => x.GenerationVersion == currentGeneration.GenerationVersion).ToListAsync();

            Assert.AreEqual(relatedContentEntries.Count, allPhotos.Count() - 1 + 1);
            Assert.AreEqual(relatedContentEntries.Select(x => x.ContentOne).Distinct().Count(), 2);
            Assert.AreEqual(relatedContentEntries.Select(x => x.ContentTwo).Count(), allPhotos.Count() - 1 + 1);
            Assert.AreEqual(
                relatedContentEntries.Select(x => x.ContentTwo).Except(allPhotos.Select(x => x.ContentId)).Count(), 1);
            Assert.AreEqual(
                allPhotos.Select(x => x.ContentId).Except(relatedContentEntries.Select(x => x.ContentTwo)).Count(), 1);

            photoContent = UserSettingsSingleton.CurrentSettings().LocalSitePhotoDirectory()
                           .GetFiles("*.html", SearchOption.AllDirectories).ToList().Where(x =>
                                                                                           !x.Name.Contains("Daily") && !x.Name.Contains("Roll") && !x.Name.Contains("List")).ToList();

            photoContent.ForEach(x =>
                                 IronwoodHtmlHelpers.CheckGenerationVersionEquals(x, currentGeneration.GenerationVersion));


            wikiQuotePost = db.PostContents.Single(x => x.Slug == IronwoodPostInfo.WikiQuotePostContent01.Slug);

            wikiQuotePost.BodyContent += $"{Environment.NewLine}Visit Ironwood Today!";

            wikiQuotePost.LastUpdatedBy = "Changed Html Test 02";
            wikiQuotePost.LastUpdatedOn = DateTime.Now;

            saveResult =
                await PostGenerator.SaveAndGenerateHtml(wikiQuotePost, null, DebugTrackers.DebugProgressTracker());

            Assert.IsFalse(saveResult.generationReturn.HasError);

            currentGenerationCount = db.GenerationLogs.Count();

            currentGeneration = await db.GenerationLogs.OrderByDescending(x => x.GenerationVersion).FirstAsync();

            await HtmlGenerationGroups.GenerateChangedToHtml(DebugTrackers.DebugProgressTracker());

            currentGeneration = await db.GenerationLogs.OrderByDescending(x => x.GenerationVersion).FirstAsync();

            Assert.AreEqual(currentGenerationCount + 1, db.GenerationLogs.Count(),
                            $"Expected {currentGenerationCount + 1} generation logs - found {db.GenerationLogs.Count()}");

            relatedContentEntries = await db.GenerationRelatedContents
                                    .Where(x => x.GenerationVersion == currentGeneration.GenerationVersion).ToListAsync();

            Assert.AreEqual(relatedContentEntries.Count, allPhotos.Count() - 1 + 1);
            Assert.AreEqual(relatedContentEntries.Select(x => x.ContentOne).Distinct().Count(), 2);
            Assert.AreEqual(relatedContentEntries.Select(x => x.ContentTwo).Count(), allPhotos.Count() - 1 + 1);
            Assert.AreEqual(
                relatedContentEntries.Select(x => x.ContentTwo).Except(allPhotos.Select(x => x.ContentId)).Count(), 1);
            Assert.AreEqual(
                allPhotos.Select(x => x.ContentId).Except(relatedContentEntries.Select(x => x.ContentTwo)).Count(), 1);

            //Todo: Check that the excluded photo is not regened
        }
Exemple #4
0
        public async Task D10_FirstGeneration()
        {
            var db = await Db.Context();

            Assert.True(!db.GenerationLogs.Any(), "Unexpected Content in Generation Logs");

            await HtmlGenerationGroups.GenerateChangedToHtml(DebugTrackers.DebugProgressTracker());

            Assert.AreEqual(1, db.GenerationLogs.Count(),
                            $"Expected 1 generation log - found {db.GenerationLogs.Count()}");

            var currentGeneration = await db.GenerationLogs.FirstAsync();

            //Index File

            IronwoodHtmlHelpers.CheckIndexHtmlAndGenerationVersion(currentGeneration.GenerationVersion);

            //Tags

            var tags = await Db.TagSlugsAndContentList(true, false, DebugTrackers.DebugProgressTracker());

            var tagFiles = UserSettingsSingleton.CurrentSettings().LocalSiteTagsDirectory().GetFiles("*.html").ToList();

            Assert.AreEqual(tagFiles.Count - 1, tags.Select(x => x.tag).Count(),
                            "Did not find the expected number of Tag Files after generation.");

            foreach (var loopDbTags in tags.Select(x => x.tag).ToList())
            {
                Assert.True(tagFiles.Exists(x => x.Name == $"TagList-{loopDbTags}.html"),
                            $"Didn't find a file for Tag {loopDbTags}");
            }


            //DailyPhotos

            var photoRecords = await db.PhotoContents.ToListAsync();

            var photoDates = photoRecords.GroupBy(x => x.PhotoCreatedOn.Date).Select(x => x.Key).ToList();

            var dailyPhotoFiles = UserSettingsSingleton.CurrentSettings().LocalSiteDailyPhotoGalleryDirectory()
                                  .GetFiles("*.html").ToList();

            Assert.AreEqual(photoDates.Count, dailyPhotoFiles.Count,
                            "Didn't find the expected number of Daily Photo Files");

            foreach (var loopPhotoDates in photoDates)
            {
                Assert.True(dailyPhotoFiles.Exists(x => x.Name == $"DailyPhotos-{loopPhotoDates:yyyy-MM-dd}.html"),
                            $"Didn't find a file for Daily Photos {loopPhotoDates:yyyy-MM-dd}");
            }


            //Camera Roll
            var cameraRollFile = UserSettingsSingleton.CurrentSettings().LocalSiteCameraRollPhotoGalleryFileInfo();

            Assert.True(cameraRollFile.Exists, "Camera Roll File not found");

            var cameraRollDocument = IronwoodHtmlHelpers.DocumentFromFile(cameraRollFile);

            var cameraRollGenerationVersionAttributeString = cameraRollDocument.Head.Attributes
                                                             .Single(x => x.Name == "data-generationversion").Value;

            Assert.AreEqual(currentGeneration.GenerationVersion.ToString("yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffffff"),
                            cameraRollGenerationVersionAttributeString,
                            "Generation Version of Camera Roll Does not match expected Log");

            //Note Check
            var noteContent = UserSettingsSingleton.CurrentSettings().LocalSiteNoteDirectory()
                              .GetFiles("*.html", SearchOption.AllDirectories).ToList();

            noteContent.ForEach(x =>
                                IronwoodHtmlHelpers.CheckGenerationVersionEquals(x, currentGeneration.GenerationVersion));
        }