public void ContainsPageLink_Should_Return_False_When_Title_Does_Not_Exist_In_Creole()
        {
            // Arrange
            CreoleParser      parser  = new CreoleParser(_applicationSettings, _siteSettings);
            MarkupLinkUpdater updater = new MarkupLinkUpdater(parser);

            string text = "here is a nice [[the internal wiki page title|the link text]]";

            // Act
            bool hasLink = updater.ContainsPageLink(text, "page title");

            // Assert
            Assert.That(hasLink, Is.False);
        }
        public void ContainsPageLink_Should_Return_True_When_Title_Exists_In_Markdown()
        {
            // Arrange
            MarkdownParser    parser  = new MarkdownParser();
            MarkupLinkUpdater updater = new MarkupLinkUpdater(parser);

            string text = "here is a nice [the link text](the-internal-wiki-page-title)";

            // Act
            bool hasLink = updater.ContainsPageLink(text, "the internal wiki page title");

            // Assert
            Assert.That(hasLink, Is.True);
        }
        public void ContainsPageLink_Should_Return_False_When_Title_Has_No_Dashes_In_Markdown()
        {
            // Arrange
            MarkdownParser    parser  = new MarkdownParser();
            MarkupLinkUpdater updater = new MarkupLinkUpdater(parser);

            string text = "here is a nice [the link text](Markdown enforces dashes for spaces in urls)";

            // Act
            bool hasLink = updater.ContainsPageLink(text, "Markdown enforces dashes for spaces in urls");

            // Assert
            Assert.That(hasLink, Is.False);
        }
        public void containspagelink_should_return_false_when_title_does_not_exist_in_creole()
        {
            // Arrange
            CreoleParser      parser  = new CreoleParser(_applicationSettings, _siteSettings);
            MarkupLinkUpdater updater = new MarkupLinkUpdater(parser);

            string text = "here is a nice [[the internal wiki page title|the link text]]";

            // Act
            bool hasLink = updater.ContainsPageLink(text, "page title");

            // Assert
            Assert.That(hasLink, Is.False);
        }
        public void containspagelink_should_return_false_when_title_has_no_dashes_in_markdown()
        {
            // Arrange
            MarkdownParser    parser  = new MarkdownParser();
            MarkupLinkUpdater updater = new MarkupLinkUpdater(parser);

            string text = "here is a nice [the link text](Markdown enforces dashes for spaces in urls)";

            // Act
            bool hasLink = updater.ContainsPageLink(text, "Markdown enforces dashes for spaces in urls");

            // Assert
            Assert.That(hasLink, Is.False);
        }
        public void containspagelink_should_return_false_when_title_does_not_exist_in_markdown()
        {
            // Arrange
            MarkdownParser    parser  = new MarkdownParser();
            MarkupLinkUpdater updater = new MarkupLinkUpdater(parser);

            string text = "here is a nice [the link text](the-internal-wiki-page-title)";

            // Act
            bool hasLink = updater.ContainsPageLink(text, "page title");

            // Assert
            Assert.That(hasLink, Is.False);
        }
Exemple #7
0
        public void containspagelink_should_return_false_when_title_does_not_exist_in_creole()
        {
            // Arrange
            var parser = new MarkdigParser();
            MarkupLinkUpdater updater = new MarkupLinkUpdater(parser);

            string text = "here is a nice [[the internal wiki page title|the link text]]";

            // Act
            bool hasLink = updater.ContainsPageLink(text, "page title");

            // Assert
            Assert.False(hasLink);
        }
Exemple #8
0
        public void containspagelink_should_return_true_when_title_exists_in_markdown()
        {
            // Arrange
            MarkdigParser     parser  = new MarkdigParser();
            MarkupLinkUpdater updater = new MarkupLinkUpdater(parser);

            string text = "here is a nice [the link text](the-internal-wiki-page-title)";

            // Act
            bool hasLink = updater.ContainsPageLink(text, "the internal wiki page title");

            // Assert
            Assert.True(hasLink);
        }
Exemple #9
0
        /// <summary>
        /// Updates all links in pages to another page, when that page's title is changed.
        /// </summary>
        /// <param name="oldTitle">The previous page title.</param>
        /// <param name="newTitle">The new page title.</param>
        public void UpdateLinksToPage(string oldTitle, string newTitle)
        {
            bool shouldClearCache = false;

            foreach (PageContent content in Repository.AllPageContents())
            {
                if (_markupLinkUpdater.ContainsPageLink(content.Text, oldTitle))
                {
                    content.Text = _markupLinkUpdater.ReplacePageLinks(content.Text, oldTitle, newTitle);
                    Repository.UpdatePageContent(content);

                    shouldClearCache = true;
                }
            }

            if (shouldClearCache)
            {
                _pageViewModelCache.RemoveAll();
                _listCache.RemoveAll();
            }
        }