Beispiel #1
0
        public void TestDoExecuteError(bool enableTLS, bool isSecured, string parameters, SMTPStatusCode code)
        {
            using (ShimsContext.Create())
            {
                Transaction.SettingsGet = () => new StubIReceiveSettings
                {
                    EnableTLSGet = () => enableTLS
                };
                Transaction.TLSActiveGet = () => isSecured;

                var started = false;
                Transaction.StartTLSCancelEventArgs = args => { started = true; };

                var handler  = new STARTTLSHandler();
                var response = handler.DoExecute(Transaction, parameters);

                Assert.Equal(code, response.Code);
                Assert.False(started);
            }
        }
Beispiel #2
0
        public void TestDoExecuteSuccess()
        {
            using (ShimsContext.Create())
            {
                Transaction.SettingsGet = () => new StubIReceiveSettings
                {
                    EnableTLSGet = () => true
                };
                Transaction.TLSActiveGet = () => false;

                var started = false;
                Transaction.StartTLSCancelEventArgs = args => { started = true; };

                var handler  = new STARTTLSHandler();
                var response = handler.DoExecute(Transaction, "");

                Assert.Equal(SMTPStatusCode.Ready, response.Code);
                Assert.True(started);
            }
        }