Пример #1
0
        public async Task Process_MissingAddress_ErrorResponse()
        {
            Mocks mocks = new Mocks();

            MailFromVerb mailFromVerb = new MailFromVerb();
            await mailFromVerb.ProcessAsync(mocks.Connection.Object, new SmtpCommand("FROM"));

            mocks.VerifyWriteResponseAsync(StandardSmtpResponseCode.SyntaxErrorInCommandArguments);
        }
Пример #2
0
        public async Task Process_AlreadyGivenFrom_ErrorResponse()
        {
            Mocks mocks = new Mocks();

            mocks.Connection.SetupGet(c => c.CurrentMessage).Returns(new Mock <IMessageBuilder>().Object);

            MailFromVerb mailFromVerb = new MailFromVerb();
            await mailFromVerb.ProcessAsync(mocks.Connection.Object, new SmtpCommand("FROM <*****@*****.**>"));

            mocks.VerifyWriteResponseAsync(StandardSmtpResponseCode.BadSequenceOfCommands);
        }
Пример #3
0
        private async Task Process_AddressAsync(string address, string expectedParsedAddress, StandardSmtpResponseCode expectedResponse)
        {
            Mocks mocks = new Mocks();
            Mock <IMessageBuilder> message        = new Mock <IMessageBuilder>();
            IMessageBuilder        currentMessage = null;

            mocks.Connection.Setup(c => c.NewMessage()).Returns(() =>
            {
                currentMessage
                    =
                        message.
                        Object;
                return
                (currentMessage);
            });
            mocks.Connection.SetupGet(c => c.CurrentMessage).Returns(() => currentMessage);

            MailFromVerb mailFromVerb = new MailFromVerb();
            await mailFromVerb.ProcessAsync(mocks.Connection.Object, new SmtpCommand("FROM " + address));

            mocks.VerifyWriteResponseAsync(expectedResponse);
            message.VerifySet(m => m.From = expectedParsedAddress);
        }