Example #1
0
        public void TestGetRawTweet()
        {
            var newTweet = new Tweet("@child1 the #child did not go to the supermarket today google.com");

            Assert.IsTrue("@john went to the #supermarket http://google.com" == _tweet.GetRawTweet());
            Assert.IsFalse("@john did not go to the #supermarket http://google.com" == _tweet.GetRawTweet());
            Assert.IsTrue(newTweet.GetLength() == 65);

            Assert.IsTrue("@child1 the #child did not go to the supermarket today google.com" == newTweet.GetRawTweet());
            Assert.IsFalse("@child1 the #child did not go to the recrd store today google.com" == _tweet.GetRawTweet());
        }
Example #2
0
        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);
        }
Example #3
0
        public void TestGetTopics()
        {
            var testTweet = new Tweet("#coffeeshop #supermarket message");
            var testList = new List<string>(1) { "coffee shop" };
            var testList2 = new List<string>(1) { "#supermarket" };

            Assert.IsTrue(testList != _tweet.GetTopics());
            Assert.IsTrue(testList2[0] == _tweet.GetTopics()[0]);

            Assert.IsTrue(testTweet.GetTopics().Contains("#coffeeshop"));
            Assert.IsTrue(testTweet.GetTopics().Contains("#supermarket"));
            Assert.IsFalse(testTweet.GetTopics().Contains("#message"));

            Assert.IsTrue(testTweet.GetTopics().Count == 2);
        }
Example #4
0
        public void TestGetMentions()
        {
            var testTweet = new Tweet("@john @bob message");
            var testList = new List<string>(1) {"bob"};
            var testList2 = new List<string>(1) { "@john" };

            Assert.IsTrue(testList2[0] == _tweet.GetMentions()[0]);
            Assert.IsFalse(testList == _tweet.GetMentions());

            Assert.IsTrue(testTweet.GetMentions().Contains("@john"));
            Assert.IsTrue(testTweet.GetMentions().Contains("@bob"));
            Assert.IsFalse(testTweet.GetMentions().Contains("@message"));

            Assert.IsTrue(testTweet.GetMentions().Count == 2);

        }
Example #5
0
        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://"));
        }
Example #6
0
 //Gets tweets from the text file that is written into from the python parsing script.
 public static List<Tweet> GetTweets()
 {
     var list = new List<Tweet>();
     string line;
     var stream = new StreamReader("tweets.txt");
     while ((line = stream.ReadLine()) != null)
     {
         var tempTweet = new Tweet(line);
         list.Add(tempTweet);
     }
     return list;
 }