当前位置: 首页>>代码示例>>C#>>正文


C# Mocks.VerifyWriteResponseAsync方法代码示例

本文整理汇总了C#中Mocks.VerifyWriteResponseAsync方法的典型用法代码示例。如果您正苦于以下问题:C# Mocks.VerifyWriteResponseAsync方法的具体用法?C# Mocks.VerifyWriteResponseAsync怎么用?C# Mocks.VerifyWriteResponseAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Mocks的用法示例。


在下文中一共展示了Mocks.VerifyWriteResponseAsync方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TestGoodDataAsync

        private async Task TestGoodDataAsync(string[] messageData, string expectedData, bool eightBitClean)
        {
            Mocks mocks = new Mocks();

            if (eightBitClean)
            {
                mocks.Connection.SetupGet(c => c.ReaderEncoding).Returns(Encoding.UTF8);
            }

            MemoryMessage.Builder messageBuilder = new MemoryMessage.Builder();
            mocks.Connection.SetupGet(c => c.CurrentMessage).Returns(messageBuilder);
            mocks.ServerBehaviour.Setup(b => b.GetMaximumMessageSize(It.IsAny<IConnection>())).Returns((long?)null);

            int messageLine = 0;
            mocks.Connection.Setup(c => c.ReadLineAsync()).Returns(() => Task.FromResult(messageData[messageLine++]));

            DataVerb verb = new DataVerb();
            await verb.ProcessAsync(mocks.Connection.Object, new SmtpCommand("DATA"));

            mocks.VerifyWriteResponseAsync(StandardSmtpResponseCode.StartMailInputEndWithDot);
            mocks.VerifyWriteResponseAsync(StandardSmtpResponseCode.OK);

            using (StreamReader dataReader = new StreamReader(messageBuilder.GetData(), eightBitClean ? Encoding.UTF8 : new ASCIISevenBitTruncatingEncoding()))
            {
                Assert.Equal(expectedData, dataReader.ReadToEnd());
            }
        }
开发者ID:rnwood,项目名称:smtp4dev,代码行数:27,代码来源:DataVerbTests.cs

示例2: Noop

        public async Task Noop()
        {
            Mocks mocks = new Mocks();

            NoopVerb verb = new NoopVerb();
            await verb.ProcessAsync(mocks.Connection.Object, new SmtpCommand("NOOP"));

            mocks.VerifyWriteResponseAsync(StandardSmtpResponseCode.OK);
        }
开发者ID:rnwood,项目名称:smtp4dev,代码行数:9,代码来源:NoopVerbTests.cs

示例3: Process_NoArguments_Accepted

        public async Task Process_NoArguments_Accepted()
        {
            Mocks mocks = new Mocks();
            EhloVerb ehloVerb = new EhloVerb();
            await ehloVerb.ProcessAsync(mocks.Connection.Object, new SmtpCommand("EHLO"));
            mocks.VerifyWriteResponseAsync(StandardSmtpResponseCode.OK);

            mocks.Session.VerifySet(s => s.ClientName = "");
        }
开发者ID:rnwood,项目名称:smtp4dev,代码行数:9,代码来源:EhloVerbTests.cs

示例4: Quit_RespondsWithClosingChannel

        public async Task Quit_RespondsWithClosingChannel()
        {
            Mocks mocks = new Mocks();

            QuitVerb quitVerb = new QuitVerb();
            await quitVerb.ProcessAsync(mocks.Connection.Object, new SmtpCommand("QUIT"));

            mocks.VerifyWriteResponseAsync(StandardSmtpResponseCode.ClosingTransmissionChannel);
        }
开发者ID:rnwood,项目名称:smtp4dev,代码行数:9,代码来源:QuitVerbTests.cs

示例5: Data_AboveSizeLimit_Rejected

        public async Task Data_AboveSizeLimit_Rejected()
        {
            Mocks mocks = new Mocks();

            MemoryMessage.Builder messageBuilder = new MemoryMessage.Builder();
            mocks.Connection.SetupGet(c => c.CurrentMessage).Returns(messageBuilder);
            mocks.ServerBehaviour.Setup(b => b.GetMaximumMessageSize(It.IsAny<IConnection>())).Returns(10);

            string[] messageData = new string[] { new string('x', 11), "." };
            int messageLine = 0;
            mocks.Connection.Setup(c => c.ReadLineAsync()).Returns(() => Task.FromResult(messageData[messageLine++]));

            DataVerb verb = new DataVerb();
            await verb.ProcessAsync(mocks.Connection.Object, new SmtpCommand("DATA"));

            mocks.VerifyWriteResponseAsync(StandardSmtpResponseCode.StartMailInputEndWithDot);
            mocks.VerifyWriteResponseAsync(StandardSmtpResponseCode.ExceededStorageAllocation);
        }
开发者ID:rnwood,项目名称:smtp4dev,代码行数:18,代码来源:DataVerbTests.cs

示例6: ProcessAsync

        public async Task ProcessAsync()
        {
            Mocks mocks = new Mocks();

            RsetVerb verb = new RsetVerb();
            await verb.ProcessAsync(mocks.Connection.Object, new SmtpCommand("RSET"));

            mocks.VerifyWriteResponseAsync(StandardSmtpResponseCode.OK);
            mocks.Connection.Verify(c => c.AbortMessage());
        }
开发者ID:rnwood,项目名称:smtp4dev,代码行数:10,代码来源:RsetVerbTests.cs

示例7: NoCertificateAvailable_ReturnsErrorResponse

        public async Task NoCertificateAvailable_ReturnsErrorResponse()
        {
            Mocks mocks = new Mocks();
            mocks.ServerBehaviour.Setup(b => b.GetSSLCertificate(It.IsAny<IConnection>())).Returns<X509Certificate>(null);

            StartTlsVerb verb = new StartTlsVerb();
            await verb.ProcessAsync(mocks.Connection.Object, new SmtpCommand("STARTTLS"));

            mocks.VerifyWriteResponseAsync(StandardSmtpResponseCode.CommandNotImplemented);
        }
开发者ID:rnwood,项目名称:smtp4dev,代码行数:10,代码来源:StartTlsVerbTests.cs

示例8: ProcessAsync_UnregisteredSubCommand_ErrorResponse

        public async Task ProcessAsync_UnregisteredSubCommand_ErrorResponse()
        {
            Mocks mocks = new Mocks();

            Mock<VerbWithSubCommands> verbWithSubCommands = new Mock<VerbWithSubCommands>() { CallBase = true };

            await verbWithSubCommands.Object.ProcessAsync(mocks.Connection.Object, new SmtpCommand("VERB SUBCOMMAND1"));

            mocks.VerifyWriteResponseAsync(StandardSmtpResponseCode.CommandParameterNotImplemented);
        }
开发者ID:rnwood,项目名称:smtp4dev,代码行数:10,代码来源:VerbWithSubCommandsTests.cs

示例9: SayHelo

        public async Task SayHelo()
        {
            Mocks mocks = new Mocks();

            HeloVerb verb = new HeloVerb();
            await verb.ProcessAsync(mocks.Connection.Object, new SmtpCommand("HELO foo.blah"));

            mocks.VerifyWriteResponseAsync(StandardSmtpResponseCode.OK);
            mocks.Session.VerifySet(s => s.ClientName = "foo.blah");
        }
开发者ID:rnwood,项目名称:smtp4dev,代码行数:10,代码来源:HeloVerbTests.cs

示例10: SayHeloTwice_ReturnsError

        public async Task SayHeloTwice_ReturnsError()
        {
            Mocks mocks = new Mocks();
            mocks.Session.SetupGet(s => s.ClientName).Returns("already.said.helo");

            HeloVerb verb = new HeloVerb();
            await verb.ProcessAsync(mocks.Connection.Object, new SmtpCommand("HELO foo.blah"));

            mocks.VerifyWriteResponseAsync(StandardSmtpResponseCode.BadSequenceOfCommands);
        }
开发者ID:rnwood,项目名称:smtp4dev,代码行数:10,代码来源:HeloVerbTests.cs

示例11: TestBadAddressAsync

        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);
        }
开发者ID:rnwood,项目名称:smtp4dev,代码行数:12,代码来源:RcptToVerbTests.cs

示例12: TestGoodAddressAsync

        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());
        }
开发者ID:rnwood,项目名称:smtp4dev,代码行数:12,代码来源:RcptToVerbTests.cs

示例13: Process_RespondsWith250

        public async Task Process_RespondsWith250()
        {
            Mocks mocks = new Mocks();
            Mock<IExtensionProcessor> mockExtensionProcessor1 = new Mock<IExtensionProcessor>();
            mockExtensionProcessor1.SetupGet(ep => ep.EHLOKeywords).Returns(new[] { "EXTN1" });
            Mock<IExtensionProcessor> mockExtensionProcessor2 = new Mock<IExtensionProcessor>();
            mockExtensionProcessor2.SetupGet(ep => ep.EHLOKeywords).Returns(new[] { "EXTN2A", "EXTN2B" });

            mocks.Connection.SetupGet(c => c.ExtensionProcessors).Returns(new[]
                                                                              {
                                                                                  mockExtensionProcessor1.Object,
                                                                                  mockExtensionProcessor2.Object
                                                                              });

            EhloVerb ehloVerb = new EhloVerb();
            await ehloVerb.ProcessAsync(mocks.Connection.Object, new SmtpCommand("EHLO foobar"));

            mocks.VerifyWriteResponseAsync(StandardSmtpResponseCode.OK);
        }
开发者ID:rnwood,项目名称:smtp4dev,代码行数:19,代码来源:EhloVerbTests.cs

示例14: Process_SaidHeloAlready_Allowed

        public async Task Process_SaidHeloAlready_Allowed()
        {
            Mocks mocks = new Mocks();

            EhloVerb verb = new EhloVerb();
            await verb.ProcessAsync(mocks.Connection.Object, new SmtpCommand("EHLO foo.blah"));
            await verb.ProcessAsync(mocks.Connection.Object, new SmtpCommand("EHLO foo.blah"));

            mocks.VerifyWriteResponseAsync(StandardSmtpResponseCode.OK);
        }
开发者ID:rnwood,项目名称:smtp4dev,代码行数:10,代码来源:EhloVerbTests.cs

示例15: Data_NoCurrentMessage_ReturnsError

        public async Task Data_NoCurrentMessage_ReturnsError()
        {
            Mocks mocks = new Mocks();

            DataVerb verb = new DataVerb();
            await verb.ProcessAsync(mocks.Connection.Object, new SmtpCommand("DATA"));

            mocks.VerifyWriteResponseAsync(StandardSmtpResponseCode.BadSequenceOfCommands);
        }
开发者ID:rnwood,项目名称:smtp4dev,代码行数:9,代码来源:DataVerbTests.cs


注:本文中的Mocks.VerifyWriteResponseAsync方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。