本文整理汇总了C#中SmtpResponse.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# SmtpResponse.ToString方法的具体用法?C# SmtpResponse.ToString怎么用?C# SmtpResponse.ToString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SmtpResponse
的用法示例。
在下文中一共展示了SmtpResponse.ToString方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ToString_MultiLineMessage
public void ToString_MultiLineMessage()
{
SmtpResponse r = new SmtpResponse(200, "Multi line message line 1\r\n" +
"Multi line message line 2\r\n" +
"Multi line message line 3");
Assert.Equal("200-Multi line message line 1\r\n" +
"200-Multi line message line 2\r\n" +
"200 Multi line message line 3\r\n", r.ToString());
}
示例2: RunCommand
public void RunCommand(string command, SmtpResponse expectedSmtpResponse)
{
_writer.WriteLine(command);
var line = _reader.ReadLine();
if (line == null)
throw new InvalidOperationException("Stream has unexpectedly closed");
if (line != expectedSmtpResponse.ToString())
throw new InvalidOperationException(String.Format("After command '{0}' received '{1}' but expected '{2}'", command, line, expectedSmtpResponse));
}
示例3: SendResponseAsync
private static async Task SendResponseAsync(SmtpConnection connection, SmtpResponse response)
{
LogResponse(response);
foreach (var additional in response.AdditionalLines)
await connection.WriteLineAsyncAndFireEvents(additional);
await connection.WriteLineAsyncAndFireEvents(response.ToString());
}
示例4: ToString_SingleLineMessage
public void ToString_SingleLineMessage()
{
SmtpResponse r = new SmtpResponse(200, "Single line message");
Assert.Equal("200 Single line message\r\n", r.ToString());
}