本文整理汇总了C#中RegressionTests.Shared.IMAPClientSimulator.Disconnect方法的典型用法代码示例。如果您正苦于以下问题:C# IMAPClientSimulator.Disconnect方法的具体用法?C# IMAPClientSimulator.Disconnect怎么用?C# IMAPClientSimulator.Disconnect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RegressionTests.Shared.IMAPClientSimulator
的用法示例。
在下文中一共展示了IMAPClientSimulator.Disconnect方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestIMAPLogonFailure
public void TestIMAPLogonFailure()
{
_settings.AutoBanOnLogonFailure = true;
_settings.MaxInvalidLogonAttempts = 4;
_settings.MaxInvalidLogonAttemptsWithin = 5;
_settings.AutoBanMinutes = 3;
Account account = SingletonProvider<TestSetup>.Instance.AddAccount(_domain, "[email protected]", "test");
var sim = new IMAPClientSimulator();
CustomAssert.IsTrue(sim.ConnectAndLogon(account.Address, "test"));
sim.Disconnect();
// confirm that we can retrieve welcome message.
CustomAssert.IsTrue(sim.GetWelcomeMessage().StartsWith("* OK"));
// fail to log on 3 times.
for (int i = 0; i < 4; i++)
{
string errorMessage;
CustomAssert.IsFalse(sim.ConnectAndLogon(account.Address, "testA", out errorMessage));
sim.Disconnect();
if (i == 3)
{
CustomAssert.IsTrue(errorMessage.Contains("Too many invalid logon attempts."));
}
}
CustomAssert.IsTrue(sim.GetWelcomeMessage().Length == 0);
string logText = TestSetup.ReadCurrentDefaultLog();
CustomAssert.IsTrue(logText.Contains("Blocked either by IP range or by connection limit."), logText);
}
示例2: TestBatchOfCommands
public void TestBatchOfCommands()
{
Account account = SingletonProvider<TestSetup>.Instance.AddAccount(_domain, "[email protected]", "test");
var oSimulator = new IMAPClientSimulator();
string sWelcomeMessage = oSimulator.Connect();
oSimulator.Logon(account.Address, "test");
string commandSequence = "";
for (int i = 0; i < 200; i++)
{
commandSequence += "A" + i.ToString() + " SELECT INBOX\r\n";
}
commandSequence = commandSequence.TrimEnd("\r\n".ToCharArray());
string result = oSimulator.Send(commandSequence);
CustomAssert.IsFalse(result.StartsWith("* BYE"));
oSimulator.Disconnect();
sWelcomeMessage = oSimulator.Connect();
oSimulator.Logon(account.Address, "test");
commandSequence = "";
for (int i = 0; i < 500; i++)
{
commandSequence += "A" + i.ToString() + " SELECT INBOX\r\n";
}
commandSequence = commandSequence.TrimEnd("\r\n".ToCharArray());
result = oSimulator.Send(commandSequence);
CustomAssert.IsFalse(result.StartsWith("* BYE Excessive number of buffered commands"));
oSimulator.Disconnect();
}
示例3: TestChangeRecentFlag
public void TestChangeRecentFlag()
{
Account oAccount = SingletonProvider<TestSetup>.Instance.AddAccount(_domain, "[email protected]", "test");
CustomAssert.IsTrue(SMTPClientSimulator.StaticSend("[email protected]", oAccount.Address, "Test", "test"));
POP3ClientSimulator.AssertMessageCount(oAccount.Address, "test", 1);
var simulator = new IMAPClientSimulator();
simulator.ConnectAndLogon(oAccount.Address, "test");
string result = simulator.ExamineFolder("Inbox");
CustomAssert.IsTrue(result.Contains("* 1 RECENT"), result);
simulator.Close();
simulator.Disconnect();
simulator = new IMAPClientSimulator();
simulator.ConnectAndLogon(oAccount.Address, "test");
CustomAssert.IsTrue(simulator.SelectFolder("Inbox", out result));
CustomAssert.IsTrue(result.Contains("* 1 RECENT"), result);
simulator.Close();
simulator.Disconnect();
simulator = new IMAPClientSimulator();
simulator.ConnectAndLogon(oAccount.Address, "test");
result = simulator.ExamineFolder("Inbox");
CustomAssert.IsTrue(result.Contains("* 0 RECENT"), result);
simulator.Close();
simulator.Disconnect();
}
示例4: FolderMarkedAsReadOnlyWhenUserHasReadOnlyRights
public void FolderMarkedAsReadOnlyWhenUserHasReadOnlyRights()
{
Application application = SingletonProvider<TestSetup>.Instance.GetApp();
Account account1 = SingletonProvider<TestSetup>.Instance.AddAccount(_domain, "[email protected]", "test");
IMAPFolders publicFolders = _settings.PublicFolders;
IMAPFolder folder = publicFolders.Add("Share1");
folder.Save();
IMAPFolderPermission permission = folder.Permissions.Add();
permission.PermissionAccountID = account1.ID;
permission.PermissionType = eACLPermissionType.ePermissionTypeUser;
permission.set_Permission(eACLPermission.ePermissionLookup, true);
permission.set_Permission(eACLPermission.ePermissionRead, true);
permission.Save();
string selectResult = string.Empty;
var oSimulator1 = new IMAPClientSimulator();
oSimulator1.Connect();
oSimulator1.LogonWithLiteral(account1.Address, "test");
oSimulator1.SelectFolder("#Public.Share1", out selectResult);
oSimulator1.Disconnect();
CustomAssert.IsTrue(selectResult.Contains("[READ-ONLY]"), selectResult);
CustomAssert.IsFalse(selectResult.Contains("[READ-WRITE]"), selectResult);
}
示例5: TestDateSortOrder
public void TestDateSortOrder()
{
Account oAccount = SingletonProvider<TestSetup>.Instance.AddAccount(_domain, "[email protected]", "test");
var oSimulator = new IMAPClientSimulator();
string sWelcomeMessage = oSimulator.Connect();
oSimulator.LogonWithLiteral("[email protected]", "test");
CustomAssert.IsTrue(oSimulator.SelectFolder("Inbox"));
string response =
oSimulator.SendSingleCommandWithLiteral("A04 APPEND INBOX \"22-Feb-2008 22:00:00 +0200\" {37}",
"Date: Wed, 15 Dec 2010 13:00:00 +0000");
CustomAssert.IsTrue(response.Contains("* 1 EXISTS"), response);
response = oSimulator.SendSingleCommandWithLiteral("A04 APPEND INBOX \"22-Feb-2008 21:00:00 +0200\" {37}",
"Date: Wed, 15 Dec 2010 14:00:00 +0000");
CustomAssert.IsTrue(response.Contains("* 2 EXISTS"), response);
response = oSimulator.SendSingleCommandWithLiteral("A04 APPEND INBOX \"22-Feb-2008 20:00:00 +0200\" {37}",
"Date: Wed, 15 Dec 2010 12:00:00 +0000");
CustomAssert.IsTrue(response.Contains("* 3 EXISTS"), response);
response = oSimulator.SendSingleCommandWithLiteral("A04 APPEND INBOX \"23-Feb-2008 01:30:23 +0200\" {37}",
"Date: Wed, 15 Dec 2010 11:00:00 +0000");
CustomAssert.IsTrue(response.Contains("* 4 EXISTS"), response);
string sortDateResponse = oSimulator.SendSingleCommand("A10 SORT (DATE) US-ASCII ALL");
CustomAssert.IsTrue(sortDateResponse.Contains(" 4 3 1 2"));
oSimulator.Disconnect();
}
示例6: TestIMAPServer
public void TestIMAPServer()
{
TestSetup.DeleteCurrentDefaultLog();
Account account = SingletonProvider<TestSetup>.Instance.AddAccount(_domain, "[email protected]", "test");
for (int i = 0; i < 30; i++)
{
try
{
var imapSim = new IMAPClientSimulator(true, 14301);
imapSim.ConnectAndLogon(account.Address, "test");
CustomAssert.IsTrue(imapSim.SelectFolder("Inbox"), "SelectInbox");
imapSim.CreateFolder("Test");
CustomAssert.IsTrue(imapSim.SelectFolder("Test"), "SelectTest");
CustomAssert.IsTrue(imapSim.Logout(), "Logout");
imapSim.Disconnect();
break;
}
catch (Exception)
{
if (i == 29)
throw;
}
}
}
示例7: ExamineFolderRequiresReadPermission
public void ExamineFolderRequiresReadPermission()
{
Application application = SingletonProvider<TestSetup>.Instance.GetApp();
Account account1 = SingletonProvider<TestSetup>.Instance.AddAccount(_domain, "[email protected]", "test");
IMAPFolders publicFolders = _settings.PublicFolders;
IMAPFolder folder = publicFolders.Add("Share1");
folder.Save();
IMAPFolderPermission permission = folder.Permissions.Add();
permission.PermissionAccountID = account1.ID;
permission.PermissionType = eACLPermissionType.ePermissionTypeUser;
permission.set_Permission(eACLPermission.ePermissionLookup, true);
permission.Save();
string selectResult = string.Empty;
var oSimulator1 = new IMAPClientSimulator();
oSimulator1.Connect();
oSimulator1.LogonWithLiteral(account1.Address, "test");
string examineResult = oSimulator1.ExamineFolder("#Public.Share1");
oSimulator1.Disconnect();
CustomAssert.IsTrue(examineResult.Contains("ACL: Read permission denied (Required for EXAMINE command)."),
examineResult);
}
示例8: ConfirmFileAddedToCorrectAccountFolder
public void ConfirmFileAddedToCorrectAccountFolder()
{
TestSetup testSetup = SingletonProvider<TestSetup>.Instance;
Account oAccount = testSetup.AddAccount(_domain, "[email protected]", "test");
var oSimulator = new IMAPClientSimulator();
// Confirm that the public folder is empty before we start our test.
string publicDir = testSetup.GetPublicDirectory();
testSetup.AssertFilesInDirectory(publicDir, 0);
// Add a message to the inbox.
oSimulator.Connect();
oSimulator.LogonWithLiteral("[email protected]", "test");
oSimulator.SendSingleCommandWithLiteral("A01 APPEND INBOX {4}", "ABCD");
// Confirm it exists in the IMAP folder.
CustomAssert.AreEqual(1, oSimulator.GetMessageCount("INBOX"));
oSimulator.Disconnect();
// The public directory should still be empty - the message was added to the user account.
testSetup.AssertFilesInDirectory(publicDir, 0);
// There should be a single file in the users directory.
testSetup.AssertFilesInUserDirectory(oAccount, 1);
}
示例9: TestChangeSeenFlag
public void TestChangeSeenFlag()
{
Account oAccount = SingletonProvider<TestSetup>.Instance.AddAccount(_domain, "[email protected]", "test");
CustomAssert.IsTrue(SMTPClientSimulator.StaticSend("[email protected]", oAccount.Address, "Test", "test"));
POP3ClientSimulator.AssertMessageCount(oAccount.Address, "test", 1);
var simulator = new IMAPClientSimulator();
simulator.ConnectAndLogon(oAccount.Address, "test");
simulator.ExamineFolder("Inbox");
string flags = simulator.GetFlags(1);
string body = simulator.Fetch("1 RFC822");
string flagsAfter = simulator.GetFlags(1);
simulator.Close();
simulator.Disconnect();
CustomAssert.AreEqual(flags, flagsAfter);
var secondSimulator = new IMAPClientSimulator();
secondSimulator.ConnectAndLogon(oAccount.Address, "test");
secondSimulator.SelectFolder("Inbox");
string secondFlags = secondSimulator.GetFlags(1);
string secondBody = secondSimulator.Fetch("1 RFC822");
string secondFlagsAfter = secondSimulator.GetFlags(1);
secondSimulator.Close();
secondSimulator.Disconnect();
CustomAssert.AreNotEqual(secondFlags, secondFlagsAfter);
}
示例10: TestBodyStructureWithNonLatinCharacter
public void TestBodyStructureWithNonLatinCharacter()
{
Account account = SingletonProvider<TestSetup>.Instance.AddAccount(_domain, "[email protected]", "test");
string attachmentName = "本本本.zip";
string filename = Path.Combine(Path.GetTempPath(), attachmentName);
File.WriteAllText(filename, "tjena moss");
var message = new Message();
message.Charset = "utf-8";
message.AddRecipient("test", account.Address);
message.From = "Test";
message.FromAddress = account.Address;
message.Body = "hejsan";
message.Attachments.Add(filename);
message.Save();
TestSetup.AssertFolderMessageCount(account.IMAPFolders[0], 1);
var oSimulator = new IMAPClientSimulator();
oSimulator.ConnectAndLogon(account.Address, "test");
oSimulator.SelectFolder("INBOX");
string result = oSimulator.Fetch("1 BODYSTRUCTURE");
oSimulator.Disconnect();
// utf-8 representation of 本本本.zip:
CustomAssert.IsTrue(result.Contains("=?utf-8?B?5pys5pys5pys?=.zip"));
}
示例11: TestCreateFolderWithHash
public void TestCreateFolderWithHash()
{
Account oAccount = SingletonProvider<TestSetup>.Instance.AddAccount(_domain, "[email protected]", "test");
var oSimulator = new IMAPClientSimulator();
oSimulator.Connect();
oSimulator.Logon(oAccount.Address, "test");
CustomAssert.IsFalse(oSimulator.CreateFolder("#Test"));
CustomAssert.IsTrue(oSimulator.CreateFolder("Test.#Testar"));
oSimulator.Disconnect();
}
示例12: TestAppendBadLiteral
public void TestAppendBadLiteral()
{
Account oAccount = SingletonProvider<TestSetup>.Instance.AddAccount(_domain, "[email protected]", "test");
var oSimulator = new IMAPClientSimulator();
string sWelcomeMessage = oSimulator.Connect();
oSimulator.LogonWithLiteral("[email protected]", "test");
oSimulator.SendSingleCommandWithLiteral("A01 APPEND INBOX {TEST}", "ABCD");
CustomAssert.AreEqual(0, oSimulator.GetMessageCount("INBOX"));
oSimulator.Disconnect();
}
示例13: TestCreateDeepFolder
public void TestCreateDeepFolder()
{
Account oAccount = SingletonProvider<TestSetup>.Instance.AddAccount(_domain, "[email protected]", "test");
var oSimulator = new IMAPClientSimulator();
oSimulator.Connect();
oSimulator.LogonWithLiteral(oAccount.Address, "test");
string result =
oSimulator.Send("A01 CREATE 1.2.3.4.5.6.7.8.9.10.11.12.13.14.15.16.17.18.19.20.21.22.23.24.25.26");
CustomAssert.IsTrue(result.Contains("A01 NO"));
oSimulator.Disconnect();
}
示例14: TestCreateFolderWithSlash
public void TestCreateFolderWithSlash()
{
Account oAccount = SingletonProvider<TestSetup>.Instance.AddAccount(_domain, "[email protected]", "test");
const string folderName = "ABC\\123";
var oSimulator = new IMAPClientSimulator();
oSimulator.Connect();
oSimulator.Logon(oAccount.Address, "test");
CustomAssert.IsTrue(oSimulator.CreateFolder(folderName));
CustomAssert.IsTrue(oSimulator.List().Contains(folderName));
CustomAssert.IsTrue(oSimulator.SelectFolder(folderName));
oSimulator.Disconnect();
}
示例15: TestFetchCharsetInQuotesWithoutSpace
public void TestFetchCharsetInQuotesWithoutSpace()
{
Account account = SingletonProvider<TestSetup>.Instance.AddAccount(_domain, "[email protected]", "test");
SMTPClientSimulator.StaticSendRaw(account.Address, account.Address,
"From: [email protected]\r\n" +
"Content-Type: text/plain; charset =\"iso-8859-1\"\r\n" +
"\r\n" +
"Test\r\n");
IMAPClientSimulator.AssertMessageCount(account.Address, "test", "Inbox", 1);
var sim = new IMAPClientSimulator(account.Address, "test", "Inbox");
string result = sim.Fetch("1 BODYSTRUCTURE");
sim.Disconnect();
CustomAssert.IsTrue(result.Contains("(\"CHARSET\" \"iso-8859-1\")"), result);
}