예제 #1
0
        public void CanReturnSmtpResponseException_DoesNotQuit()
        {
            // arrange
            var mailboxFilter = new DelegatingMailboxFilter(@from =>
            {
                throw new SmtpResponseException(SmtpResponse.AuthenticationRequired);

#pragma warning disable 162
                return(MailboxFilterResult.Yes);

#pragma warning restore 162
            });

            using (CreateServer(services => services.Add(mailboxFilter)))
            {
                using var client = MailClient.Client();

                Assert.Throws <ServiceNotAuthenticatedException>(() => client.Send(MailClient.Message()));

                client.NoOp();
            }
        }
예제 #2
0
        public void CanReturnSmtpResponseException_SessionWillQuit()
        {
            // arrange
            var mailboxFilter = new DelegatingMailboxFilter(@from =>
            {
                throw new SmtpResponseException(SmtpResponse.AuthenticationRequired, true);

#pragma warning disable 162
                return(MailboxFilterResult.Yes);

#pragma warning restore 162
            });

            using (CreateServer(options => options.MailboxFilter(mailboxFilter)))
            {
                using (var client = MailClient.Client())
                {
                    Assert.Throws <ServiceNotAuthenticatedException>(() => client.Send(MailClient.Message()));

                    // no longer connected to this is invalid
                    Assert.ThrowsAny <Exception>(() => client.NoOp());
                }
            }
        }