コード例 #1
0
ファイル: POP3Simulator.cs プロジェクト: japi/hmailserver
        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 POP3Simulator();

            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));
        }
コード例 #2
0
ファイル: POP3Simulator.cs プロジェクト: japi/hmailserver
        public static string AssertGetFirstMessageText(string accountName, string accountPassword)
        {
            // Wait for the message to appear.
             var pop3 = new POP3Simulator();
             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;
        }