Example #1
0
        public void Send(MailMessage mailMessage)
        {
            _validator.Validate(mailMessage);

            ISmtpClient client = null;

            try
            {
                client = _factory.Create();
                SetUpClient(client);

                client.Send(mailMessage);
            }
            catch (ArgumentException e)
            {
                throw new SmptClientException("Cannot setup client.", e);
            }
            catch (InvalidOperationException e)
            {
                throw new SmptClientException("Client cannot do operation.", e);
            }
            catch (SmtpException e)
            {
                throw new SmptClientException("Client cannot send mail message.", e);
            }
            finally
            {
                client?.Dispose();
            }
        }
 public void Validate_Should_ThrowMailBuildExeption_When_NothingWasSet()
 {
     Expect(() => _validator.Validate(_mailMessage), Throws.TypeOf <InvalidMailExeption>());
 }