public void SendFullEmail_WhenHideFromIsFalseAndFromUserEmailIsNotEmpty_SendEmail() { // Arrange _hideFrom = false; SetupFakesForGeneralPurpose(); var mailMessage = new MailMessage(); var smtpClient = new SmtpClient(); ShimSmtpClient.AllInstances.SendMailMessage = (client, message) => { smtpClient = client; mailMessage = message; }; // Act EmailSystem.SendFullEmail(_body, _subject, _hideFrom, _fromUser, _toUser); // Assert var resultBody = GetResultBody(_body, SampleName, UserEmailAddress, SampleLoginName); var resultSubject = GetResultBody(_subject, SampleName, UserEmailAddress, SampleLoginName); Assert.AreEqual(DummyString, smtpClient.Host); Assert.AreEqual(UserEmailAddress, mailMessage.From.Address); Assert.AreEqual(SampleName, mailMessage.From.DisplayName); Assert.AreEqual(resultBody, mailMessage.Body); Assert.AreEqual(resultSubject, mailMessage.Subject); Assert.IsTrue(mailMessage.IsBodyHtml); smtpClient.Dispose(); }
public void SendFullEmail_WhenToUserIsNull_ThrowsException() { // Arrange _toUser = null; // Act EmailSystem.SendFullEmail(_body, _subject, _hideFrom, _fromUser, _toUser); // Assert // Expected ArgumentNullException }
public void SendFullEmail_WhenSubjectIsEmpty_ThrowsException() { // Arrange _subject = string.Empty; // Act EmailSystem.SendFullEmail(_body, _subject, _hideFrom, _fromUser, _toUser); // Assert // Expected ArgumentNullException }