Example #1
0
        private void TestBadAddress(string address)
        {
            Mocks mocks = new Mocks();
            Message message = new Message(mocks.Session.Object);
            mocks.Connection.SetupGet(c => c.CurrentMessage).Returns(message);

            RcptToVerb verb = new RcptToVerb();
            verb.Process(mocks.Connection.Object, new SmtpCommand("TO " + address));

            mocks.VerifyWriteResponse(StandardSmtpResponseCode.SyntaxErrorInCommandArguments);
            Assert.AreEqual(0, message.To.Length);
        }
Example #2
0
        private async Task TestBadAddressAsync(string address)
        {
            Mocks mocks = new Mocks();
            MemoryMessage.Builder messageBuilder = new MemoryMessage.Builder();
            mocks.Connection.SetupGet(c => c.CurrentMessage).Returns(messageBuilder);

            RcptToVerb verb = new RcptToVerb();
            await verb.ProcessAsync(mocks.Connection.Object, new SmtpCommand("TO " + address));

            mocks.VerifyWriteResponseAsync(StandardSmtpResponseCode.SyntaxErrorInCommandArguments);
            Assert.Equal(0, messageBuilder.To.Count);
        }
Example #3
0
        private void TestGoodAddress(string address, string expectedAddress)
        {
            Mocks mocks = new Mocks();
            Message message = new Message(mocks.Session.Object);
            mocks.Connection.SetupGet(c => c.CurrentMessage).Returns(message);

            RcptToVerb verb = new RcptToVerb();
            verb.Process(mocks.Connection.Object, new SmtpCommand("TO " + address));

            mocks.VerifyWriteResponse(StandardSmtpResponseCode.OK);
            Assert.AreEqual(expectedAddress, message.To[0]);
        }
Example #4
0
        private async Task TestGoodAddressAsync(string address, string expectedAddress)
        {
            Mocks mocks = new Mocks();
            MemoryMessage.Builder messageBuilder = new MemoryMessage.Builder();
            mocks.Connection.SetupGet(c => c.CurrentMessage).Returns(messageBuilder);

            RcptToVerb verb = new RcptToVerb();
            await verb.ProcessAsync(mocks.Connection.Object, new SmtpCommand("TO " + address));

            mocks.VerifyWriteResponseAsync(StandardSmtpResponseCode.OK);
            Assert.Equal(expectedAddress, messageBuilder.To.First());
        }
Example #5
0
        private async Task TestBadAddressAsync(string address)
        {
            var mocks          = new Mocks();
            var messageBuilder = new MemoryMessage.Builder();

            mocks.Connection.SetupGet(c => c.CurrentMessage).Returns(messageBuilder);

            var verb = new RcptToVerb();
            await verb.ProcessAsync(mocks.Connection.Object, new SmtpCommand("TO " + address));

            mocks.VerifyWriteResponseAsync(StandardSmtpResponseCode.SyntaxErrorInCommandArguments);
            Assert.Equal(0, messageBuilder.To.Count);
        }
Example #6
0
        private async Task TestGoodAddressAsync(string address, string expectedAddress)
        {
            var mocks          = new Mocks();
            var messageBuilder = new MemoryMessage.Builder();

            mocks.Connection.SetupGet(c => c.CurrentMessage).Returns(messageBuilder);

            var verb = new RcptToVerb();
            await verb.ProcessAsync(mocks.Connection.Object, new SmtpCommand("TO " + address));

            mocks.VerifyWriteResponseAsync(StandardSmtpResponseCode.Ok);
            Assert.Equal(expectedAddress, messageBuilder.To.First());
        }
Example #7
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="address">The address<see cref="string"/></param>
        /// <param name="expectedAddress">The expectedAddress<see cref="string"/></param>
        /// <returns>A <see cref="Task{T}"/> representing the async operation</returns>
        private async Task TestGoodAddressAsync(string address, string expectedAddress, bool eightBit = false)
        {
            TestMocks            mocks          = new TestMocks();
            MemoryMessageBuilder messageBuilder = new MemoryMessageBuilder();

            messageBuilder.EightBitTransport = eightBit;
            mocks.Connection.SetupGet(c => c.CurrentMessage).Returns(messageBuilder);

            RcptToVerb verb = new RcptToVerb();
            await verb.Process(mocks.Connection.Object, new SmtpCommand("TO " + address)).ConfigureAwait(false);

            mocks.VerifyWriteResponseAsync(StandardSmtpResponseCode.OK);
            Assert.Equal(expectedAddress, messageBuilder.Recipients.First());
        }
Example #8
0
        private void TestBadAddress(string address)
        {
            Mocks mocks = new Mocks();

            MemoryMessage.Builder messageBuilder = new MemoryMessage.Builder();
            mocks.Connection.SetupGet(c => c.CurrentMessage).Returns(messageBuilder);

            RcptToVerb verb = new RcptToVerb();

            verb.Process(mocks.Connection.Object, new SmtpCommand("TO " + address));

            mocks.VerifyWriteResponse(StandardSmtpResponseCode.SyntaxErrorInCommandArguments);
            Assert.AreEqual(0, messageBuilder.To.Count);
        }
Example #9
0
        private void TestGoodAddress(string address, string expectedAddress)
        {
            Mocks mocks = new Mocks();

            MemoryMessage.Builder messageBuilder = new MemoryMessage.Builder();
            mocks.Connection.SetupGet(c => c.CurrentMessage).Returns(messageBuilder);

            RcptToVerb verb = new RcptToVerb();

            verb.Process(mocks.Connection.Object, new SmtpCommand("TO " + address));

            mocks.VerifyWriteResponse(StandardSmtpResponseCode.OK);
            Assert.AreEqual(expectedAddress, messageBuilder.To.First());
        }
Example #10
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="address">The address<see cref="string"/></param>
        /// <returns>A <see cref="Task{T}"/> representing the async operation</returns>
        private async Task TestBadAddressAsync(string address, bool asException = false)
        {
            TestMocks            mocks          = new TestMocks();
            MemoryMessageBuilder messageBuilder = new MemoryMessageBuilder();

            mocks.Connection.SetupGet(c => c.CurrentMessage).Returns(messageBuilder);

            RcptToVerb verb = new RcptToVerb();

            if (!asException)
            {
                await verb.Process(mocks.Connection.Object, new SmtpCommand("TO " + address)).ConfigureAwait(false);

                mocks.VerifyWriteResponseAsync(StandardSmtpResponseCode.SyntaxErrorInCommandArguments);
            }
            else
            {
                SmtpServerException e = await Assert.ThrowsAsync <SmtpServerException>(() => verb.Process(mocks.Connection.Object, new SmtpCommand("TO " + address))).ConfigureAwait(false);

                Assert.Equal((int)StandardSmtpResponseCode.SyntaxErrorInCommandArguments, e.SmtpResponse.Code);
            }
            Assert.Equal(0, messageBuilder.Recipients.Count);
        }