Beispiel #1
0
        //[Test]
        //public void TestSampleMessages()
        //{
        //   string folder = @"C:\Temp\hMailServer IssueTracker ID 342 Example EML Files";

        //   var files = Directory.GetFiles(folder, "*.eml");

        //   foreach (var file in files)
        //   {
        //      string content = File.ReadAllText(file);

        //      TestMessage(content);

        //      SetUp();
        //      TestSetup();
        //   }
        //}

        private void TestMessage(string messageContent)
        {
            FetchAccount fetchAccount;

            using (var pop3Server = CreateServer(messageContent))
            {
                pop3Server.SendBufferMode = POP3Server.BufferMode.SingleBuffer;
                pop3Server.StartListen();

                fetchAccount = CreateFetchAccount();

                // Fetch message
                fetchAccount.DownloadNow();
                pop3Server.WaitForCompletion();
                LockHelper.WaitForUnlock(fetchAccount);
            }

            // Do it again
            using (var pop3Server = CreateServer(messageContent))
            {
                pop3Server.SendBufferMode = POP3Server.BufferMode.MessageAndTerminatonTogether;
                pop3Server.StartListen();

                fetchAccount.DownloadNow();
                pop3Server.WaitForCompletion();
                LockHelper.WaitForUnlock(fetchAccount);

                POP3ClientSimulator.AssertMessageCount(_account.Address, "test", 2);
                string downloadedMessage = POP3ClientSimulator.AssertGetFirstMessageText(_account.Address, "test");
                CustomAssert.IsTrue(downloadedMessage.Contains(messageContent));
            }
        }
Beispiel #2
0
        public void TestDisconnectAfterRetrCommand()
        {
            var pop3Server = CreateServer();

            pop3Server.SecondsToWaitBeforeTerminate  = 180;
            pop3Server.DisconnectAfterRetrCompletion = true;
            pop3Server.StartListen();

            // Connection will be dropped after we perform the RETR command.
            var fetchAccount = CreateFetchAccount();

            fetchAccount.DownloadNow();

            pop3Server.WaitForCompletion();
            LockHelper.WaitForUnlock(fetchAccount);

            // Simulate another download where the connection is not dropPed.
            pop3Server = CreateServer();
            pop3Server.SecondsToWaitBeforeTerminate  = 180;
            pop3Server.DisconnectAfterRetrCompletion = false;
            pop3Server.StartListen();

            fetchAccount.DownloadNow();
            pop3Server.WaitForCompletion();

            POP3ClientSimulator.AssertMessageCount(_account.Address, "test", 2);
        }
Beispiel #3
0
        public void TestMessageAndTerminationInSameBuffer()
        {
            FetchAccount fetchAccount;

            using (var pop3Server = CreateServer())
            {
                pop3Server.SendBufferMode = Pop3ServerSimulator.BufferMode.MessageAndTerminatonTogether;
                pop3Server.StartListen();

                fetchAccount = CreateFetchAccount();

                // Fetch message
                fetchAccount.DownloadNow();
                pop3Server.WaitForCompletion();
                LockHelper.WaitForUnlock(fetchAccount);
            }


            // Do it again, to make sure
            using (var pop3Server = CreateServer())
            {
                pop3Server.SendBufferMode = Pop3ServerSimulator.BufferMode.MessageAndTerminatonTogether;
                pop3Server.StartListen();

                fetchAccount.DownloadNow();
                pop3Server.WaitForCompletion();
                LockHelper.WaitForUnlock(fetchAccount);
            }

            Pop3ClientSimulator.AssertMessageCount(_account.Address, "test", 2);
            string downloadedMessage = Pop3ClientSimulator.AssertGetFirstMessageText(_account.Address, "test");

            Assert.IsTrue(downloadedMessage.Contains(_message));
        }