Example #1
0
        public void sirEmailFailSortAnalysis()
        {
            Control c = new Control();
            SirEmail.fillIncidents();
            string _head = "E123456789";
            string _body = "[email protected]\r\nSIR 12/12/15\r\nThis isnt a sort code!\r\nTheft\r\nThis is a SIR email that will fail validization";

            Email testEmail = new Email(_head, _body);

            testEmail.anaylizeMessage();

            SirEmail.checkIfSir(testEmail);

            SirEmail testSirEmail = new SirEmail(testEmail);

            testSirEmail.anaylizeMessage();
        }
Example #2
0
        public void sirEmailAnalysis()
        {
            Control c = new Control();
            SirEmail.fillIncidents();
            string _head = "E123456789";
            string _body = "[email protected]\r\nSIR 12/12/15\r\n09-12-45\r\nTheft\r\nThis is a SIR email that will pass validization";

            Email testEmail = new Email(_head, _body);

            testEmail.anaylizeMessage();

            SirEmail.checkIfSir(testEmail);

            SirEmail testSirEmail = new SirEmail(testEmail);

            try
            {
                testSirEmail.anaylizeMessage();
            }
            catch (Exception ex)
            {
                Assert.Fail("Expected no exception, but got: " + ex.Message);
            }
        }
Example #3
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);
        }
Example #4
0
        public void sirEmailSIRListCount()
        {
            Control c = new Control();
            SirEmail.fillIncidents();
            int expectedCount = 1;
            string _head = "E123456789";
            string _body = "[email protected]\r\nSIR 12/12/15\r\n09-12-45\r\nTheft\r\nThis is a SIR email that will pass validization";

            Email testEmail = new Email(_head, _body);

            testEmail.anaylizeMessage();

            SirEmail.checkIfSir(testEmail);

            SirEmail testSirEmail = new SirEmail(testEmail);

            testSirEmail.anaylizeMessage();

            Assert.AreEqual(expectedCount, Control.SIRLIST.Count);
        }