public void WithAngleBracketsTest() { string tweet = "(Debugging) <3 #idol2011"; string expected = "(Debugging) <3 <a href=\"https://twitter.com/#!/search?q=%23idol2011\" title=\"#idol2011\" class=\"tweet-url hashtag\">#idol2011</a>"; string actual = _autolink.AutoLink(tweet); Assert.AreEqual(expected, actual); tweet = "<link rel='true'>http://example.com</link>"; expected = "<link rel='true'><a href=\"http://example.com\">http://example.com</a></link>"; actual = _autolink.AutoLinkUrls(tweet); Assert.AreEqual(expected, actual); }
public void UsernameIncludeSymbolTest() { var autolink = new Autolink { NoFollow = true, UsernameIncludeSymbol = true }; string tweet = "Testing @mention and @mention/list"; string expected = "Testing <a class=\"tweet-url username\" href=\"https://twitter.com/mention\" rel=\"nofollow\">@mention</a> and <a class=\"tweet-url list-slug\" href=\"https://twitter.com/mention/list\" rel=\"nofollow\">@mention/list</a>"; string actual = autolink.AutoLink(tweet); Assert.AreEqual(expected, actual); }
public void UrlTargetTest() { var autolink = new Autolink { UrlTarget = "_blank", NoFollow = false }; string tweet = "http://test.com"; string expected = "<a href=\"http://test.com\" target=\"_blank\">http://test.com</a>"; string actual = autolink.AutoLink(tweet); Assert.AreEqual(expected, actual); }
public void SymbolTagTest() { var autolink = new Autolink { SymbolTag = "s", TextWithSymbolTag = "b", NoFollow = false }; string tweet = "#hash"; string expected = "<a href=\"https://twitter.com/#!/search?q=%23hash\" title=\"#hash\" class=\"tweet-url hashtag\"><s>#</s><b>hash</b></a>"; string actual = autolink.AutoLink(tweet); Assert.AreEqual(expected, actual); tweet = "@mention"; expected = "<s>@</s><a class=\"tweet-url username\" href=\"https://twitter.com/mention\"><b>mention</b></a>"; actual = autolink.AutoLink(tweet); Assert.AreEqual(expected, actual); autolink.UsernameIncludeSymbol = true; expected = "<a class=\"tweet-url username\" href=\"https://twitter.com/mention\"><s>@</s><b>mention</b></a>"; actual = autolink.AutoLink(tweet); Assert.AreEqual(expected, actual); }
public void AutolinkAll() { var failures = new List <string>(); foreach (var test in LoadTests <string>("autolink.yml", "all")) { try { string actual = autolink.AutoLink(test.Text); Assert.AreEqual(test.Expected, actual); } catch (Exception) { failures.Add(test.Description + ": " + test.Text); } } if (failures.Any()) { Assert.Fail(string.Join("\n", failures)); } }
public void UrlClassTest() { string tweet = "http://twitter.com"; string expected = "<a href=\"http://twitter.com\">http://twitter.com</a>"; string actual = this.instance.AutoLink(tweet); Assert.AreEqual(expected, actual); var autolink = new Autolink { UrlClass = "testClass", NoFollow = false }; autolink.UrlClass = "testClass"; expected = "<a href=\"http://twitter.com\" class=\"testClass\">http://twitter.com</a>"; actual = autolink.AutoLink(tweet); Assert.AreEqual(expected, actual); tweet = "#hash @tw"; string result = this.instance.AutoLink(tweet); Assert.IsTrue(result.Contains("class=\"" + this.instance.HashtagClass + "\"")); Assert.IsTrue(result.Contains("class=\"" + this.instance.UsernameClass + "\"")); Assert.IsFalse(result.Contains("class=\"testClass\"")); }