Beispiel #1
0
        public void TalkHeaderDefaultsortChange()
        {
            string start = @"
==Foo==
bar", df = @"{{DEFAULTSORT:Bert}}";

            string articleText = start + "\r\n" + df;

            TalkPageHeaders.ProcessTalkPage(ref articleText, DEFAULTSORT.MoveToBottom);
            Assert.AreEqual(start + "\r\n" + "\r\n" + df, articleText);

            articleText = start + df;

            TalkPageHeaders.ProcessTalkPage(ref articleText, DEFAULTSORT.MoveToTop);
            Assert.AreEqual(df + "\r\n" + start, articleText);

            articleText = start + df;

            TalkPageHeaders.ProcessTalkPage(ref articleText, DEFAULTSORT.NoChange);
            Assert.AreEqual(start + df, articleText);

            string df2 = @"{{DEFAULTSORT:}}";

            articleText = start + df2;

            TalkPageHeaders.ProcessTalkPage(ref articleText, DEFAULTSORT.MoveToBottom);
            Assert.AreEqual(start, articleText, "defaultsort with no key removed");

            articleText = start + df2;

            TalkPageHeaders.ProcessTalkPage(ref articleText, DEFAULTSORT.MoveToTop);
            Assert.AreEqual(start, articleText, "defaultsort with no key removed");
        }
Beispiel #2
0
        public void WikiProjectBannerShellBLP()
        {
            const string a = @"{{WikiProjectBannerShell|blp=yes|1={{WPBiography|foo=bar|living=yes}}}}";

            Assert.AreEqual(a, TalkPageHeaders.WikiProjectBannerShell(a + "{{Blp}}"));
            Assert.AreEqual(a, TalkPageHeaders.WikiProjectBannerShell(a.Replace("blp=yes", "blp=") + "{{Blp}}"));
            Assert.AreEqual("{{Blp}}", TalkPageHeaders.WikiProjectBannerShell("{{Blp}}"));
        }
Beispiel #3
0
        public void AddMissingFirstCommentHeader()
        {
            const string comment       = @"
Hello world comment.";
            string       newSummary    = "";
            string       articleTextIn = articleTextHeader + comment;

            // plain comment
            TalkPageHeaders.ProcessTalkPage(ref articleTextIn, ref newSummary, DEFAULTSORT.NoChange);

            Assert.AreEqual(articleTextIn, articleTextHeader + "\r\n" + @"
==Untitled==
Hello world comment.");
            Assert.IsTrue(newSummary.Contains("Added missing comments section header"));

            // idented comment2
            articleTextIn = articleTextHeader + @"
*Hello world comment2.";
            newSummary    = "";
            TalkPageHeaders.ProcessTalkPage(ref articleTextIn, ref newSummary, DEFAULTSORT.NoChange);

            Assert.AreEqual(articleTextIn, articleTextHeader + "\r\n" + @"
==Untitled==
*Hello world comment2.");
            Assert.IsTrue(newSummary.Contains("Added missing comments section header"));

            // idented comment3
            articleTextIn = articleTextHeader + @"
:Hello world comment3.";
            newSummary    = "";
            TalkPageHeaders.ProcessTalkPage(ref articleTextIn, ref newSummary, DEFAULTSORT.NoChange);

            Assert.AreEqual(articleTextIn, articleTextHeader + "\r\n" + @"
==Untitled==
:Hello world comment3.");
            Assert.IsTrue(newSummary.Contains("Added missing comments section header"));

            // quoted comment
            articleTextIn = articleTextHeader + @"
""Hello world comment4"".";
            newSummary    = "";
            TalkPageHeaders.ProcessTalkPage(ref articleTextIn, ref newSummary, DEFAULTSORT.NoChange);

            Assert.AreEqual(articleTextIn, articleTextHeader + "\r\n" + @"
==Untitled==
""Hello world comment4"".");
            Assert.IsTrue(newSummary.Contains("Added missing comments section header"));

            // heading level 3 changed to level 2
            articleTextIn = articleTextHeader + "\r\n" + @"===Foo bar===
*Hello world comment2.";
            newSummary    = "";
            TalkPageHeaders.ProcessTalkPage(ref articleTextIn, ref newSummary, DEFAULTSORT.NoChange);

            Assert.IsTrue(articleTextIn.Contains(@"==Foo bar=="));
            Assert.IsFalse(articleTextIn.Contains(@"==Untitled=="));
            Assert.IsTrue(newSummary.Contains("Corrected comments section header"));
        }
Beispiel #4
0
        public void RenameTalkHeader()
        {
            string talkheader = @"{{talkheader|noarchive=no}}", talkrest = @"==hello==
hello talk";
            string articleText = talkrest + "\r\n" + talkheader;

            TalkPageHeaders.ProcessTalkPage(ref articleText, DEFAULTSORT.NoChange);

            Assert.AreEqual(@"{{Talk header|noarchive=no}}" + "\r\n" + talkrest + "\r\n", articleText, "renamed to upper case with space");
        }
Beispiel #5
0
        public void AddWikiProjectBannerShell()
        {
            const string a = @"{{WikiProject a|text}}", b = @"{{WikiProject b|text}}", c = @"{{WikiProject c|text}}", d = @"{{WikiProject d|text}}";

            Assert.AreEqual(a, TalkPageHeaders.WikiProjectBannerShell(a));
            Assert.AreEqual(a + b, TalkPageHeaders.WikiProjectBannerShell(a + b));
            Assert.AreEqual(a + b + c, TalkPageHeaders.WikiProjectBannerShell(a + b + c));
            Assert.AreEqual(@"{{WikiProjectBannerShell
|1=" + "\r\n" + a + "\r\n" + b + "\r\n" + c + "\r\n" + d + "\r\n" + @"}}", TalkPageHeaders.WikiProjectBannerShell(a + b + c + d));
        }
Beispiel #6
0
        public void WikiProjectBannerShellWPBiography()
        {
            Assert.AreEqual(@"{{WikiProjectBannerShell|1={{WPBiography|foo=bar}}}}", TalkPageHeaders.WikiProjectBannerShell(@"{{WikiProjectBannerShell|1={{WPBiography|foo=bar}}}}"));

            Assert.AreEqual(@"{{WikiProjectBannerShell|blp=yes|1={{WPBiography|foo=bar|living=yes}}}}", TalkPageHeaders.WikiProjectBannerShell(@"{{WikiProjectBannerShell|blp=|1={{WPBiography|foo=bar|living=yes}}}}"));
            Assert.AreEqual(@"{{WikiProjectBannerShell|activepol=yes|1={{WPBiography|foo=bar|activepol=yes}}}}", TalkPageHeaders.WikiProjectBannerShell(@"{{WikiProjectBannerShell|activepol=abc|1={{WPBiography|foo=bar|activepol=yes}}}}"));
            Assert.AreEqual(@"{{WikiProjectBannerShell|blpo=yes|1={{WPBiography|foo=bar|blpo=yes}}}}", TalkPageHeaders.WikiProjectBannerShell(@"{{WikiProjectBannerShell|blpo=|1={{WPBiography|foo=bar|blpo=yes}}}}"));
            Assert.AreEqual(@"{{WikiProjectBannerShell|blpo=|1={{WPBiography|foo=bar|blpo=no}}}}", TalkPageHeaders.WikiProjectBannerShell(@"{{WikiProjectBannerShell|blpo=|1={{WPBiography|foo=bar|blpo=no}}}}"));

            Assert.AreEqual(@"{{WikiProjectBannerShell|1={{WPBiography|foo=bar|living=no}}}}", TalkPageHeaders.WikiProjectBannerShell(@"{{WikiProjectBannerShell|blp=yes|1={{WPBiography|foo=bar|living=no}}}}"));
        }
Beispiel #7
0
        public void RenameTalkHeader()
        {
            string talkheader = @"{{talkheader|noarchive=no}}", talkrest = @"==hello==
hello talk";
            string articleText = talkrest + "\r\n" + talkheader, newSummary = "";

            TalkPageHeaders.ProcessTalkPage(ref articleText, ref newSummary, DEFAULTSORT.NoChange);

            Assert.AreEqual(@"{{talk header|noarchive=no}}" + "\r\n" + talkrest + "\r\n", articleText);
            Assert.IsTrue(newSummary.Contains("{{tl|Talk header}} given top billing"));
        }
Beispiel #8
0
        public void WikiProjectBannerShellUnnamedParam()
        {
            Assert.AreEqual(@"{{WikiProjectBannerShell|1={{WPBiography|foo=bar}}}}", TalkPageHeaders.WikiProjectBannerShell(@"{{WikiProjectBannerShell|{{WPBiography|foo=bar}}}}"), "1= added when missing");
            Assert.AreEqual(@"{{WikiProjectBannerShell|1=
{{WPBiography|foo=bar}}}}", TalkPageHeaders.WikiProjectBannerShell(@"{{WikiProjectBannerShell|
{{WPBiography|foo=bar}}}}"));

            const string otherUnnamed = @"{{WikiProjectBannerShell|random}}";

            Assert.AreEqual(otherUnnamed, TalkPageHeaders.WikiProjectBannerShell(otherUnnamed), "other unknown parameter not named 1=");
        }
Beispiel #9
0
        public void SkipToTalk()
        {
            string articleText = @"{{Skiptotoc}}", STT = @"{{Skip to talk}}";

            TalkPageHeaders.ProcessTalkPage(ref articleText, DEFAULTSORT.NoChange);
            Assert.AreEqual(STT + "\r\n", articleText);

            articleText = @"{{skiptotoctalk}}";

            TalkPageHeaders.ProcessTalkPage(ref articleText, DEFAULTSORT.NoChange);
            Assert.AreEqual(STT + "\r\n", articleText);
        }
Beispiel #10
0
        public void SkipToTalk()
        {
            string articleText = @"{{Skiptotoc}}", newSummary = "", STT = @"{{Skip to talk}}";

            TalkPageHeaders.ProcessTalkPage(ref articleText, ref newSummary, DEFAULTSORT.NoChange);
            Assert.AreEqual(STT + "\r\n", articleText);
            Assert.IsTrue(newSummary.Contains("Skip to talk"));

            articleText = @"{{skiptotoctalk}}";
            newSummary  = "";
            TalkPageHeaders.ProcessTalkPage(ref articleText, ref newSummary, DEFAULTSORT.NoChange);
            Assert.AreEqual(STT + "\r\n", articleText);
            Assert.IsTrue(newSummary.Contains("Skip to talk"));
        }
Beispiel #11
0
        public void RemoveTemplateNamespace()
        {
            string T1 = @"{{Template:Foo}}", T2 = @"{{Template:Foo}}
==Section==
{{Template:Bar}}";

            Assert.IsFalse(TalkPageHeaders.ProcessTalkPage(ref T1, DEFAULTSORT.NoChange));
            Assert.AreEqual("{{Foo}}", T1, "template namespace removed");

            Assert.IsFalse(TalkPageHeaders.ProcessTalkPage(ref T2, DEFAULTSORT.NoChange));
            Assert.AreEqual(@"{{Foo}}
==Section==
{{Template:Bar}}", T2, "changes only made in zeroth section");
        }
Beispiel #12
0
        public void WikiProjectBannerShellMisc()
        {
            const string a = @"{{wpbs|1=|banner collapsed=no|
{{WPBiography|living=yes|class=Start|priority=|listas=Hill, A}}
{{WikiProject Gender Studies}}
{{WikiProject Oklahoma}}
}}", b = @"{{WikiProjectBannerShell|banner collapsed=no|1=
{{WPBiography|living=yes|class=Start|priority=|listas=Hill, A}}
{{WikiProject Gender Studies}}
{{WikiProject Oklahoma}}
| blp=yes
}}";

            Assert.AreEqual(b, TalkPageHeaders.WikiProjectBannerShell(a));
        }
Beispiel #13
0
        public void MoveTalkHeader()
        {
            string talkheader = @"{{talk header|noarchive=no|search=no|arpol=no|wp=no|disclaimer=no|shortcut1|shortcut2}}", talkrest = @"==hello==
hello talk";
            string articleText = talkrest + "\r\n" + talkheader;

            TalkPageHeaders.ProcessTalkPage(ref articleText, ref newSummary, DEFAULTSORT.NoChange);

            Assert.AreEqual(talkheader + "\r\n" + talkrest + "\r\n", articleText);
            Assert.IsTrue(newSummary.Contains("{{tl|Talk header}} given top billing"));

            // handles {{talk header}} on same line as other template
            string WPBS = @"{{WikiProjectBannerShell|blp=yes|1=
{{OH-Project|class=B|importance=Low|nested=yes}}
{{WPBiography|living=yes|class=B|priority=Low|filmbio-work-group=yes|nested=yes|listas=Parker, Sarah Jessica}}
{{WikiProject Cincinnati|class=B|importance=mid|nested=yes}}
}}", rest = "\r\n" + @"==Song Jessie by Joshua Kadison==
In the article it says that above mentioned";

            articleText = WPBS + @"{{Talkheader}}" + rest;

            TalkPageHeaders.ProcessTalkPage(ref articleText, ref newSummary, DEFAULTSORT.NoChange);

            Assert.AreEqual(@"{{talk header}}" + "\r\n" + WPBS + rest, articleText);
            Assert.IsTrue(newSummary.Contains("{{tl|Talk header}} given top billing"));

            // no change if already at top
            articleText = talkheader + "\r\n" + talkrest;
            newSummary  = "";
            TalkPageHeaders.ProcessTalkPage(ref articleText, ref newSummary, DEFAULTSORT.NoChange);
            Assert.AreEqual(talkheader + "\r\n" + talkrest, articleText);
            Assert.IsFalse(newSummary.Contains("{{tl|Talk header}} given top billing"));

            // no change if no talk header
            articleText = talkrest;
            newSummary  = "";
            TalkPageHeaders.ProcessTalkPage(ref articleText, ref newSummary, DEFAULTSORT.NoChange);
            Assert.AreEqual(talkrest, articleText);
            Assert.IsFalse(newSummary.Contains("{{tl|Talk header}} given top billing"));
        }
Beispiel #14
0
        /// <summary>
        /// Extracts categories from the article text; removes duplicate categories, cleans whitespace and underscores
        /// </summary>
        /// <param name="articleText">The wiki text of the article.</param>
        /// <param name="articleTitle">Title of the article</param>
        /// <returns>The cleaned page categories in a single string</returns>
        public string RemoveCats(ref string articleText, string articleTitle)
        {
            List <string> categoryList        = new List <string>();
            string        originalArticleText = articleText;

            // allow comments between categories, and keep them in the same place, but don't grab any comment just after the last category
            Regex r = new Regex(@"<!-- [^<>]*?\[\[\s*" + Variables.NamespacesCaseInsensitive[Namespace.Category]
                                + @".*?(\]\]|\|.*?\]\]).*?-->|\[\["
                                + Variables.NamespacesCaseInsensitive[Namespace.Category]
                                + @".*?(\]\]|\|.*?\]\])(\s*⌊⌊⌊⌊\d{1,4}⌋⌋⌋⌋|\s*<!--.*?-->(?=\r\n\[\[\s*" + Variables.NamespacesCaseInsensitive[Namespace.Category]
                                + @"))?", RegexOptions.Singleline);

            MatchCollection matches = r.Matches(articleText);

            foreach (Match m in matches)
            {
                if (!Regex.IsMatch(m.Value, @"\[\[Category:(Pages|Categories|Articles) for deletion\]\]"))
                {
                    categoryList.Add(m.Value);
                }
            }

            articleText = Tools.RemoveMatches(articleText, matches);

            // if category tidying has changed comments/nowikis return with no changes – we've pulled a cat from a comment
            if (!UnformattedTextNotChanged(originalArticleText, articleText))
            {
                articleText = originalArticleText;
                return("");
            }

            if (AddCatKey)
            {
                categoryList = CatKeyer(categoryList, articleTitle);
            }

            if (CatCommentRegex.IsMatch(articleText))
            {
                string catComment = CatCommentRegex.Match(articleText).Value;
                articleText = articleText.Replace(catComment, "");
                categoryList.Insert(0, catComment);
            }

            MatchCollection mc = WikiRegexes.Defaultsort.Matches(articleText);

            if (mc.Count > 1)
            {
                throw new ArgumentException("Page contains multiple {{DEFAULTSORTS}} tags. Metadata sorting cancelled");
            }

            string defaultSort = "";

            // ignore commented out DEFAULTSORT – http://en.wikipedia.org/wiki/Wikipedia_talk:AutoWikiBrowser/Bugs#Moving_DEFAULTSORT_in_HTML_comments
            if (mc.Count > 0 && WikiRegexes.Defaultsort.Matches(WikiRegexes.Comments.Replace(articleText, "")).Count == mc.Count)
            {
                defaultSort = mc[0].Value;
            }

            if (!string.IsNullOrEmpty(defaultSort))
            {
                articleText = articleText.Replace(defaultSort, "");
            }

            if (!string.IsNullOrEmpty(defaultSort) && defaultSort.ToUpper().Contains("DEFAULTSORT"))
            {
                defaultSort = TalkPageHeaders.FormatDefaultSort(defaultSort);
            }
            if (!string.IsNullOrEmpty(defaultSort))
            {
                defaultSort += "\r\n";
            }

            return(defaultSort + ListToString(categoryList));
        }
Beispiel #15
0
        /// <summary>
        /// Extracts categories from the article text; removes duplicate categories, cleans whitespace and underscores
        /// </summary>
        /// <param name="articleText"></param>
        /// <param name="articleTitle"></param>
        /// <returns></returns>
        public string RemoveCats(ref string articleText, string articleTitle)
        {
            List <string> categoryList = new List <string>();

            // http://en.wikipedia.org/wiki/Wikipedia_talk:AutoWikiBrowser/Bugs#Comments_get_removed_from_between_categories
            // allow comments between categories, and keep them in the same place, but don't grab any comment just after the last category
            Regex r = new Regex("<!-- ? ?\\[\\[" + Variables.NamespacesCaseInsensitive[Namespace.Category]
                                + ".*?(\\]\\]|\\|.*?\\]\\]).*?-->|\\[\\["
                                + Variables.NamespacesCaseInsensitive[Namespace.Category]
                                + ".*?(\\]\\]|\\|.*?\\]\\])( {0,4}⌊⌊⌊⌊[0-9]{1,4}⌋⌋⌋⌋|\\s*<!--.*?-->(?=\r\n\\[\\[))?", RegexOptions.Singleline);

            MatchCollection matches = r.Matches(articleText);

            foreach (Match m in matches)
            {
                if (!Regex.IsMatch(m.Value, "\\[\\[Category:(Pages|Categories|Articles) for deletion\\]\\]"))
                {
                    categoryList.Add(m.Value);
                }
            }

            articleText = Tools.RemoveMatches(articleText, matches);

            if (AddCatKey)
            {
                categoryList = CatKeyer(categoryList, articleTitle);
            }

            if (CatCommentRegex.IsMatch(articleText))
            {
                string catComment = CatCommentRegex.Match(articleText).Value;
                articleText = articleText.Replace(catComment, "");
                categoryList.Insert(0, catComment);
            }

            MatchCollection mc = WikiRegexes.Defaultsort.Matches(articleText);

            if (mc.Count > 1)
            {
                throw new ArgumentException("Page contains multiple {{DEFAULTSORTS}} tags. Metadata sorting cancelled");
            }

            string defaultSort = "";

            if (mc.Count > 0)
            {
                defaultSort = mc[0].Value;
            }

            if (!string.IsNullOrEmpty(defaultSort))
            {
                articleText = articleText.Replace(defaultSort, "");
            }

            if (!string.IsNullOrEmpty(defaultSort) && defaultSort.ToUpper().Contains("DEFAULTSORT"))
            {
                defaultSort = TalkPageHeaders.FormatDefaultSort(defaultSort);
            }
            if (!string.IsNullOrEmpty(defaultSort))
            {
                defaultSort += "\r\n";
            }

            // on en-wiki find any {{Lifetime}} template and move directly after categories
            string lifetime = "";

            if (Variables.LangCode == LangCodeEnum.en)
            {
                lifetime = WikiRegexes.Lifetime.Match(articleText).Value;

                if (!string.IsNullOrEmpty(lifetime))
                {
                    articleText = articleText.Replace(lifetime, "");

                    // http://en.wikipedia.org/wiki/Wikipedia_talk:AutoWikiBrowser/Bugs#Blank_lines_after_Lifetime
                    lifetime += "\r\n";
                }
            }

            return(defaultSort + ListToString(categoryList) + lifetime);
        }
        public string removeCats(ref string ArticleText, string ArticleTitle)
        {
            List <string> categoryList = new List <string>();
            string        x            = "";

            Regex r = new Regex("<!-- ? ?\\[\\[" + Variables.NamespacesCaseInsensitive[14] + ".*?(\\]\\]|\\|.*?\\]\\]).*?-->|\\[\\[" + Variables.NamespacesCaseInsensitive[14] + ".*?(\\]\\]|\\|.*?\\]\\])( {0,4}⌊⌊⌊⌊[0-9]{1,4}⌋⌋⌋⌋)?");

            MatchCollection matches = r.Matches(ArticleText);

            foreach (Match m in matches)
            {
                x = m.Value;
                //add to array, replace underscores with spaces, ignore=
                if (!Regex.IsMatch(x, "\\[\\[Category:(Pages|Categories|Articles) for deletion\\]\\]"))
                {
                    categoryList.Add(x.Replace("_", " "));
                }
            }

            ArticleText = Tools.RemoveMatches(ArticleText, matches);

            if (parser.addCatKey)
            {
                categoryList = catKeyer(categoryList, ArticleTitle);
            }

            if (CatCommentRegex.IsMatch(ArticleText))
            {
                string catComment = CatCommentRegex.Match(ArticleText).Value;
                ArticleText = ArticleText.Replace(catComment, "");
                categoryList.Insert(0, catComment);
            }

            MatchCollection mc = WikiRegexes.Defaultsort.Matches(ArticleText);

            if (mc.Count > 1)
            {
                throw new ArgumentException("Page contains multiple {{DEFAULTSORTS}} tags. Metadata sorting cancelled");
            }

            string defaultSort = "";

            if (mc.Count > 0)
            {
                defaultSort = mc[0].Value;
            }

            if (!string.IsNullOrEmpty(defaultSort))
            {
                ArticleText = ArticleText.Replace(defaultSort, "");
            }

            if (defaultSort.ToUpper().Contains("DEFAULTSORT"))
            {
                defaultSort = TalkPageHeaders.FormatDefaultSort(defaultSort);
            }
            if (!string.IsNullOrEmpty(defaultSort))
            {
                defaultSort += "\r\n";
            }

            return(defaultSort + ListToString(categoryList));
        }
Beispiel #17
0
        public void AddMissingFirstCommentHeaderNoChanges()
        {
            // no change – header already
            string articleTextIn = articleTextHeader + @"
==Question==
:Hello world comment3.";

            newSummary = "";
            TalkPageHeaders.ProcessTalkPage(ref articleTextIn, ref newSummary, DEFAULTSORT.NoChange);

            Assert.AreEqual(articleTextIn, articleTextHeader + @"
==Question==
:Hello world comment3.");
            Assert.IsFalse(newSummary.Contains("Added missing comments section header"));

            // no change – already header at top
            articleTextIn = @"
{{Some template}}
==Question==
:Hello world comment3.";

            newSummary = "";
            TalkPageHeaders.ProcessTalkPage(ref articleTextIn, ref newSummary, DEFAULTSORT.NoChange);

            Assert.AreEqual(@"
{{Some template}}
==Question==
:Hello world comment3.", articleTextIn);
            Assert.IsFalse(newSummary.Contains("Added missing comments section header"));

            // no change – already header at top 2
            articleTextIn = @"
==Question==
{{Some template}}
:Hello world comment3.";

            newSummary = "";
            TalkPageHeaders.ProcessTalkPage(ref articleTextIn, ref newSummary, DEFAULTSORT.NoChange);

            Assert.AreEqual(@"
==Question==
{{Some template}}
:Hello world comment3.", articleTextIn);
            Assert.IsFalse(newSummary.Contains("Added missing comments section header"));

            // no change – no comments
            articleTextIn = @"
==Question==
{{Some template}}";

            newSummary = "";
            TalkPageHeaders.ProcessTalkPage(ref articleTextIn, ref newSummary, DEFAULTSORT.NoChange);

            Assert.AreEqual(@"
==Question==
{{Some template}}", articleTextIn);
            Assert.IsFalse(newSummary.Contains("Added missing comments section header"));

            // no change – only text in template
            articleTextIn = @"
{{foo|
bar|
end}}";

            newSummary = "";
            TalkPageHeaders.ProcessTalkPage(ref articleTextIn, ref newSummary, DEFAULTSORT.NoChange);

            Assert.AreEqual(@"
{{foo|
bar|
end}}", articleTextIn);
            Assert.IsFalse(newSummary.Contains("Added missing comments section header"));

            // no change – only TOC
            articleTextIn = @"
__TOC__";

            newSummary = "";
            TalkPageHeaders.ProcessTalkPage(ref articleTextIn, ref newSummary, DEFAULTSORT.NoChange);

            Assert.AreEqual(@"
__TOC__", articleTextIn);
            Assert.IsFalse(newSummary.Contains("Added missing comments section header"));

            // no change -- only in template
            const string allInTemplate = @"{{archive box|
*[[/Archive: GA review|Good Article review]]}}

== Explanation of Wright's work in ''Certaine Errors'' ==";

            articleTextIn = allInTemplate;
            newSummary    = "";
            TalkPageHeaders.ProcessTalkPage(ref articleTextIn, ref newSummary, DEFAULTSORT.NoChange);

            Assert.AreEqual(allInTemplate, articleTextIn);
            Assert.IsFalse(newSummary.Contains("Added missing comments section header"));
        }
Beispiel #18
0
        public void AddMissingFirstCommentHeaderNoChanges()
        {
            // no change – header already
            string articleTextIn = articleTextHeader + @"
==Question==
:Hello world comment3.";


            TalkPageHeaders.ProcessTalkPage(ref articleTextIn, DEFAULTSORT.NoChange);

            Assert.AreEqual(articleTextIn, articleTextHeader + @"
==Question==
:Hello world comment3.");

            // no change – already header at top
            articleTextIn = @"
{{Some template}}
==Question==
:Hello world comment3.";


            TalkPageHeaders.ProcessTalkPage(ref articleTextIn, DEFAULTSORT.NoChange);

            Assert.AreEqual(@"
{{Some template}}
==Question==
:Hello world comment3.", articleTextIn);

            // no change – already header at top 2
            articleTextIn = @"
==Question==
{{Some template}}
:Hello world comment3.";

            TalkPageHeaders.ProcessTalkPage(ref articleTextIn, DEFAULTSORT.NoChange);

            Assert.AreEqual(@"
==Question==
{{Some template}}
:Hello world comment3.", articleTextIn);

            // no change – no comments
            articleTextIn = @"
==Question==
{{Some template}}";

            TalkPageHeaders.ProcessTalkPage(ref articleTextIn, DEFAULTSORT.NoChange);

            Assert.AreEqual(@"
==Question==
{{Some template}}", articleTextIn);

            // no change – only text in template
            articleTextIn = @"
{{foo|
bar|
end}}";

            TalkPageHeaders.ProcessTalkPage(ref articleTextIn, DEFAULTSORT.NoChange);

            Assert.AreEqual(@"
{{foo|
bar|
end}}", articleTextIn);

            // no change – only comments
            articleTextIn = @"
<!--
foo
-->";

            TalkPageHeaders.ProcessTalkPage(ref articleTextIn, DEFAULTSORT.NoChange);

            Assert.AreEqual(@"
<!--
foo
-->", articleTextIn);

            // no change – only TOC
            articleTextIn = @"
__TOC__";

            TalkPageHeaders.ProcessTalkPage(ref articleTextIn, DEFAULTSORT.NoChange);

            Assert.AreEqual(@"
__TOC__", articleTextIn);

            // no change -- only in template
            const string allInTemplate = @"{{archive box|
*[[/Archive: GA review|Good Article review]]}}

== Explanation of Wright's work in ''Certaine Errors'' ==";

            articleTextIn = allInTemplate;

            TalkPageHeaders.ProcessTalkPage(ref articleTextIn, DEFAULTSORT.NoChange);

            Assert.AreEqual(allInTemplate, articleTextIn);

            // no change -- only after template on same line
            // http://en.wikipedia.org/wiki/Wikipedia_talk:AutoWikiBrowser/Bugs#Section_header_added_in_wrong_position
            const string allAfterTemplate = @"{{archive box|words}} extra foo

{{another one}}";

            articleTextIn = allAfterTemplate;

            TalkPageHeaders.ProcessTalkPage(ref articleTextIn, DEFAULTSORT.NoChange);

            Assert.AreEqual(allAfterTemplate, articleTextIn);
        }
Beispiel #19
0
        public void WikiProjectBannerShellRedirects()
        {
            string red1 = @"{{WPBS}}", WikiProjectBannerShell = @"{{WikiProjectBannerShell}}";

            Assert.AreEqual(WikiProjectBannerShell, TalkPageHeaders.WikiProjectBannerShell(red1));
        }
Beispiel #20
0
 public void WikiProjectBannerShellDupeParameters()
 {
     Assert.AreEqual(@"{{WikiProjectBannerShell|blp=yes}}", TalkPageHeaders.WikiProjectBannerShell(@"{{WikiProjectBannerShell|blp=yes|blp=yes}}"));
 }
Beispiel #21
0
 public void WikiProjectBannerShellUnneededParams()
 {
     Assert.AreEqual(@"{{WikiProjectBannerShell}}", TalkPageHeaders.WikiProjectBannerShell(@"{{WikiProjectBannerShell|blp=no|activepol=no|collapsed=no}}"));
 }