public async Task SendMessageAsync_Should_Receive_With_One_Message_Arg(string to, string body, string subject) { _message.Subject = subject; _message.Body = body; _message.To.Add(to); await _mailer.SendMessageAsync(to, body, subject); await _smtp.ReceivedWithAnyArgs(1).SendMailAsync(_message); }
public async Task Consume(ConsumeContext <EmailSend> context) { try { if (context.Message == null) { throw new ArgumentNullException("Message is null"); } if (context.Message.To == null) { throw new ArgumentNullException("No email address provided"); } if (context.Message.Subject == null) { throw new ArgumentNullException("Message subject is not provided"); } if (context.Message.Body == null) { throw new ArgumentNullException("Body subject is not provided"); } var message = context.Message; await _mailer.SendMessageAsync(message.To, message.Body, message.Subject); _logger.Information($"Email sent to: {context.Message.To}"); } catch (Exception exception) { _logger.Error(exception.Message); return; } }