예제 #1
0
파일: TagTest.cs 프로젝트: rnielikki/Pagene
        public void TagRemovalTest()
        {
            (var tags1, var entry1) = (new string[] { "cheese", "apple", "ice cream" }, new BlogEntry {
                Url = Path.Combine(RoutePathInfo.ContentPath, "uno").Replace('\\', '/')
            });
            (var tags2, var entry2) = (new string[] { "orange", "juice", "apple", "cheese", "milk" }, new BlogEntry {
                Url = Path.Combine(RoutePathInfo.ContentPath, "dos").Replace('\\', '/')
            });
            (var tags3, var entry3) = (new string[] { "apple", "juice", "milk", "cheese" }, new BlogEntry {
                Url = Path.Combine(RoutePathInfo.ContentPath, "tres").Replace('\\', '/')
            });
            var fileSystem = new MockFileSystem(new Dictionary <string, MockFileData>()
            {
                { AppPathInfo.BlogTagPath + "milk.json", new MockFileData("{\"milk\":[]}") }
            });
            var tagManager = new TagManager(fileSystem);

            tagManager.AddTag(tags1, entry1);
            tagManager.AddTag(tags2, entry2);
            tagManager.AddTag(tags3, entry3);
            IEnumerable <string> removedTarget = new string[] { "dos.md", "tres.md" };

            tagManager.Clean(removedTarget);

            var resultDictionary = GetTagMap(tagManager);

            resultDictionary.Should().NotContainKey("milk");
            resultDictionary["cheese"].Should().ContainKey(Path.Combine(RoutePathInfo.ContentPath, "uno").Replace('\\', '/'))
            .And.NotContainKey(Path.Combine(RoutePathInfo.ContentPath, "dos").Replace('\\', '/'));
            tagManager.GetRemovedTags().Should().Contain("milk");
        }
예제 #2
0
        internal override async System.Threading.Tasks.Task CleanAsync(IEnumerable <string> files)
        {
            if (!modified)
            {
                return;
            }

            await base.CleanAsync(files).ConfigureAwait(false);

            _tagManager.Clean(files);

            await _tagManager.Serialize().ConfigureAwait(false);

            var postManager = new RecentPostManager(_fileSystem, _formatter);
            await postManager.Serialize(await postManager.GetRecentPosts(ConvertingInfo.RecentPostsCount).ConfigureAwait(false)).ConfigureAwait(false);
        }