public void MixedEmailFormatTest() { string methodName = "MixedEmailFormatTest()"; string[] toEmails = new string[] { CreateEmailListString(_twoEmails), CreateEmailListString(_twoAngleBracketsNameEmails), CreateEmailListString(_twoParenthesisEmailNames), CreateEmailListString(_twoAngleBracketsEmailNames), CreateEmailListString(_twoParenthesisNameEmails) }; MailTask mailTask = new MailTask(); mailTask.Project = CreateEmptyProject(); mailTask.Mailhost = _mailHost; mailTask.Port = _port; mailTask.From = _fromEmail; mailTask.ToList = CreateEmailListString(toEmails); mailTask.Subject = String.Format(_subjectText, methodName); mailTask.Message = CreateSampleEmailMessage(methodName); mailTask.Execute(); Assert.AreEqual(1, _smtpServer.ReceivedEmailCount); Assert.AreEqual(10, _smtpServer.ReceivedEmail[0].ToAddresses.Length); }
public void ManyCcNamesAndEmailAddressesInParenthesisTest() { string methodName = "ManyCcNamesAndEmailAddressesInParenthesisTest()"; MailTask mailTask = new MailTask(); mailTask.Project = CreateEmptyProject(); mailTask.Mailhost = _mailHost; mailTask.Port = _port; mailTask.From = _fromEmail; mailTask.CcList = CreateEmailListString(_multiParenthesisNameEmails); mailTask.Subject = String.Format(_subjectText, methodName); mailTask.Message = CreateSampleEmailMessage(methodName); mailTask.Execute(); Assert.AreEqual(1, _smtpServer.ReceivedEmailCount); if (_smtpServer.ReceivedEmail[0].Headers.ContainsKey("Cc")) { string[] ccEmails = GetCcAddressesFromSentMail(); Assert.AreEqual(6, ccEmails.Length); } else { Assert.Fail("Test email did not contain addresses in the CC line"); } }
public void ManyToNamesAndEmailAddressesInParenthesisTest() { string methodName = "ManyToNamesAndEmailAddressesInParenthesisTest()"; MailTask mailTask = new MailTask(); mailTask.Project = CreateEmptyProject(); mailTask.Mailhost = _mailHost; mailTask.Port = _port; mailTask.From = _fromEmail; mailTask.ToList = CreateEmailListString(_multiParenthesisNameEmails); mailTask.Subject = String.Format(_subjectText, methodName); mailTask.Message = CreateSampleEmailMessage(methodName); mailTask.Execute(); Assert.AreEqual(1, _smtpServer.ReceivedEmailCount); Assert.AreEqual(6, _smtpServer.ReceivedEmail[0].ToAddresses.Length); }
public void BadParenthesisNameEmailTest() { string methodName = "BadParenthesisNameEmailTest()"; MailTask mailTask = new MailTask(); mailTask.Project = CreateEmptyProject(); mailTask.Mailhost = _mailHost; mailTask.Port = _port; mailTask.From = _fromEmail; mailTask.ToList = _badParenthesisNameEmail; mailTask.Subject = String.Format(_subjectText, methodName); mailTask.Message = CreateSampleEmailMessage(methodName); mailTask.Execute(); }
public void EmailMessageFromFileTest() { string methodName = "EmailMessageFromFileTest()"; FileSet fileSet = new FileSet(); fileSet.FileNames.AddRange(_files.ToArray()); MailTask mailTask = new MailTask(); mailTask.Project = CreateEmptyProject(); mailTask.Mailhost = _mailHost; mailTask.Port = _port; mailTask.From = _fromEmail; mailTask.ToList = CreateEmailListString(_twoEmails); mailTask.Subject = String.Format(_subjectText, methodName); mailTask.Files = fileSet; mailTask.Execute(); Assert.AreEqual(1, _smtpServer.ReceivedEmailCount); }
public void AllRecipientListsTest() { string methodName = "AllRecipientListsTest()"; MailTask mailTask = new MailTask(); mailTask.Project = CreateEmptyProject(); mailTask.Mailhost = _mailHost; mailTask.Port = _port; mailTask.From = _fromEmail; mailTask.ToList = CreateEmailListString(_twoEmails); mailTask.CcList = CreateEmailListString(_twoParenthesisEmailNames); mailTask.BccList = CreateEmailListString(_twoAngleBracketsNameEmails); mailTask.Subject = String.Format(_subjectText, methodName); mailTask.Message = CreateSampleEmailMessage(methodName); mailTask.Execute(); Assert.AreEqual(1, _smtpServer.ReceivedEmailCount); Assert.AreEqual(6, _smtpServer.ReceivedEmail[0].ToAddresses.Length); Assert.AreEqual(2, GetCcAddressesFromSentMail().Length); }
public void TwoToEmailAddressesAndNamesInAngleBracketsTest() { string methodName = "TwoToEmailAddressesAndNamesInAngleBracketsTest()"; MailTask mailTask = new MailTask(); mailTask.Project = CreateEmptyProject(); mailTask.Mailhost = _mailHost; mailTask.Port = _port; mailTask.From = _fromEmail; mailTask.ToList = CreateEmailListString(_twoAngleBracketsEmailNames); mailTask.Subject = String.Format(_subjectText, methodName); mailTask.Message = CreateSampleEmailMessage(methodName); mailTask.Execute(); Assert.AreEqual(1, _smtpServer.ReceivedEmailCount); Assert.AreEqual(2, _smtpServer.ReceivedEmail[0].ToAddresses.Length); }
public void SimpleNameEmailWithParenthesisTest() { string methodName = "SimpleNameEmailWithParenthesisTest()"; MailTask mailTask = new MailTask(); mailTask.Project = CreateEmptyProject(); mailTask.Mailhost = _mailHost; mailTask.Port = _port; mailTask.From = _fromEmail; mailTask.ToList = _singleParenthesisNameEmail; mailTask.Subject = String.Format(_subjectText, methodName); mailTask.Message = CreateSampleEmailMessage(methodName); mailTask.Execute(); Assert.AreEqual(1, _smtpServer.ReceivedEmailCount); }
public void testAllLists() { MailTask mailTask = new MailTask(); mailTask.Project = new Project(); _tolist= _emailAddress1; _cclist= _emailAddress2; _bcclist= _emailAddress1; _subject="Msg 5: Test to all addresses"; _message="Test message"; try { mailTask.Mailhost = _mailhost; mailTask.From = _from; mailTask.ToList = _tolist; mailTask.Subject = _subject; mailTask.Message = _message; mailTask.CcList = _cclist; mailTask.BccList = _bcclist; mailTask.Attachments = _attachments; mailTask.Files = _files; mailTask.Execute(); } catch (Exception e) { Assertion.Assert(_subject + ": " + e.Message, false); } }
public void testFilesAsBody() { MailTask mailTask = new MailTask(); mailTask.Project = new Project(); _tolist= _emailAddress1; _subject="Msg 6: Files for message"; _message="Test message"; foreach (string fileName in _fileList) { _files += fileName + ";"; } // add bogus entry _files += "BogusFile.txt"; try { mailTask.Mailhost = _mailhost; mailTask.From = _from; mailTask.ToList = _tolist; mailTask.Subject = _subject; mailTask.Message = _message; mailTask.CcList = _cclist; mailTask.BccList = _bcclist; mailTask.Attachments = _attachments; mailTask.Files = _files; mailTask.Execute(); } catch (Exception e) { Assertion.Assert(_subject + ": " + e.Message, false); } }