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 imap = new ImapClientSimulator(); Assert.IsTrue(imap.ConnectAndLogon(accountName, accountPassword)); if (expectedCount != 0) { imap.AssertFolderExists(folderName); } int currentCount = 0; int timeout = 1000; // 1000 * 25 = 25 seconds. while (timeout > 0) { currentCount = imap.GetMessageCount(folderName); if (currentCount > expectedCount) { break; } if (currentCount == expectedCount) { imap.Disconnect(); return; } timeout--; Thread.Sleep(25); } imap.Disconnect(); string error = "Wrong number of messages in mailbox " + folderName + " in account " + accountName + " Actual: " + currentCount.ToString() + " Expected: " + expectedCount.ToString(); Assert.Fail(error); }
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); }