public static void AssertMessageCount(string accountName, string accountPassword, int expectedCount)
        {
            if (expectedCount == 0)
             {
            // just in case.
            TestSetup.AssertRecipientsInDeliveryQueue(0);
             }

             int timeout = 100;
             int actualCount = 0;
             while (timeout > 0)
             {
            var oPOP3 = new POP3ClientSimulator();

            actualCount = oPOP3.GetMessageCount(accountName, accountPassword);
            if (actualCount == expectedCount)
               return;

            if (actualCount > expectedCount)
               CustomAssert.Fail(
                  string.Format(
                     "Actual count exceeds expected count. Account name: {2}, Actual: {0}, Expected: {1}.",
                     actualCount, expectedCount, accountName));

            timeout--;
            Thread.Sleep(50);
             }

             CustomAssert.Fail(string.Format("Wrong number of messages in inbox for {0}. Actual: {1}, Expected: {2}",
                                   accountName, actualCount, expectedCount));
        }
        public static string AssertGetFirstMessageText(string accountName, string accountPassword)
        {
            // Wait for the message to appear.
            var pop3 = new POP3ClientSimulator();

            for (int i = 0; i < 5000; i++)
            {
                if (pop3.GetMessageCount(accountName, accountPassword) > 0)
                {
                    break;
                }

                Thread.Sleep(20);
            }

            // Download it.
            string text = pop3.GetFirstMessageText(accountName, accountPassword);

            if (text.Length == 0)
            {
                CustomAssert.Fail("Message was found but contents could not be received");
            }

            return(text);
        }
        public static string AssertGetFirstMessageText(string accountName, string accountPassword)
        {
            // Wait for the message to appear.
             var pop3 = new POP3ClientSimulator();
             for (int i = 0; i < 5000; i++)
             {
            if (pop3.GetMessageCount(accountName, accountPassword) > 0)
               break;

            Thread.Sleep(20);
             }

             // Download it.
             string text = pop3.GetFirstMessageText(accountName, accountPassword);

             if (text.Length == 0)
            CustomAssert.Fail("Message was found but contents could not be received");

             return text;
        }
        public static void AssertMessageCount(string accountName, string accountPassword, int expectedCount)
        {
            if (expectedCount == 0)
            {
                // just in case.
                TestSetup.AssertRecipientsInDeliveryQueue(0);
            }

            int timeout     = 100;
            int actualCount = 0;

            while (timeout > 0)
            {
                var oPOP3 = new POP3ClientSimulator();

                actualCount = oPOP3.GetMessageCount(accountName, accountPassword);
                if (actualCount == expectedCount)
                {
                    return;
                }

                if (actualCount > expectedCount)
                {
                    CustomAssert.Fail(
                        string.Format(
                            "Actual count exceeds expected count. Account name: {2}, Actual: {0}, Expected: {1}.",
                            actualCount, expectedCount, accountName));
                }

                timeout--;
                Thread.Sleep(50);
            }

            CustomAssert.Fail(string.Format("Wrong number of messages in inbox for {0}. Actual: {1}, Expected: {2}",
                                            accountName, actualCount, expectedCount));
        }
        private void WaitForMessageCount(TimeSpan timeout, int expectedMessageCount)
        {
            RetryHelper.TryAction(timeout, () =>
            {
               var pop3ClientSimulator = new POP3ClientSimulator();
               int count = pop3ClientSimulator.GetMessageCount("*****@*****.**", "test");

               Assert.AreEqual(expectedMessageCount, count);
            });
        }