/// <summary> /// Send email /// </summary> /// <param name="emailMessage"></param> public void Send(EmailMessage emailMessage) { try { emailMessage.Validate(); _smtpClient.Send(emailMessage); emailMessage.IsSent = true; } catch (Exception ex) { emailMessage.Error = ex.Message; } finally { _repository.Insert(emailMessage); } }
public void SendEmail_GetsSent() { var message = new MailMessage(_from, _to, _subject, _body); _smtpWrapper.Send(_from, _to, _subject, _body); _smtpWrapper.Send(message); _smtpWrapper.SendMailAsync(_from, _to, _subject, _body).GetAwaiter().GetResult(); _smtpWrapper.SendMailAsync(message).GetAwaiter().GetResult(); _smtpWrapper.SendAsync(_from, _to, _subject, _body, null); Thread.Sleep(5000); _smtpWrapper.SendAsync(message, null); Assert.Contains(message.To.ToList(), x => x.Address == _to); }