public void TestGetLinks() { var testTweet = new Tweet("yahoo.com google.com message"); var testList = new List<string>(1) { "http://yahoo.com" }; var testList2 = new List<string>(1) { "http://google.com" }; Assert.IsFalse(testList == _tweet.GetTopics()); Assert.IsTrue(testList2[0] == _tweet.GetLinks()[0]); Assert.IsTrue(testTweet.GetLinks().Contains("yahoo.com")); Assert.IsTrue(testTweet.GetLinks().Contains("google.com")); Assert.IsFalse(testTweet.GetLinks().Contains("message")); Assert.IsTrue(testTweet.GetLinks().Count == 2); }
public void TestRegexStrings() { //Testing Topic regex string "(#)((?:[A-Za-z0-9-_]*))" //Checking different tests like spaces and other markers interfering with the topic marker. var testTweet = new Tweet("#test # test ##test #@test @#test"); Assert.IsTrue(testTweet.GetTopics().Contains("#test")); Assert.IsTrue(testTweet.GetTopics().Contains("#")); Assert.IsFalse(testTweet.GetTopics().Contains("test")); Assert.IsFalse(testTweet.GetTopics().Contains("##test")); Assert.IsFalse(testTweet.GetTopics().Contains("#@test")); Assert.IsFalse(testTweet.GetTopics().Contains("@#test")); //Testing "(@)((?:[A-Za-z0-9-_]*))" //Checking different tests like spaces and other markers interfering with the topic marker. var testTweet2 = new Tweet("@test @ test @@test #@test @#test"); Assert.IsTrue(testTweet2.GetMentions().Contains("@test")); Assert.IsTrue(testTweet2.GetMentions().Contains("@")); Assert.IsFalse(testTweet2.GetMentions().Contains(" test")); Assert.IsFalse(testTweet2.GetMentions().Contains("@@test")); Assert.IsFalse(testTweet2.GetMentions().Contains("#@test")); Assert.IsFalse(testTweet2.GetMentions().Contains("@#test")); Assert.IsFalse(testTweet2.GetMentions().Contains("test")); //Testing "(http(s)?://)?([\w-]+\.)+[\w-]+(/\S\w[\w- ;,./?%&=]\S*)?" //Checking different tests like spaces and other markers interfering with the topic marker. var testTweet3 = new Tweet("http:// https:// google.com https://google.com website.net http://website.net"); Assert.IsTrue(testTweet3.GetLinks().Contains("google.com")); Assert.IsTrue(testTweet3.GetLinks().Contains("https://google.com")); Assert.IsTrue(testTweet3.GetLinks().Contains("http://website.net")); Assert.IsTrue(testTweet3.GetLinks().Contains("website.net")); Assert.IsFalse(testTweet3.GetLinks().Contains("http://")); Assert.IsFalse(testTweet3.GetLinks().Contains("https://")); }