Пример #1
0
        public void tweetFailTextAnalysis()
        {
            Control c = new Control();
            string _head = "T123456789";
            string _body = "@sam\r\nThis tweet is too long.Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin eget lobortis sapien. Proin tempor, lectus nec eleifend condimentum, nisl ex laoreet ipsum, sed placerat elit ante a nulla. Pellentesque id odio non orci convallis vehicula vel vel ante. Vestibulum tincidunt vitae diam in aliquam. Ut efficitur enim augue, at maximus arcu gravida in. Nullam leo enim, feugiat in laoreet at, interdum sit amet lacus. Aenean sed augue elementum, accumsan ante quis, consequat lectus. In in malesuada nibh, eget faucibus nunc. In lobortis tincidunt urna. Fusce a porttitor tellus. Praesent facilisis porttitor diam, ut congue nisi molestie vitae. Etiam faucibus nibh sit amet lectus ullamcorper, et pretium sapien dictum. Pellentesque volutpat diam ligula, pellentesque interdum metus commodo eget. Suspendisse fringilla pellentesque neque, vestibulum blandit enim euismod consectetur. Pellentesque nec egestas quam. Morbi at efficitur erat. Vivamus ornare eros diam, eget gravida sapien dapibus id. Phasellus dictum dictum nullam.";

            Tweet testTweet = new Tweet(_head, _body);

            testTweet.anaylizeMessage();
        }
Пример #2
0
        public void tweetFailSenderAnalysis()
        {
            Control c = new Control();
            string _head = "T123456789";
            string _body = "an invalid twitter username as sender\r\nThis is a tweet that will fail analysis.";

            Tweet testTweet = new Tweet(_head, _body);

            testTweet.anaylizeMessage();
        }
Пример #3
0
        public void tweetAddHashtagCount()
        {
            Control c = new Control();
            int expectedCount = 2;
            string _head = "T123456789";
            string _body = "@sam\r\n#great #fancy";

            Tweet testTweet = new Tweet(_head, _body);

            testTweet.anaylizeMessage();

            Assert.AreEqual(expectedCount, Control.HASHTAGDICT.Count);
        }
Пример #4
0
        public void tweetNoHashtag()
        {
            Control c = new Control();

            int expectedCount = 0;
            string _head = "T123456789";
            string _body = "@sam\r\nnone of theese words are hastags. # ";

            Tweet testTweet = new Tweet(_head, _body);

            testTweet.anaylizeMessage();

            Assert.AreEqual(expectedCount, Control.HASHTAGDICT.Count);
        }
Пример #5
0
        public void tweetAnalysis()
        {
            Control c = new Control();
            string _head = "T123456789";
            string _body = "@sam\r\nA test tweet that will pass analysis.";

            Tweet testTweet = new Tweet(_head, _body);
            try
            {
                testTweet.anaylizeMessage();
            }
            catch (Exception ex)
            {
                Assert.Fail("Expected no exception, but got: " + ex.Message);
            }
        }
Пример #6
0
        public void tweetAddMentionCount()
        {
            Control c = new Control();
            int expectedCount = 2;
            string _head = "T123456789";
            string _body = "@sam\r\nGreat coursework! @rob @Lu";

            Tweet testTweet = new Tweet(_head, _body);

            testTweet.anaylizeMessage();

            Assert.AreEqual(expectedCount, Control.MENTIONLIST.Count);
        }
Пример #7
0
        //takes in head/body and creates create message instance
        public void analyzeMessage(String head, String body)
        {
            //set inouts as varibles
            _basicHeader = head;
            _basicBody = body;
            //regex check valid id
            Match match = idPtrn.Match(_basicHeader);
            if (!match.Success)
            {
                throw new System.ArgumentOutOfRangeException("Message Header", "Message Header is invalid.\nMust be a Charcter and Nine digits.");
            }
            else
            {
                //set id to first char from header
                Char id = _basicHeader[0];
                //remove id from header
                if (id.Equals('S'))
                {
                    //create new sms
                    Sms newMsg = new Sms(_basicHeader, _basicBody);
                    //anaylze sms
                    newMsg.anaylizeMessage();
                    //set as final message
                    _finalMessage = newMsg;
                    //add to message list
                    MESSAGE_LIST.Add(_finalMessage);
                }
                else if (id.Equals('E'))
                {
                    //create new email
                    Email newMsg = new Email(_basicHeader, _basicBody);
                    //analyize message
                    newMsg.anaylizeMessage();
                    //set as final message
                    _finalMessage = newMsg;
                    //check if valid sir message
                    if (SirEmail.checkIfSir(newMsg))
                    {
                        //read inincidnet list
                        SirEmail.fillIncidents();
                        //create new sir email(pass old one as argument)
                        SirEmail sir = new SirEmail(newMsg);
                        //analyize sir
                        sir.anaylizeMessage();
                        //set as final
                        _finalMessage = sir;
                        //add to message list
                        MESSAGE_LIST.Add(_finalMessage);

                    }
                    else
                    {
                        MESSAGE_LIST.Add(_finalMessage);
                    }
                }
                else if (id.Equals('T'))
                {
                    //create new Tweet
                    Tweet newMsg = new Tweet(_basicHeader, _basicBody);
                    //analylze tweet
                    newMsg.anaylizeMessage();
                    //set as final message
                    _finalMessage = newMsg;
                    //add to list
                    MESSAGE_LIST.Add(_finalMessage);
                }
                else
                {
                    throw new System.ArgumentOutOfRangeException("Message Header", "Invalid Message ID.\nID not reconized.");
                }
            }
            //serilze message
            Serializer.serializeToFile(_finalMessage);
        }