本文整理汇总了C#中SmtpResponse类的典型用法代码示例。如果您正苦于以下问题:C# SmtpResponse类的具体用法?C# SmtpResponse怎么用?C# SmtpResponse使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SmtpResponse类属于命名空间,在下文中一共展示了SmtpResponse类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: SmtpResponse
public void SmtpResponse()
{
SmtpResponse smtpResponse = new SmtpResponse(StandardSmtpResponseCode.ExceededStorageAllocation, "Blah");
SmtpServerException e = new SmtpServerException(smtpResponse);
Assert.Same(smtpResponse, e.SmtpResponse);
}
开发者ID:rnwood,项目名称:smtp4dev,代码行数:7,代码来源:SmtpServerExceptionTests.cs
示例2: Clone_should_deep_copy_Additional
public void Clone_should_deep_copy_Additional()
{
var response = new SmtpResponse(250, "", new[] { "additional" });
var cloned = response.Clone();
Assert.NotSame(response.AdditionalLines, cloned.AdditionalLines);
Assert.Equal(response.AdditionalLines, cloned.AdditionalLines);
}
开发者ID:kdblocher,项目名称:simple.mailserver,代码行数:8,代码来源:SmtpResponseFacts.cs
示例3: Equals_is_false_ResponseCode_doesnt_match
public void Equals_is_false_ResponseCode_doesnt_match()
{
var response1 = new SmtpResponse(250, "");
var response2 = new SmtpResponse(251, "");
Assert.False(response1.Equals(response2));
Assert.False(response1.Equals((object)response2));
Assert.NotEqual(response1.GetHashCode(), response2.GetHashCode());
}
开发者ID:kdblocher,项目名称:simple.mailserver,代码行数:9,代码来源:SmtpResponseFacts.cs
示例4: 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());
}
开发者ID:rnwood,项目名称:smtp4dev,代码行数:9,代码来源:SmtpResponseTests.cs
示例5: CloneAndChange_with_ResponseText_should_change_response_text
public void CloneAndChange_with_ResponseText_should_change_response_text()
{
var response = new SmtpResponse(250, "old text", new[] { "additional" });
var cloned = response.CloneAndChange("new text");
Assert.Equal("new text", cloned.ResponseText);
var clonedBack = cloned.CloneAndChange("old text");
Assert.Equal(response, clonedBack);
}
开发者ID:kdblocher,项目名称:simple.mailserver,代码行数:10,代码来源:SmtpResponseFacts.cs
示例6: VerifyEhlo
private SmtpResponse VerifyEhlo()
{
var smtpCapabilities = _getSmtpCapabilities.GetCapabilities().ToList();
if (!smtpCapabilities.Any())
return SmtpResponses.OK;
var additionalLines = smtpCapabilities.Skip(1).Select(capability => "250-" + capability).ToList();
var response = new SmtpResponse(250, smtpCapabilities.First().ToString(), additionalLines);
return response;
}
开发者ID:dapaxx,项目名称:simple.mailserver,代码行数:12,代码来源:SmtpIdentificationResponder.cs
示例7: 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));
}
开发者ID:kdblocher,项目名称:simple.mailserver,代码行数:12,代码来源:TestConnection.cs
示例8: Equals_is_false_Additional_missing_in_other_response
public void Equals_is_false_Additional_missing_in_other_response()
{
var response1 = new SmtpResponse(250, "", new[] { "line" });
var response2 = new SmtpResponse(250, "");
Assert.False(response1.Equals(response2));
Assert.False(response1.Equals((object)response2));
}
开发者ID:kdblocher,项目名称:simple.mailserver,代码行数:8,代码来源:SmtpResponseFacts.cs
示例9: 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.ResponseCode + " " + response.ResponseText);
}
开发者ID:Snuk,项目名称:simple.mailserver,代码行数:9,代码来源:SmtpServer.cs
示例10: Execute
/// <summary>
/// Execute the SMTP request returning a response. This method models the state transition table for the SMTP server.
/// </summary>
/// <returns>Reponse to the request</returns>
public virtual SmtpResponse Execute()
{
SmtpResponse response = null;
if (action.Stateless)
{
if (SmtpActionType.EXPN == action || SmtpActionType.VRFY == action)
{
response = new SmtpResponse(252, "Not supported", this.state);
}
else if (SmtpActionType.HELP == action)
{
response = new SmtpResponse(211, "No help available", this.state);
}
else if (SmtpActionType.NOOP == action)
{
response = new SmtpResponse(250, "OK", this.state);
}
else if (SmtpActionType.VRFY == action)
{
response = new SmtpResponse(252, "Not supported", this.state);
}
else if (SmtpActionType.RSET == action)
{
response = new SmtpResponse(250, "OK", SmtpState.GREET);
}
else
{
response = new SmtpResponse(500, "Command not recognized", this.state);
}
}
else
{
// Stateful commands
if (SmtpActionType.CONNECT == action)
{
if (SmtpState.CONNECT == state)
{
response = new SmtpResponse(220, "localhost nDumbster SMTP service ready", SmtpState.GREET);
}
else
{
response = new SmtpResponse(503, "Bad sequence of commands: " + action, this.state);
}
}
else if (SmtpActionType.EHLO == action)
{
if (SmtpState.GREET == state)
{
response = new SmtpResponse(250, "OK", SmtpState.MAIL);
}
else
{
response = new SmtpResponse(503, "Bad sequence of commands: " + action, this.state);
}
}
else if (SmtpActionType.MAIL == action)
{
if (SmtpState.MAIL == state || SmtpState.QUIT == state)
{
response = new SmtpResponse(250, "OK", SmtpState.RCPT);
}
else
{
response = new SmtpResponse(503, "Bad sequence of commands: " + action, this.state);
}
}
else if (SmtpActionType.RCPT == action)
{
if (SmtpState.RCPT == state)
{
response = new SmtpResponse(250, "OK", this.state);
}
else
{
response = new SmtpResponse(503, "Bad sequence of commands: " + action, this.state);
}
}
else if (SmtpActionType.DATA == action)
{
if (SmtpState.RCPT == state)
{
response = new SmtpResponse(354, "Start mail input; end with <CRLF>.<CRLF>", SmtpState.DATA_HDR);
}
else
{
response = new SmtpResponse(503, "Bad sequence of commands: " + action, this.state);
}
}
else if (SmtpActionType.UNRECOG == action)
{
if (SmtpState.DATA_HDR == state || SmtpState.DATA_BODY == state)
{
response = new SmtpResponse(-1, "", this.state);
}
else
{
//.........这里部分代码省略.........
开发者ID:TheSpider,项目名称:nDumbster,代码行数:101,代码来源:SmtpRequest.cs
示例11: Check_Response
// I was seeing my SMTP server hang waiting for a response to the QUIT, so I added
// this timeout. Pass -1 to wait forever. Timeout is in milliseconds.
private bool Check_Response(Socket s, SmtpResponse response_expected, int timeout)
{
string sResponse;
int response;
byte[] bytes = new byte[1024];
int start = Environment.TickCount;
while (s.Available == 0)
{
System.Threading.Thread.Sleep(101);
if (timeout != -1)
{
if ((Environment.TickCount - start) > timeout)
{
// We timed out
return false;
}
}
}
s.Receive(bytes, 0, s.Available, SocketFlags.None);
sResponse = Encoding.ASCII.GetString(bytes);
if (sw != null)
sw.WriteLine(">>{0}", sResponse);
response = Convert.ToInt32(sResponse.Substring(0, 3));
if (response != (int)response_expected)
return false;
return true;
}
开发者ID:nuxleus,项目名称:flexwikicore,代码行数:32,代码来源:SMTPMail.cs
示例12: CreateParseResponderWithMockedIRespondToSmtpIdentification
private static SmtpSessionInfoResponder CreateParseResponderWithMockedIRespondToSmtpIdentification(SmtpResponse testResponse)
{
var respondToSmtpIdentification = MockIRespondToSmtpIdentificationToReturnResponse(testResponse);
var factory = new DefaultSmtpResponderFactory<ISmtpServerConfiguration>(new SmtpServerConfiguration()) { IdentificationResponder = respondToSmtpIdentification };
var parseResponder = DefaultResponder(factory);
return parseResponder;
}
开发者ID:Snuk,项目名称:simple.mailserver,代码行数:8,代码来源:SmtpSessionInfoResponderFacts.cs
示例13: SendResponseAsync
private static async Task SendResponseAsync(SmtpConnection connection, SmtpResponse response)
{
LogResponse(response);
try
{
foreach (var additional in response.AdditionalLines)
await connection.WriteLineAsyncAndFireEvents(additional);
await connection.WriteLineAsyncAndFireEvents(response.ResponseCode + " " + response.ResponseText);
} catch(Exception ex)
{
MailServerLogger.Instance.Error(ex);
}
}
开发者ID:RFlipper,项目名称:simple.mailserver,代码行数:16,代码来源:SmtpServer.cs
示例14: Parse
public static SmtpResponse Parse (string line) {
SmtpResponse response = new SmtpResponse ();
if (line.Length < 4)
throw new SmtpException ("Response is to short " +
line.Length + ".");
if ((line [3] != ' ') && (line [3] != '-'))
throw new SmtpException ("Response format is wrong.(" +
line + ")");
// parse the response code
response.StatusCode = (SmtpStatusCode) Int32.Parse (line.Substring (0, 3));
// set the raw response
response.Description = line;
return response;
}
开发者ID:frje,项目名称:SharpLang,代码行数:19,代码来源:SmtpClient.cs
示例15: ProcessRawLineHasResponse
private bool ProcessRawLineHasResponse(string line, out SmtpResponse smtpResponse)
{
smtpResponse = ProcessRawLine(line);
return (smtpResponse != SmtpResponses.None);
}
开发者ID:kdblocher,项目名称:simple.mailserver,代码行数:5,代码来源:SmtpCommandParser.cs
示例16: MockIRespondToVerifyToReturnResponse
private static IRespondToSmtpVerify MockIRespondToVerifyToReturnResponse(SmtpResponse testResponse)
{
var mockedInterface = new Mock<IRespondToSmtpVerify>();
mockedInterface
.Setup(x => x.Verify(It.IsAny<SmtpSessionInfo>(), It.IsAny<string>()))
.Returns<SmtpSessionInfo, string>((sessionInfo, args) => testResponse);
return mockedInterface.Object;
}
开发者ID:Snuk,项目名称:simple.mailserver,代码行数:8,代码来源:SmtpSessionInfoResponderFacts.cs
示例17: CheckStatus
void CheckStatus (SmtpResponse status, int i)
{
if (((int) status.StatusCode) != i)
throw new SmtpException (status.StatusCode, status.Description);
}
开发者ID:frje,项目名称:SharpLang,代码行数:5,代码来源:SmtpClient.cs
示例18: CreateParseResponderWithMockedIRespondToVerify
private static SmtpSessionInfoResponder CreateParseResponderWithMockedIRespondToVerify(SmtpResponse testResponse)
{
var respondToVerify = MockIRespondToVerifyToReturnResponse(testResponse);
var factory = new DefaultSmtpResponderFactory<ISmtpServerConfiguration>(new SmtpServerConfiguration()) { VerifyResponder = respondToVerify };
var parseResponder = MailFromIdentifiedParseResponder(factory);
return parseResponder;
}
开发者ID:Snuk,项目名称:simple.mailserver,代码行数:8,代码来源:SmtpSessionInfoResponderFacts.cs
示例19: MockIRespondToRecipientToToReturnResponse
private static IRespondToSmtpRecipientTo MockIRespondToRecipientToToReturnResponse(SmtpResponse testResponse)
{
var mockedInterface = new Mock<IRespondToSmtpRecipientTo>();
mockedInterface
.Setup(x => x.VerifyRecipientTo(It.IsAny<SmtpSessionInfo>(), It.IsAny<MailAddressWithParameters>()))
.Returns<SmtpSessionInfo, MailAddressWithParameters>((sessionInfo, mailAddressWithParameters) => testResponse);
return mockedInterface.Object;
}
开发者ID:Snuk,项目名称:simple.mailserver,代码行数:8,代码来源:SmtpSessionInfoResponderFacts.cs
示例20: MockIRespondToSmtpIdentificationToReturnResponse
private static IRespondToSmtpIdentification MockIRespondToSmtpIdentificationToReturnResponse(SmtpResponse testResponse)
{
var mockedInterface = new Mock<IRespondToSmtpIdentification>();
mockedInterface
.Setup(x => x.VerifyIdentification(It.IsAny<SmtpSessionInfo>(), It.IsAny<SmtpIdentification>()))
.Returns<SmtpSessionInfo, SmtpIdentification>((sessionInfo, identification) => testResponse);
return mockedInterface.Object;
}
开发者ID:Snuk,项目名称:simple.mailserver,代码行数:8,代码来源:SmtpSessionInfoResponderFacts.cs
注:本文中的SmtpResponse类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论