本文整理汇总了C#中RegressionTests.Shared.SMTPClientSimulator.Connect方法的典型用法代码示例。如果您正苦于以下问题:C# SMTPClientSimulator.Connect方法的具体用法?C# SMTPClientSimulator.Connect怎么用?C# SMTPClientSimulator.Connect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RegressionTests.Shared.SMTPClientSimulator
的用法示例。
在下文中一共展示了SMTPClientSimulator.Connect方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestTooManyInvalidCommandsTempError
public void TestTooManyInvalidCommandsTempError()
{
Account account = SingletonProvider<TestSetup>.Instance.AddAccount(_domain, "[email protected]", "test");
for (int i = 0; i < 10; i++)
SingletonProvider<TestSetup>.Instance.AddAccount(_domain, string.Format("test{0}@test.com", i), "test");
Application application = SingletonProvider<TestSetup>.Instance.GetApp();
Settings settings = _settings;
settings.DisconnectInvalidClients = true;
settings.MaxNumberOfInvalidCommands = 5;
settings.AntiSpam.GreyListingEnabled = true;
var sim = new SMTPClientSimulator();
sim.Connect();
string res = sim.Receive();
sim.Send("EHLO test.com\r\n");
res = sim.Receive();
sim.Send("MAIL FROM: <[email protected]>\r\n");
res = sim.Receive();
for (int i = 1; i < 10; i++)
{
string address = string.Format("test{0}@test.com", i);
sim.Send("RCPT TO: " + address + "\r\n");
res = sim.Receive();
CustomAssert.AreEqual("451 Please try again later.\r\n", res);
}
sim.Disconnect();
}
示例2: TestTooManyInvalidCommandsAUTH
public void TestTooManyInvalidCommandsAUTH()
{
Application application = SingletonProvider<TestSetup>.Instance.GetApp();
Settings settings = _settings;
settings.DisconnectInvalidClients = true;
settings.MaxNumberOfInvalidCommands = 3;
var sim = new SMTPClientSimulator();
sim.Connect();
sim.Send("EHLO test.com\r\n");
for (int i = 1; i <= 6; i++)
{
try
{
sim.Send("AUTH LOGIN\r\n");
string result = sim.Receive();
if (result.Contains("Too many invalid commands"))
return;
if (i > 5)
break;
sim.Send("YWNhZGVtaWE=\r\n");
sim.Receive();
sim.Send("abc\r\n");
sim.Receive();
}
catch (Exception)
{
if (i < 5)
{
CustomAssert.Fail("Was disconnected prematurely.");
}
return;
}
}
CustomAssert.Fail("Wasn't disconnected");
}
示例3: TestTooManyInvalidCommandsHELO
public void TestTooManyInvalidCommandsHELO()
{
Settings settings = _settings;
settings.DisconnectInvalidClients = true;
settings.MaxNumberOfInvalidCommands = 3;
var sim = new SMTPClientSimulator();
sim.Connect();
sim.Receive(); // banner
sim.SendAndReceive("HELO\r\n");
sim.SendAndReceive("HELO\r\n");
sim.SendAndReceive("HELO\r\n");
sim.SendAndReceive("HELO\r\n");
var result = sim.SendAndReceive("HELO\r\n");
CustomAssert.IsTrue(result.Contains("Too many invalid commands"), result);
}
示例4: TestSameRecipientMultipleTimes
public void TestSameRecipientMultipleTimes()
{
Logging logging = SingletonProvider<TestSetup>.Instance.GetApp().Settings.Logging;
logging.AWStatsEnabled = true;
logging.Enabled = true;
if (File.Exists(logging.CurrentAwstatsLog))
File.Delete(logging.CurrentAwstatsLog);
Account account1 = SingletonProvider<TestSetup>.Instance.AddAccount(_domain, "[email protected]", "test");
var oSMTP = new SMTPClientSimulator();
oSMTP.Connect();
CustomAssert.IsTrue(oSMTP.Receive().StartsWith("220"));
oSMTP.Send("HELO test\r\n");
CustomAssert.IsTrue(oSMTP.Receive().StartsWith("250"));
oSMTP.Send("MAIL FROM: [email protected]\r\n");
CustomAssert.IsTrue(oSMTP.Receive().StartsWith("250"));
oSMTP.Send("RCPT TO: [email protected]\r\n");
CustomAssert.IsTrue(oSMTP.Receive().StartsWith("250"));
oSMTP.Send("RCPT TO: [email protected]\r\n");
CustomAssert.IsTrue(oSMTP.Receive().StartsWith("250"));
oSMTP.Disconnect();
}
示例5: TestRcptToSyntax
public void TestRcptToSyntax()
{
Account account1 = SingletonProvider<TestSetup>.Instance.AddAccount(_domain, "[email protected]", "test");
var oSMTP = new SMTPClientSimulator();
oSMTP.Connect();
CustomAssert.IsTrue(oSMTP.Receive().StartsWith("220"));
oSMTP.Send("HELO test\r\n");
CustomAssert.IsTrue(oSMTP.Receive().StartsWith("250"));
// A few tests of invalid syntax.
CustomAssert.IsTrue(oSMTP.SendAndReceive("MAIL FROM: <[email protected]>\r\n").StartsWith("250"));
CustomAssert.IsFalse(oSMTP.SendAndReceive("RCPT TO: [email protected]>\r\n").StartsWith("250"));
CustomAssert.IsFalse(oSMTP.SendAndReceive("RCPT TO: <[email protected]\r\n").StartsWith("250"));
CustomAssert.IsFalse(oSMTP.SendAndReceive("RCPT TO <[email protected]\r\n").StartsWith("250"));
CustomAssert.IsFalse(oSMTP.SendAndReceive("RCPT TO<[email protected]\r\n").StartsWith("250"));
CustomAssert.IsTrue(oSMTP.SendAndReceive("RCPT TO: <[email protected]>\r\n").StartsWith("250"));
CustomAssert.IsTrue(oSMTP.SendAndReceive("RCPT TO: [email protected]\r\n").StartsWith("250"));
oSMTP.Disconnect();
}
示例6: TestMailFromSyntaxValidation
public void TestMailFromSyntaxValidation()
{
Account account1 = SingletonProvider<TestSetup>.Instance.AddAccount(_domain, "[email protected]", "test");
var oSMTP = new SMTPClientSimulator();
oSMTP.Connect();
CustomAssert.IsTrue(oSMTP.Receive().StartsWith("220"));
oSMTP.Send("HELO test\r\n");
CustomAssert.IsTrue(oSMTP.Receive().StartsWith("250"));
// A few tests of invalid syntax.
CustomAssert.IsFalse(oSMTP.SendAndReceive("MAIL FROM: <[email protected]\r\n").StartsWith("250"));
CustomAssert.IsFalse(oSMTP.SendAndReceive("MAIL FROM: [email protected]>\r\n").StartsWith("250"));
CustomAssert.IsFalse(oSMTP.SendAndReceive("MAIL FROM: < [email protected] \r\n").StartsWith("250"));
CustomAssert.IsFalse(oSMTP.SendAndReceive("MAIL FROM: < \r\n").StartsWith("250"));
CustomAssert.IsFalse(oSMTP.SendAndReceive("MAIL FROM: > \r\n").StartsWith("250"));
CustomAssert.IsFalse(oSMTP.SendAndReceive("MAIL FROM: <[email protected]\r\n").StartsWith("250"));
CustomAssert.IsFalse(oSMTP.SendAndReceive("MAIL FROM <[email protected]>\r\n").StartsWith("250"));
CustomAssert.IsFalse(oSMTP.SendAndReceive("MAIL FROM [email protected]\r\n").StartsWith("250"));
// Valid syntax, < and >
CustomAssert.IsTrue(oSMTP.SendAndReceive("MAIL FROM: <[email protected]>\r\n").StartsWith("250"));
CustomAssert.IsTrue(oSMTP.SendAndReceive("RSET\r\n").StartsWith("250"));
CustomAssert.IsTrue(oSMTP.SendAndReceive("MAIL FROM: [email protected]\r\n").StartsWith("250"));
CustomAssert.IsTrue(oSMTP.SendAndReceive("RSET\r\n").StartsWith("250"));
CustomAssert.IsTrue(oSMTP.SendAndReceive("MAIL FROM: [email protected] \r\n").StartsWith("250"));
CustomAssert.IsTrue(oSMTP.SendAndReceive("RSET\r\n").StartsWith("250"));
CustomAssert.IsTrue(oSMTP.SendAndReceive("MAIL FROM:[email protected]\r\n").StartsWith("250"));
CustomAssert.IsTrue(oSMTP.SendAndReceive("RSET\r\n").StartsWith("250"));
CustomAssert.IsTrue(oSMTP.SendAndReceive("MAIL FROM:<[email protected]>\r\n").StartsWith("250"));
CustomAssert.IsTrue(oSMTP.SendAndReceive("RSET\r\n").StartsWith("250"));
oSMTP.Disconnect();
}
示例7: TestHelo
public void TestHelo()
{
var oSimulator = new SMTPClientSimulator();
oSimulator.Connect();
string sWelcome = oSimulator.Receive();
oSimulator.Send("HELO\r\n");
string sResponse = oSimulator.Receive();
if (!sResponse.StartsWith("501"))
throw new Exception("Invalid response to HELO");
oSimulator.Send("HELO \r\n");
sResponse = oSimulator.Receive();
if (!sResponse.StartsWith("501"))
throw new Exception("Invalid response to HELO");
oSimulator.Send("HELO TEST.COM\r\n");
sResponse = oSimulator.Receive();
if (!sResponse.StartsWith("250"))
throw new Exception("Invalid response to HELO");
oSimulator.Send("HELO TEST.COM\r\n");
sResponse = oSimulator.Receive();
if (!sResponse.StartsWith("250"))
throw new Exception("Invalid response to HELO");
oSimulator.Send("EHLO TEST.COM\r\n");
sResponse = oSimulator.Receive();
if (!sResponse.StartsWith("250"))
throw new Exception("Invalid response to HELO");
oSimulator.Send("EHLO TEST.COM\r\n");
sResponse = oSimulator.Receive();
if (!sResponse.StartsWith("250"))
throw new Exception("Invalid response to HELO");
oSimulator.Disconnect();
}
示例8: TestTooManyInvalidCommandsHELO
public void TestTooManyInvalidCommandsHELO()
{
Application application = SingletonProvider<TestSetup>.Instance.GetApp();
Settings settings = _settings;
settings.DisconnectInvalidClients = true;
settings.MaxNumberOfInvalidCommands = 3;
var sim = new SMTPClientSimulator();
sim.Connect(25);
for (int i = 1; i <= 6; i++)
{
sim.Send("HELO\r\n");
string result = sim.Receive();
if (result.Contains("Too many invalid commands"))
break;
if (i > 5)
Assert.Fail();
}
}