public void addTest() { urlQuarantinedList list = new urlQuarantinedList(); string testVar = "<Test string>"; string mixedStringTest = "123456ABCDEF_%^"; list.add(mixedStringTest); list.add(testVar); Assert.AreEqual(urlQuarantinedList.UrlQuarantines.ElementAt(0), mixedStringTest); Assert.AreEqual(urlQuarantinedList.UrlQuarantines.ElementAt(1), testVar); }
public void countTest() { urlQuarantinedList list = new urlQuarantinedList(); urlQuarantinedList.UrlQuarantines.Clear(); string testVar = "Test string"; string mixedStringTest = "123456ABCDEF_%^"; list.add(mixedStringTest); list.add(testVar); Assert.AreEqual(list.count(), 2); }
public void returnValueTest() { urlQuarantinedList list = new urlQuarantinedList(); urlQuarantinedList.UrlQuarantines.Clear(); string testVar = "Test string with many characters in it"; string mixedStringTest = "123456ABCDEF_%^"; list.add(mixedStringTest); list.add(testVar); Assert.AreEqual(list.returnValue(0), mixedStringTest); Assert.AreEqual(list.returnValue(1), testVar); }
public void removeUrls(message asset, urlQuarantinedList quarantinedList) { string[] bodyText = asset.Body.Split(null); string urlReplacement = "<URL Quarantined>"; //check every word in body for url for (int i = 0; i < bodyText.Length; i++) { if (bodyText[i].StartsWith("http:\\")) { //add url to list and replace it with the replacement string quarantinedList.add(bodyText[i]); bodyText[i] = urlReplacement; } } string newBody = string.Join(" ", bodyText); asset.Body = newBody.Trim(); }
public void emailDisplay(sirList sir, urlQuarantinedList urlList) { //if listbox needs refreshing, do so if (lstSIR.HasItems) { lstSIR.Items.Clear(); } //then add new list to it for (int i = 0; i < sir.count(); i++) { lstSIR.Items.Add(sir.returnValue(i)); } if (lstURLs.HasItems) { lstURLs.Items.Clear(); } for (int i = 0; i < urlList.count(); i++) { lstURLs.Items.Add(urlList.returnValue(i)); } }
public void EmailSIR() { MainWindow mainWindow = new MainWindow(); string testHeader = "E123456789"; string testBody = "[email protected] SIR 04/05/18 Sort Code: 99-99-99 Nature of Incident: Staff Attack My body message is http:\\example.com URL example"; mainWindow.sortMessageType(testHeader, testBody); email emailAsset = new email(); mainWindow.assignAttributes(emailAsset, testBody); List <string> incidents = new List <string>(); sirList SIRList = new sirList(); incidents = mainWindow.createIncidentList(incidents); mainWindow.assignEmailSubject(emailAsset, incidents, SIRList); urlQuarantinedList quarantinedList = new urlQuarantinedList(); mainWindow.removeUrls(emailAsset, quarantinedList); Assert.AreEqual(emailAsset.Sender, "*****@*****.**"); Assert.AreEqual(emailAsset.IsSIR, true); Assert.AreEqual(emailAsset.Subject, "SIR 04/05/18"); Assert.AreEqual(emailAsset.Body, "Sort Code: 99-99-99 Nature of Incident: Staff Attack My body message is <URL Quarantined> URL example"); }
public void Email() { MainWindow mainWindow = new MainWindow(); string testHeader = "E123456789"; string testBody = "[email protected] this is my subject!! This is my test body with a http:\\example.com URL example"; mainWindow.sortMessageType(testHeader, testBody); email emailAsset = new email(); mainWindow.assignAttributes(emailAsset, testBody); List <string> incidents = new List <string>(); sirList SIRList = new sirList(); incidents = mainWindow.createIncidentList(incidents); mainWindow.assignEmailSubject(emailAsset, incidents, SIRList); urlQuarantinedList quarantinedList = new urlQuarantinedList(); mainWindow.removeUrls(emailAsset, quarantinedList); Assert.AreEqual(emailAsset.Sender, "*****@*****.**"); Assert.AreEqual(emailAsset.IsSIR, false); Assert.AreEqual(emailAsset.Subject, "this is my subject!!"); Assert.AreEqual(emailAsset.Body, "This is my test body with a <URL Quarantined> URL example"); }
private void btnSend_Click(object sender, RoutedEventArgs e) { try { //read in message from input string header = txtHeader.Text; string body = txtBody.Text; if (txtHeader.Text != "" || txtBody.Text != "") { if (!txtBody.Text.Contains(" ")) { throw new Exception("Please ensure there is a space between the sender and the main body text."); } //determine message type string type = sortMessageType(header, body); if (type == null) { MessageBox.Show("Message type could not be determined. Check header."); } List <message> msgList = new List <message>(); switch (type) { case "E": email emailAsset = new email(); //assign sender and body text to message assignAttributes(emailAsset, body); assignId(emailAsset); List <string> incidents = new List <string>(); sirList SIRList = new sirList(); //fill list of registered incidents incidents = createIncidentList(incidents); assignEmailSubject(emailAsset, incidents, SIRList); urlQuarantinedList quarantinedList = new urlQuarantinedList(); removeUrls(emailAsset, quarantinedList); //display details on UI emailDisplay(SIRList, quarantinedList); serialiser(emailAsset, msgList); break; case "T": tweet tweetAsset = new tweet(); //assign sender and body text to message assignAttributes(tweetAsset, body); assignId(tweetAsset); removeTextspeak(tweetAsset); trendingList trending = new trendingList(); detectHashtags(tweetAsset, trending); mentionsList mentions = new mentionsList(); detectMentions(tweetAsset, mentions); tweetDisplay(tweetAsset, trending, mentions); serialiser(tweetAsset, msgList); break; case "S": sms smsAsset = new sms(); //assign sender and body text to message assignAttributes(smsAsset, body); assignId(smsAsset); //identify textspeak and add extension of it removeTextspeak(smsAsset); serialiser(smsAsset, msgList); break; } } } catch (Exception ex) { MessageBox.Show(ex.Message); } }