//constructor public SirEmail(Email email) { this.MessageHeader = email.MessageHeader; this.MessageBody = email.MessageBody; this.MessageSender = email.MessageSender; this.EmailSubject = email.EmailSubject; this.MessageText = email.MessageText; }
public void emailFailTextAnalysis() { Control c = new Control(); string _head = "E123456789"; string _body = "[email protected]\r\nTest email\r\nThis email text is far 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"; Email testEmail = new Email(_head, _body); testEmail.anaylizeMessage(); }
public void emailFailSubjectAnalysis() { Control c = new Control(); string _head = "E123456789"; string _body = "[email protected]\r\nThis email subject is too long \r\nA test email that will fail the analysis test."; Email testEmail = new Email(_head, _body); testEmail.anaylizeMessage(); }
public void emailFailSenderAnalysis() { Control c = new Control(); string _head = "E123456789"; string _body = "an invalid email address as sender\r\nTest email\r\nA test email that will fail the analysis test."; Email testEmail = new Email(_head, _body); testEmail.anaylizeMessage(); }
//returns true if an emial matchs SIR creitera public static Boolean checkIfSir(Email emial) { //define and check if email sunject matches sir regex Match match = _subPtrn.Match(emial.EmailSubject); if (match.Success) { return true; } return false; }
public void emailQuarantineUrl() { Control c = new Control(); string expectedText = " <URL Quarantined> <URL Quarantined>"; string _head = "E123456789"; string _body = "[email protected]\r\nTest email\r\n https://www.google.co.uk https://www.facebook.com"; Email emailTest = new Email(_head, _body); emailTest.anaylizeMessage(); Assert.AreEqual(expectedText, emailTest.MessageText); }
public void sirEmailFailSirSubjectAnalysis() { Control c = new Control(); SirEmail.fillIncidents(); string _head = "E123456789"; string _body = "[email protected]\r\nNot a SIR subject\r\n09-12-45\r\nTheft\r\nThis is a SIR email that will fail validization"; Email testEmail = new Email(_head, _body); testEmail.anaylizeMessage(); Assert.IsFalse(SirEmail.checkIfSir(testEmail)); }
public void emailAnalysis() { Control c = new Control(); string _head = "E123456789"; string _body = "[email protected]\r\nTest email\r\nA test email that will pass the analysis test."; Email testEmail = new Email(_head, _body); try { testEmail.anaylizeMessage(); } catch (Exception ex) { Assert.Fail("Expected no exception, but got: " + ex.Message); } }
public void sirEmailFailIncidentAnalysis() { Control c = new Control(); SirEmail.fillIncidents(); string _head = "E123456789"; string _body = "[email protected]\r\nSIR 12/12/15\r\n09/23/67\r\nThis incident isnt in the Incident list\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(); }
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); } }
public void emailQuarantineCount() { Control c = new Control(); int expectedCount = 2; string _head = "E123456789"; string _body = "[email protected]\r\nTest email\r\n https://www.google.co.uk https://www.facebook.com"; Email emailTest = new Email(_head, _body); emailTest.anaylizeMessage(); Assert.AreEqual(expectedCount, emailTest.UrlList.Count); }
//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); }
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); }