本文整理汇总了C#中Connection.ProcessAsync方法的典型用法代码示例。如果您正苦于以下问题:C# Connection.ProcessAsync方法的具体用法?C# Connection.ProcessAsync怎么用?C# Connection.ProcessAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Connection
的用法示例。
在下文中一共展示了Connection.ProcessAsync方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Process_BadCommand_500Response
public async Task Process_BadCommand_500Response()
{
Mocks mocks = new Mocks();
mocks.ConnectionChannel.Setup(c => c.ReadLineAsync()).ReturnsAsync("BADCOMMAND").Callback(() => mocks.Connection.Object.CloseConnectionAsync().Wait());
Connection connection = new Connection(mocks.Server.Object, mocks.ConnectionChannel.Object, mocks.VerbMap.Object);
await connection.ProcessAsync();
mocks.ConnectionChannel.Verify(cc => cc.WriteLineAsync(It.IsRegex("500 .*", RegexOptions.IgnoreCase)));
}
示例2: Process_GreetingWritten
public async Task Process_GreetingWritten()
{
Mocks mocks = new Mocks();
mocks.ConnectionChannel.Setup(c => c.WriteLineAsync(It.IsAny<string>())).Callback(() => mocks.Connection.Object.CloseConnectionAsync().Wait());
Connection connection = new Connection(mocks.Server.Object, mocks.ConnectionChannel.Object, mocks.VerbMap.Object);
await connection.ProcessAsync();
mocks.ConnectionChannel.Verify(cc => cc.WriteLineAsync(It.IsRegex("220 .*", RegexOptions.IgnoreCase)));
}
示例3: Process_EmptyCommand_NoResponse
public async Task Process_EmptyCommand_NoResponse()
{
Mocks mocks = new Mocks();
mocks.ConnectionChannel.Setup(c => c.ReadLineAsync()).ReturnsAsync("").Callback(() => mocks.Connection.Object.CloseConnectionAsync().Wait());
Connection connection = new Connection(mocks.Server.Object, mocks.ConnectionChannel.Object, mocks.VerbMap.Object);
await connection.ProcessAsync();
//Should only print service ready message
mocks.ConnectionChannel.Verify(cc => cc.WriteLineAsync(It.Is<string>(s => !s.StartsWith("220 "))), Times.Never());
}
示例4: Process_GoodCommand_Processed
public async Task Process_GoodCommand_Processed()
{
Mocks mocks = new Mocks();
Mock<IVerb> mockVerb = new Mock<IVerb>();
mocks.VerbMap.Setup(v => v.GetVerbProcessor(It.IsAny<string>())).Returns(mockVerb.Object).Callback(() => mocks.Connection.Object.CloseConnectionAsync().Wait());
mocks.ConnectionChannel.Setup(c => c.ReadLineAsync()).ReturnsAsync("GOODCOMMAND");
Connection connection = new Connection(mocks.Server.Object, mocks.ConnectionChannel.Object, mocks.VerbMap.Object);
await connection.ProcessAsync();
mockVerb.Verify(v => v.ProcessAsync(It.IsAny<IConnection>(), It.IsAny<SmtpCommand>()));
}
示例5: Process_SmtpServerExceptionThrow_ResponseWritten
public async Task Process_SmtpServerExceptionThrow_ResponseWritten()
{
Mocks mocks = new Mocks();
Mock<IVerb> mockVerb = new Mock<IVerb>();
mocks.VerbMap.Setup(v => v.GetVerbProcessor(It.IsAny<string>())).Returns(mockVerb.Object);
mockVerb.Setup(v => v.ProcessAsync(It.IsAny<IConnection>(), It.IsAny<SmtpCommand>())).Returns(Task.FromException(new SmtpServerException(new SmtpResponse(500, "error"))));
mocks.ConnectionChannel.Setup(c => c.ReadLineAsync()).ReturnsAsync("GOODCOMMAND").Callback(() => mocks.Connection.Object.CloseConnectionAsync().Wait());
Connection connection = new Connection(mocks.Server.Object, mocks.ConnectionChannel.Object, mocks.VerbMap.Object);
await connection.ProcessAsync();
mocks.ConnectionChannel.Verify(cc => cc.WriteLineAsync(It.IsRegex("500 error", RegexOptions.IgnoreCase)));
}
示例6: Process_TooManyBadCommands_Disconnected
public async Task Process_TooManyBadCommands_Disconnected()
{
Mocks mocks = new Mocks();
mocks.ServerBehaviour.SetupGet(b => b.MaximumNumberOfSequentialBadCommands).Returns(2);
mocks.ConnectionChannel.Setup(c => c.ReadLineAsync()).ReturnsAsync("BADCOMMAND");
Connection connection = new Connection(mocks.Server.Object, mocks.ConnectionChannel.Object, mocks.VerbMap.Object);
await connection.ProcessAsync();
mocks.ConnectionChannel.Verify(c => c.ReadLineAsync(), Times.Exactly(2));
mocks.ConnectionChannel.Verify(cc => cc.WriteLineAsync(It.IsRegex("221 .*", RegexOptions.IgnoreCase)));
}