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

            var smtpSim = new SmtpClientSimulator();

            smtpSim.Send("*****@*****.**", account.Address, "Test", "MyBody");

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

                    Assert.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.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.");
            }
        }