Beispiel #1
0
        public void smsFailSenderAnalaysis()
        {
            Control c = new Control();

            string _head = "S123456789";
            string _body = "This is not a valid phone number!\r\nA test text that will fail validization.";

            Sms testSms = new Sms(_head, _body);

            testSms.anaylizeMessage();
        }
Beispiel #2
0
        public void smsFailTextAnalaysis()
        {
            Control c = new Control();

            string _head = "S123456789";
            string _body = "+447402967712\r\nThis text 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.";

            Sms testSms = new Sms(_head, _body);

            testSms.anaylizeMessage();

        }
Beispiel #3
0
        public void smsAnalyzeTextSpeak()
        {
            Control c = new Control();
            string expected = "LOL<Laughing out loud>";
            string _head = "S123456789";
            string _body = "+447402967712\r\nLOL";

            Sms testSms = new Sms(_head, _body);

            testSms.anaylizeMessage();

            Assert.AreEqual(expected, testSms.MessageText);
        }
Beispiel #4
0
        public void smsAnalaysis()
        {
            Control c = new Control();
            string _head = "S123456789";
            string _body = "+447402967712\r\nA test text that will pass validization.";

            Sms testSms = new Sms(_head, _body);

            try
            {
                testSms.anaylizeMessage();
            }
            catch (Exception ex)
            {
                Assert.Fail("Expected no exception, but got: " + ex.Message);
            }
        }
Beispiel #5
0
        public void smsAnalyzeTextSpeakInsidePunctuation()
        {
            Control c = new Control();

            string expected = ",ROTFL<Rolling on the floor laughing>,";

            string _head = "S123456789";
            string _body = "+447402967712\r\n,ROTFL,";

            Sms testSms = new Sms(_head, _body);

            testSms.anaylizeMessage();

            Assert.AreEqual(expected, testSms.MessageText);
        }
Beispiel #6
0
        public void smsAnalyzeTextSpeakInsideWord()
        {
            Control c = new Control();
            string expected = "wordLOLword";
            string _head = "S123456789";
            string _body = "+447402967712\r\nwordLOLword";

            Sms testSms = new Sms(_head, _body);

            testSms.anaylizeMessage();

            Assert.AreEqual(expected, testSms.MessageText);
        }
Beispiel #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);
        }