Ejemplo n.º 1
0
        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;
        }
Ejemplo n.º 2
0
        public void TestPOP3Server()
        {
            Account account = SingletonProvider<TestSetup>.Instance.AddAccount(_domain, "*****@*****.**", "test");

             var smtpSim = new SMTPClientSimulator();
             CustomAssert.IsTrue(smtpSim.Send("*****@*****.**", account.Address, "Test", "MyBody"));

             for (int i = 0; i < 10; i++)
             {
            try
            {
               POP3Simulator.AssertMessageCount(account.Address, "test", 1);
               var pop3Sim = new POP3Simulator(true, 11000);
               string text = pop3Sim.GetFirstMessageText(account.Address, "test");

               CustomAssert.IsTrue(text.Contains("MyBody"));

               break;
            }
            catch (AssertionException)
            {
               throw;
            }
            catch (Exception)
            {
               if (i == 9)
                  throw;
            }
             }
        }
Ejemplo n.º 3
0
        public void TestAutoReplySubject()
        {
            // Create a test account
             // Fetch the default domain
             Account oAccount1 = SingletonProvider<TestSetup>.Instance.AddAccount(_domain,
                                                                              TestSetup.RandomString() + "@test.com",
                                                                              "test");
             Account oAccount2 = SingletonProvider<TestSetup>.Instance.AddAccount(_domain,
                                                                              TestSetup.RandomString() + "@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 oSMTP = new SMTPClientSimulator();
             oSMTP.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 oPOP3 = new POP3Simulator();

             POP3Simulator.AssertMessageCount(oAccount1.Address, "test", 1);
             string s = oPOP3.GetFirstMessageText(oAccount1.Address, "test");
             if (s.IndexOf("Subject: Auto-Reply: Test message") < 0)
            throw new Exception("ERROR - Auto reply subject not set properly.");
        }
Ejemplo n.º 4
0
        public void TestAutoReply()
        {
            // Create a test account
             // Fetch the default domain
             Account oAccount1 = SingletonProvider<TestSetup>.Instance.AddAccount(_domain,
                                                                              TestSetup.RandomString() + "@test.com",
                                                                              "test");
             Account oAccount2 = SingletonProvider<TestSetup>.Instance.AddAccount(_domain,
                                                                              TestSetup.RandomString() + "@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 oSMTP = new SMTPClientSimulator();
             oSMTP.Send(oAccount1.Address, oAccount2.Address, "Test message", "This is the body");

             var oPOP3 = new POP3Simulator();
             POP3Simulator.AssertMessageCount(oAccount1.Address, "test", 1);
             POP3Simulator.AssertMessageCount(oAccount2.Address, "test", 1);
             string s = oPOP3.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
             oSMTP.Send(oAccount1.Address, oAccount2.Address, "Test message", "This is the body");

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

             s = oPOP3.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();
        }