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)
            {
                Assert.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)
            Assert.Fail("Message was found but contents could not be received");

             return text;
        }
Example #3
0
        public void TestSMTPServer()
        {
            Account account = SingletonProvider<TestSetup>.Instance.AddAccount(_domain, "*****@*****.**", "test");

             int i = 0;
             for (i = 0; i < 10; i++)
             {
            try
            {
               var smtpSim = new SmtpClientSimulator(true, 25001);
               smtpSim.Send("*****@*****.**", account.Address, "Test", "MyBody");

               break;
            }
            catch (Exception)
            {
               if (i == 9)
                  throw;
            }
             }

             Pop3ClientSimulator.AssertMessageCount(account.Address, "test", i + 1);
             var pop3Sim = new Pop3ClientSimulator(false, 110);
             string text = pop3Sim.GetFirstMessageText(account.Address, "test");
             Assert.IsTrue(text.Contains("MyBody"));
        }
Example #4
0
        public void TestAutoReplySubject()
        {
            // Create a test account
             // Fetch the default domain
             Account oAccount1 = SingletonProvider<TestSetup>.Instance.AddAccount(_domain,
                                                                              TestSetup.UniqueString() + "@test.com",
                                                                              "test");
             Account oAccount2 = SingletonProvider<TestSetup>.Instance.AddAccount(_domain,
                                                                              TestSetup.UniqueString() + "@test.com",
                                                                              "test");

             oAccount2.VacationMessageIsOn = true;
             oAccount2.VacationMessage = "I'm on vacation";
             oAccount2.VacationSubject = "Auto-Reply: %SUBJECT%";
             oAccount2.Save();

             // Send 1 message to this account
             var smtpClientSimulator = new SmtpClientSimulator();
             smtpClientSimulator.Send(oAccount1.Address, oAccount2.Address, "Test message", "This is the body");

             // Wait a second to be sure that the message
             // are delivered.

             // Check using POP3 that 2 messages exists.
             var pop3ClientSimulator = new Pop3ClientSimulator();

             Pop3ClientSimulator.AssertMessageCount(oAccount1.Address, "test", 1);
             string s = pop3ClientSimulator.GetFirstMessageText(oAccount1.Address, "test");
             if (s.IndexOf("Subject: Auto-Reply: Test message") < 0)
            throw new Exception("ERROR - Auto reply subject not set properly.");
        }
Example #5
0
        public void TestAutoReply()
        {
            // Create a test account
             // Fetch the default domain
             Account oAccount1 = SingletonProvider<TestSetup>.Instance.AddAccount(_domain,
                                                                              TestSetup.UniqueString() + "@test.com",
                                                                              "test");
             Account oAccount2 = SingletonProvider<TestSetup>.Instance.AddAccount(_domain,
                                                                              TestSetup.UniqueString() + "@test.com",
                                                                              "test");

             oAccount2.VacationMessageIsOn = true;
             oAccount2.VacationMessage = "I'm on vacation";
             oAccount2.VacationSubject = "Out of office!";
             oAccount2.Save();

             // Send 2 messages to this account.
             var smtpClientSimulator = new SmtpClientSimulator();
             smtpClientSimulator.Send(oAccount1.Address, oAccount2.Address, "Test message", "This is the body");

             var pop3ClientSimulator = new Pop3ClientSimulator();
             Pop3ClientSimulator.AssertMessageCount(oAccount1.Address, "test", 1);
             Pop3ClientSimulator.AssertMessageCount(oAccount2.Address, "test", 1);
             string s = pop3ClientSimulator.GetFirstMessageText(oAccount1.Address, "test");
             if (s.IndexOf("Out of office!") < 0)
            throw new Exception("ERROR - Auto reply subject not set properly.");

             oAccount2.VacationMessageIsOn = false;
             oAccount2.Save();

             oAccount2.VacationSubject = "";
             oAccount2.VacationMessageIsOn = true;
             oAccount2.Save();

             // Send another
             smtpClientSimulator.Send(oAccount1.Address, oAccount2.Address, "Test message", "This is the body");

             Pop3ClientSimulator.AssertMessageCount(oAccount2.Address, "test", 2);
             Pop3ClientSimulator.AssertMessageCount(oAccount1.Address, "test", 1);

             s = pop3ClientSimulator.GetFirstMessageText(oAccount1.Address, "test");
             if (s.ToLower().IndexOf("re: test message") < 0)
            throw new Exception("ERROR - Auto reply subject not set properly.");

             Assert.IsTrue(s.Contains("Auto-Submitted: auto-replied"));

             oAccount2.VacationMessageIsOn = false;
             oAccount2.Save();
        }