本文整理汇总了C#中RegressionTests.Shared.ImapClientSimulator.GetMessageCount方法的典型用法代码示例。如果您正苦于以下问题:C# ImapClientSimulator.GetMessageCount方法的具体用法?C# ImapClientSimulator.GetMessageCount怎么用?C# ImapClientSimulator.GetMessageCount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RegressionTests.Shared.ImapClientSimulator
的用法示例。
在下文中一共展示了ImapClientSimulator.GetMessageCount方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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 = GetPublicDirectory();
CustomAsserts.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.
Assert.AreEqual(1, oSimulator.GetMessageCount("INBOX"));
oSimulator.Disconnect();
// The public directory should still be empty - the message was added to the user account.
CustomAsserts.AssertFilesInDirectory(publicDir, 0);
// There should be a single file in the users directory.
CustomAsserts.AssertFilesInUserDirectory(oAccount, 1);
}
示例2: 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");
Assert.AreEqual(0, oSimulator.GetMessageCount("INBOX"));
oSimulator.Disconnect();
}
示例3: ConfirmFileAddedToCorrectPublicFolder
public void ConfirmFileAddedToCorrectPublicFolder()
{
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 = GetPublicDirectory();
CustomAsserts.AssertFilesInDirectory(publicDir, 0);
IMAPFolders folders = _application.Settings.PublicFolders;
IMAPFolder folder = folders.Add("Share");
folder.Save();
// Give everyone access to the folder.
IMAPFolderPermission permission = folder.Permissions.Add();
permission.PermissionType = eACLPermissionType.ePermissionTypeAnyone;
permission.set_Permission(eACLPermission.ePermissionLookup, true);
permission.set_Permission(eACLPermission.ePermissionRead, true);
permission.set_Permission(eACLPermission.ePermissionInsert, true);
permission.Save();
// Add the message to the public folder.
oSimulator.Connect();
oSimulator.LogonWithLiteral("[email protected]", "test");
oSimulator.SendSingleCommandWithLiteral("A01 APPEND #Public.Share {4}", "ABCD");
// Confirm that the message exists in the public folder and not in the inbox.
Assert.AreEqual(1, oSimulator.GetMessageCount("#Public.Share"));
Assert.AreEqual(0, oSimulator.GetMessageCount("INBOX"));
oSimulator.Disconnect();
// The public directory should now contain the message.
CustomAsserts.AssertFilesInDirectory(publicDir, 1);
// There users directory should still be empty.
CustomAsserts.AssertFilesInUserDirectory(oAccount, 0);
}
示例4: AssertMessageCount
public static void AssertMessageCount(string accountName, string accountPassword, string folderName,
int expectedCount)
{
if (expectedCount == 0)
{
// make sure that we aren't currently delivering messages.
CustomAsserts.AssertRecipientsInDeliveryQueue(0);
}
var oIMAP = new ImapClientSimulator();
Assert.IsTrue(oIMAP.ConnectAndLogon(accountName, accountPassword));
if (expectedCount != 0)
oIMAP.AssertFolderExists(folderName);
int currentCount = 0;
int timeout = 1000; // 1000 * 25 = 25 seconds.
while (timeout > 0)
{
currentCount = oIMAP.GetMessageCount(folderName);
if (currentCount > expectedCount)
break;
if (currentCount == expectedCount)
{
oIMAP.Disconnect();
return;
}
timeout--;
Thread.Sleep(25);
}
oIMAP.Disconnect();
string error = "Wrong number of messages in mailbox " + folderName + " in account " + accountName +
" Actual: " + currentCount.ToString() + " Expected: " + expectedCount.ToString();
Assert.Fail(error);
}
示例5: TestAppendToPublicFolder
public void TestAppendToPublicFolder()
{
Application application = SingletonProvider<TestSetup>.Instance.GetApp();
Account account = 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 = account.ID;
permission.PermissionType = eACLPermissionType.ePermissionTypeUser;
permission.set_Permission(eACLPermission.ePermissionLookup, true);
permission.set_Permission(eACLPermission.ePermissionRead, true);
permission.set_Permission(eACLPermission.ePermissionInsert, true);
permission.set_Permission(eACLPermission.ePermissionPost, true);
permission.Save();
var oSimulator = new ImapClientSimulator();
string sWelcomeMessage = oSimulator.Connect();
oSimulator.LogonWithLiteral(account.Address, "test");
oSimulator.SendSingleCommandWithLiteral("A01 APPEND #Public.Share1 {4}", "ABCD");
Assert.AreEqual(1, oSimulator.GetMessageCount("#Public.Share1"));
oSimulator.Disconnect();
}
示例6: TestAppendResponseContainsExists
public void TestAppendResponseContainsExists()
{
Account oAccount = SingletonProvider<TestSetup>.Instance.AddAccount(_domain, "[email protected]", "test");
var oSimulator = new ImapClientSimulator();
string sWelcomeMessage = oSimulator.Connect();
oSimulator.LogonWithLiteral("[email protected]", "test");
Assert.IsTrue(oSimulator.SelectFolder("Inbox"));
string response1 = oSimulator.SendSingleCommandWithLiteral("A01 APPEND INBOX {4}", "ABCD");
Assert.IsTrue(response1.Contains("* 1 EXISTS"), response1);
Assert.IsTrue(response1.Contains("* 1 RECENT"), response1);
Assert.AreEqual(1, oSimulator.GetMessageCount("INBOX"));
oSimulator.Disconnect();
}
示例7: TestPOP3TransactionSafety
public void TestPOP3TransactionSafety()
{
Account account = SingletonProvider<TestSetup>.Instance.AddAccount(_domain, "[email protected]", "test");
SmtpClientSimulator.StaticSend(account.Address, account.Address, "Test", "TestBody");
Pop3ClientSimulator.AssertMessageCount(account.Address, "test", 1);
var sim = new Pop3ClientSimulator();
sim.ConnectAndLogon(account.Address, "test");
// Now delete the message using an IMAP client.
var imapSimulator = new ImapClientSimulator();
Assert.IsTrue(imapSimulator.ConnectAndLogon(account.Address, "test"));
Assert.IsTrue(imapSimulator.SelectFolder("INBOX"));
Assert.IsTrue(imapSimulator.SetDeletedFlag(1));
Assert.IsTrue(imapSimulator.Expunge());
Assert.AreEqual(0, imapSimulator.GetMessageCount("Inbox"));
SmtpClientSimulator.StaticSend(account.Address, account.Address, "Test", "TestBody");
ImapClientSimulator.AssertMessageCount(account.Address, "test", "Inbox", 1);
// This deletion should not have any effect, since the POP3 connection is referencing an old message.
sim.DELE(1);
sim.QUIT();
Assert.AreEqual(1, imapSimulator.GetMessageCount("Inbox"));
}
示例8: TestImportOfMessageIntoOtherFolder
public void TestImportOfMessageIntoOtherFolder()
{
string @messageText =
"From: [email protected]\r\n" +
"\r\n" +
"Test\r\n";
Account account = SingletonProvider<TestSetup>.Instance.AddAccount(_domain, "[email protected]", "test");
account.IMAPFolders.Add("Woho");
string domainPath = Path.Combine(_application.Settings.Directories.DataDirectory, "test.com");
string accountPath = Path.Combine(domainPath, "test");
Directory.CreateDirectory(accountPath);
string fileName = Path.Combine(accountPath, "something.eml");
File.WriteAllText(fileName, messageText);
Assert.IsTrue(_application.Utilities.ImportMessageFromFileToIMAPFolder(fileName, account.ID, "Woho"));
Pop3ClientSimulator.AssertMessageCount("[email protected]", "test", 0);
var sim = new ImapClientSimulator();
sim.ConnectAndLogon("[email protected]", "test");
Assert.AreEqual(1, sim.GetMessageCount("Woho"));
sim.Disconnect();
}