Пример #1
0
        public static void AssertMessageCount(string accountName, string accountPassword, string folderName,
                                              int expectedCount)
        {
            if (expectedCount == 0)
            {
                // make sure that we aren't currently delivering messages.
                TestSetup.AssertRecipientsInDeliveryQueue(0);
            }

            var oIMAP = new IMAPClientSimulator();

            CustomAssert.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();

            CustomAssert.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.
            TestSetup.AssertRecipientsInDeliveryQueue(0);
             }

             var oIMAP = new IMAPClientSimulator();
             CustomAssert.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();
             CustomAssert.Fail(error);
        }