[Test] public void send() { var emailMessage = new EmailMessage { To = 10.randomLetters(), From = 10.randomLetters(), Subject = 10.randomLetters(), Message = 10.randomLetters(), HtmlMessage = false }; sendEmails.Smtp_Server = 10.randomLetters(); sendEmails.Smtp_UserName = 10.randomLetters(); sendEmails.Smtp_Password = 10.randomLetters(); //try with bad email values var result1 = sendEmails.send(emailMessage); Assert.IsFalse(sendEmails.serverNotConfigured()); Assert.IsFalse(result1); Assert.AreEqual(emailMessage.SentStatus, SentStatus.Error); //try with good emails values SendEmails.Dont_Send_Emails = true; emailMessage.To = "".random_Email(); emailMessage.From = "from".random_Email(); var result2 = sendEmails.send(emailMessage); Assert.IsTrue(result2); Assert.AreEqual(emailMessage.SentStatus, SentStatus.NotSent); SendEmails.Dont_Send_Emails = false; }
public void Send_Test_Email() { var sentEmailMessages = SendEmails.Sent_EmailMessages; var sentMessagesBefore = sentEmailMessages.size(); var sendResult = sendEmails.send(to, subject, message); var sentMessagesAfter = SendEmails.Sent_EmailMessages.size(); var lastMessage = sentEmailMessages.last(); Assert.IsFalse(sendResult); Assert.AreEqual(sentMessagesBefore + 1, sentMessagesAfter); Assert.IsNotNull(lastMessage); Assert.IsNotNull(lastMessage.To = to); Assert.IsNotNull(lastMessage.Subject = subject); Assert.IsNotNull(lastMessage.Message = message); }