public async void SendAsync_with_userState_should_pass_that() { var client = new Mock <ISmtpClient>(); client.Setup(c => c.SendAsync(_mailMessage, "something")); await _mailMessage.SendAsync(userState : "something", smtpClient : client.Object); client.VerifyAll(); }
/// <summary> /// Attempts to send an email message. /// </summary> /// <param name="message"> /// The message. /// </param> /// <exception cref="EmailSendFailureException"> /// All errors relating to sending the message will result in this exception. /// This allows for mailing errors to be easily handled. /// </exception> /// <remarks> /// Sending emails can result in a wide variety of exceptions. /// To make it easier to handle these exceptions upstream, all exceptions /// relating to the actual sending of the message are caught and wrapped into /// one exception. This is acceptable because code upstream doesn't care /// about how the message failed to send, only that it did fail. /// </remarks> /// <returns> /// The <see cref="Task"/>. /// </returns> private Task SendMessageAsync(MvcMailMessage message) { try { return(message.SendAsync()); } catch (Exception ex) { throw new EmailSendFailureException(ex); } }
public void TestSendAsync() { _mailMessage.SendAsync(smtpClient: _smtpClient); Assert.Pass("Mail Send Async working since no exception wast thrown"); }