Esempio n. 1
3
        public void TestSearchOR()
        {
            hMailServer.Application application = SingletonProvider<Utilities>.Instance.GetApp();

             ;
             hMailServer.Account oAccount = SingletonProvider<Utilities>.Instance.AddAccount(_domain, "*****@*****.**", "test");

             // Send a message to this account.
             SMTPClientSimulator oSMTP = new SMTPClientSimulator();
             oSMTP.Send("*****@*****.**", "*****@*****.**", "Search test", "This is a test of IMAP Search");
             IMAPSimulator.AssertMessageCount("*****@*****.**", "test", "INBOX", 1);

             IMAPSimulator oSimulator = new IMAPSimulator();

             string sWelcomeMessage = oSimulator.Connect();
             oSimulator.Logon("*****@*****.**", "test");
             Assert.IsTrue(oSimulator.SelectFolder("INBOX"));

             if (oSimulator.Search("OR SINCE 28-May-2001 ON 28-May-2001 ALL") != "1")
             {
            throw new Exception("ERROR - Search or flag failed");
             }

             if (oSimulator.Search("OR SINCE 28-May-2012 ON 28-May-2012 ALL") != "")
             {
            throw new Exception("ERROR - Search or flag failed");
             }

             string formattedToday = DateTime.Now.ToString("dd-MMM-yyyy", System.Globalization.CultureInfo.InvariantCulture).ToUpper();
             if (oSimulator.Search("OR SINCE 28-May-2017 ON " + formattedToday + " ALL") != "1")
             {
            throw new Exception("ERROR - Search or flag failed");
             }

             string formatted2001 = new DateTime(2001,01,01).ToString("dd-MMM-yyyy").ToUpper();
             if (oSimulator.Search("OR SINCE 28-May-2008 ON " + formatted2001 + " ALL") != "1")
             {
            throw new Exception("ERROR - Search or flag failed");
             }
        }
Esempio n. 2
0
        public void TestSearchUTF8TEXT()
        {
            hMailServer.Account account = SingletonProvider <Utilities> .Instance.AddAccount(_domain, "*****@*****.**", "test");

            string body = Utilities.GetResource("Messages.MessageContainingGreekSubject.txt");

            SMTPClientSimulator.StaticSendRaw(account.Address, account.Address, body);

            POP3Simulator.AssertMessageCount(account.Address, "test", 1);

            IMAPSimulator oSimulator = new IMAPSimulator();

            Assert.IsTrue(oSimulator.ConnectAndLogon(account.Address, "test"));
            Assert.IsTrue(oSimulator.SelectFolder("INBOX"));

            string result = oSimulator.Search("CHARSET UTF-8 ALL TEXT GRΣΣK");

            Assert.AreEqual("1", result);

            result = oSimulator.Search("CHARSET UTF-8 ALL TEXT 標準語");
            Assert.AreEqual("1", result);

            result = oSimulator.Search("CHARSET UTF-8 ALL TEXT GRΣΣK標準語");
            Assert.AreEqual("1", result);

            result = oSimulator.Search("CHARSET UTF-8 ALL TEXT GRΣΣKWHAT標準語");
            Assert.AreEqual("", result);
        }
Esempio n. 3
0
        public void TestSearchORWithParenthesisSubject()
        {
            hMailServer.Application application = SingletonProvider <Utilities> .Instance.GetApp();

            ;
            hMailServer.Account oAccount = SingletonProvider <Utilities> .Instance.AddAccount(_domain, "*****@*****.**", "test");

            // Send a message to this account.
            SMTPClientSimulator oSMTP = new SMTPClientSimulator();

            oSMTP.Send("*****@*****.**", "*****@*****.**", "Test1", "This is a test of IMAP Search");
            IMAPSimulator.AssertMessageCount("*****@*****.**", "test", "INBOX", 1);
            oSMTP.Send("*****@*****.**", "*****@*****.**", "Test2", "This is a test of IMAP Search");
            IMAPSimulator.AssertMessageCount("*****@*****.**", "test", "INBOX", 2);

            IMAPSimulator oSimulator = new IMAPSimulator();

            string sWelcomeMessage = oSimulator.Connect();

            oSimulator.Logon("*****@*****.**", "test");
            Assert.IsTrue(oSimulator.SelectFolder("INBOX"));

            if (oSimulator.Search("OR (SUBJECT \"Test1\") (ON 28-May-2001) ALL") != "1")
            {
                throw new Exception("ERROR - Search or flag failed");
            }

            if (oSimulator.Search("OR (SUBJECT \"Test2\") (ON 28-May-2001) ALL") != "2")
            {
                throw new Exception("ERROR - Search or flag failed");
            }
        }
Esempio n. 4
0
        public void TestSearchON()
        {
            hMailServer.Application application = SingletonProvider <Utilities> .Instance.GetApp();

            ;
            hMailServer.Account oAccount = SingletonProvider <Utilities> .Instance.AddAccount(_domain, "*****@*****.**", "test");

            // Send a message to this account.
            SMTPClientSimulator oSMTP = new SMTPClientSimulator();

            oSMTP.Send("*****@*****.**", "*****@*****.**", "Search test", "This is a test of IMAP Search");
            IMAPSimulator.AssertMessageCount("*****@*****.**", "test", "INBOX", 1);

            IMAPSimulator oSimulator = new IMAPSimulator();

            string sWelcomeMessage = oSimulator.Connect();

            oSimulator.Logon("*****@*****.**", "test");
            Assert.IsTrue(oSimulator.SelectFolder("INBOX"));

            string formattedTomorrow = (DateTime.Now + new TimeSpan(1, 0, 0, 0)).ToString("dd-MMM-yyyy", System.Globalization.CultureInfo.InvariantCulture).ToUpper();
            string formattedToday    = DateTime.Now.ToString("dd-MMM-yyyy", System.Globalization.CultureInfo.InvariantCulture).ToUpper();

            if (oSimulator.Search("ON " + formattedTomorrow) != "")
            {
                throw new Exception("ERROR - Search or flag failed");
            }

            if (oSimulator.Search("ON " + formattedToday) != "1")
            {
                throw new Exception("ERROR - Search or flag failed");
            }
        }
Esempio n. 5
0
        public void TestSearchUSASCII()
        {
            hMailServer.Account account = SingletonProvider <Utilities> .Instance.AddAccount(_domain, "*****@*****.**", "test");

            SMTPClientSimulator.StaticSend(account.Address, account.Address, "MySubject", "MyBody");

            POP3Simulator.AssertMessageCount(account.Address, "test", 1);

            IMAPSimulator oSimulator = new IMAPSimulator();

            Assert.IsTrue(oSimulator.ConnectAndLogon(account.Address, "test"));
            Assert.IsTrue(oSimulator.SelectFolder("INBOX"));

            string result = oSimulator.Search("CHARSET US-ASCII ALL SUBJECT MySubject");

            Assert.AreEqual("1", result);

            result = oSimulator.Search("CHARSET US-ASCII ALL SUBJECT MySubjact");
            Assert.AreEqual("", result);
        }
Esempio n. 6
0
        public void TestAppendDeletedMessage()
        {
            hMailServer.Account oAccount = SingletonProvider<Utilities>.Instance.AddAccount(_domain, "*****@*****.**", "test");

             IMAPSimulator oSimulator = new IMAPSimulator();

             string sWelcomeMessage = oSimulator.Connect();
             oSimulator.Logon("*****@*****.**", "test");
             oSimulator.SendSingleCommandWithLiteral("A01 APPEND INBOX (\\Deleted) {4}", "ABCD");
             Assert.AreEqual(1, oSimulator.GetMessageCount("INBOX"));

             Assert.AreEqual("1", oSimulator.Search("DELETED"));

             oSimulator.Disconnect();
        }
Esempio n. 7
0
        public void TestSearch()
        {
            hMailServer.Application application = SingletonProvider <Utilities> .Instance.GetApp();

            hMailServer.Account oAccount = SingletonProvider <Utilities> .Instance.AddAccount(_domain, "se'*****@*****.**", "test");

            // Send a message to this account.
            SMTPClientSimulator oSMTP = new SMTPClientSimulator();

            oSMTP.Send(oAccount.Address, oAccount.Address, "Search test", "This is a test of IMAP Search");

            IMAPSimulator.AssertMessageCount(oAccount.Address, "test", "INBOX", 1);

            IMAPSimulator oSimulator = new IMAPSimulator();

            string sWelcomeMessage = oSimulator.Connect();

            oSimulator.Logon(oAccount.Address, "test");
            Assert.IsTrue(oSimulator.SelectFolder("INBOX"));

            oSimulator.SetFlagOnFirstMessage(true, "\\ANSWERED");
            if (oSimulator.Search("ANSWERED") != "1")
            {
                throw new Exception("ERROR - Search or flag failed");
            }

            oSimulator.SetFlagOnFirstMessage(false, "\\ANSWERED");
            if (oSimulator.Search("ANSWERED") != "")
            {
                throw new Exception("ERROR - Search or flag failed");
            }

            oSimulator.SetFlagOnFirstMessage(true, "\\DELETED");
            if (oSimulator.Search("DELETED") != "1")
            {
                throw new Exception("ERROR - Search or flag failed");
            }

            oSimulator.SetFlagOnFirstMessage(false, "\\DELETED");
            if (oSimulator.Search("DELETED") != "")
            {
                throw new Exception("ERROR - Search or flag failed");
            }

            oSimulator.SetFlagOnFirstMessage(true, "\\DRAFT");
            if (oSimulator.Search("DRAFT") != "1")
            {
                throw new Exception("ERROR - Search or flag failed");
            }

            oSimulator.SetFlagOnFirstMessage(false, "\\DRAFT");
            if (oSimulator.Search("DRAFT") != "")
            {
                throw new Exception("ERROR - Search or flag failed");
            }

            oSimulator.SetFlagOnFirstMessage(true, "\\FLAGGED");
            if (oSimulator.Search("FLAGGED  ") != "1")
            {
                throw new Exception("ERROR - Search or flag failed");
            }

            oSimulator.SetFlagOnFirstMessage(false, "\\FLAGGED");
            if (oSimulator.Search("FLAGGED") != "")
            {
                throw new Exception("ERROR - Search or flag failed");
            }

            oSimulator.SetFlagOnFirstMessage(true, "\\SEEN");
            if (oSimulator.Search("SEEN") != "1")
            {
                throw new Exception("ERROR - Search or flag failed");
            }

            oSimulator.SetFlagOnFirstMessage(false, "\\SEEN");
            if (oSimulator.Search("SEEN") != "")
            {
                throw new Exception("ERROR - Search or flag failed");
            }

            oSimulator.SetFlagOnFirstMessage(true, "\\ANSWERED");
            if (oSimulator.Search("UNANSWERED") != "")
            {
                throw new Exception("ERROR - Search or flag failed");
            }

            oSimulator.SetFlagOnFirstMessage(false, "\\ANSWERED");
            if (oSimulator.Search("UNANSWERED") != "1")
            {
                throw new Exception("ERROR - Search or flag failed");
            }

            oSimulator.SetFlagOnFirstMessage(true, "\\DELETED");
            if (oSimulator.Search("UNDELETED") != "")
            {
                throw new Exception("ERROR - Search or flag failed");
            }

            oSimulator.SetFlagOnFirstMessage(false, "\\DELETED");
            if (oSimulator.Search("UNDELETED") != "1")
            {
                throw new Exception("ERROR - Search or flag failed");
            }

            oSimulator.SetFlagOnFirstMessage(true, "\\DRAFT");
            if (oSimulator.Search("UNDRAFT") != "")
            {
                throw new Exception("ERROR - Search or flag failed");
            }

            oSimulator.SetFlagOnFirstMessage(false, "\\DRAFT");
            if (oSimulator.Search("UNDRAFT") != "1")
            {
                throw new Exception("ERROR - Search or flag failed");
            }

            oSimulator.SetFlagOnFirstMessage(true, "\\FLAGGED");
            if (oSimulator.Search("UNFLAGGED") != "")
            {
                throw new Exception("ERROR - Search or flag failed");
            }

            oSimulator.SetFlagOnFirstMessage(false, "\\FLAGGED");
            if (oSimulator.Search("UNFLAGGED") != "1")
            {
                throw new Exception("ERROR - Search or flag failed");
            }

            // SEARCH using LARGER & SMALLER
            if (oSimulator.Search("SMALLER 10") != "")
            {
                throw new Exception("ERROR - Search or flag failed");
            }

            if (oSimulator.Search("SMALLER 10000") != "1")
            {
                throw new Exception("ERROR - Search or flag failed");
            }

            if (oSimulator.Search("LARGER 10") != "1")
            {
                throw new Exception("ERROR - Search or flag failed");
            }

            if (oSimulator.Search("LARGER 10000") != "")
            {
                throw new Exception("ERROR - Search or flag failed");
            }
        }
Esempio n. 8
0
        public void TestSearch()
        {
            hMailServer.Application application = SingletonProvider<Utilities>.Instance.GetApp();

             hMailServer.Account oAccount = SingletonProvider<Utilities>.Instance.AddAccount(_domain, "se'*****@*****.**", "test");

             // Send a message to this account.
             SMTPClientSimulator oSMTP = new SMTPClientSimulator();
             oSMTP.Send(oAccount.Address, oAccount.Address, "Search test", "This is a test of IMAP Search");

             IMAPSimulator.AssertMessageCount(oAccount.Address, "test", "INBOX", 1);

             IMAPSimulator oSimulator = new IMAPSimulator();

             string sWelcomeMessage = oSimulator.Connect();
             oSimulator.Logon(oAccount.Address, "test");
             Assert.IsTrue(oSimulator.SelectFolder("INBOX"));

             oSimulator.SetFlagOnFirstMessage(true, "\\ANSWERED");
             if (oSimulator.Search("ANSWERED") != "1")
            throw new Exception("ERROR - Search or flag failed");

             oSimulator.SetFlagOnFirstMessage(false, "\\ANSWERED");
             if (oSimulator.Search("ANSWERED") != "")
            throw new Exception("ERROR - Search or flag failed");

             oSimulator.SetFlagOnFirstMessage(true, "\\DELETED");
             if (oSimulator.Search("DELETED") != "1")
            throw new Exception("ERROR - Search or flag failed");

             oSimulator.SetFlagOnFirstMessage(false, "\\DELETED");
             if (oSimulator.Search("DELETED") != "")
            throw new Exception("ERROR - Search or flag failed");

             oSimulator.SetFlagOnFirstMessage(true, "\\DRAFT");
             if (oSimulator.Search("DRAFT") != "1")
            throw new Exception("ERROR - Search or flag failed");

             oSimulator.SetFlagOnFirstMessage(false, "\\DRAFT");
             if (oSimulator.Search("DRAFT") != "")
            throw new Exception("ERROR - Search or flag failed");

             oSimulator.SetFlagOnFirstMessage(true, "\\FLAGGED");
             if (oSimulator.Search("FLAGGED  ") != "1")
            throw new Exception("ERROR - Search or flag failed");

             oSimulator.SetFlagOnFirstMessage(false, "\\FLAGGED");
             if (oSimulator.Search("FLAGGED") != "")
            throw new Exception("ERROR - Search or flag failed");

             oSimulator.SetFlagOnFirstMessage(true, "\\SEEN");
             if (oSimulator.Search("SEEN") != "1")
            throw new Exception("ERROR - Search or flag failed");

             oSimulator.SetFlagOnFirstMessage(false, "\\SEEN");
             if (oSimulator.Search("SEEN") != "")
            throw new Exception("ERROR - Search or flag failed");

             oSimulator.SetFlagOnFirstMessage(true, "\\ANSWERED");
             if (oSimulator.Search("UNANSWERED") != "")
            throw new Exception("ERROR - Search or flag failed");

             oSimulator.SetFlagOnFirstMessage(false, "\\ANSWERED");
             if (oSimulator.Search("UNANSWERED") != "1")
            throw new Exception("ERROR - Search or flag failed");

             oSimulator.SetFlagOnFirstMessage(true, "\\DELETED");
             if (oSimulator.Search("UNDELETED") != "")
            throw new Exception("ERROR - Search or flag failed");

             oSimulator.SetFlagOnFirstMessage(false, "\\DELETED");
             if (oSimulator.Search("UNDELETED") != "1")
            throw new Exception("ERROR - Search or flag failed");

             oSimulator.SetFlagOnFirstMessage(true, "\\DRAFT");
             if (oSimulator.Search("UNDRAFT") != "")
            throw new Exception("ERROR - Search or flag failed");

             oSimulator.SetFlagOnFirstMessage(false, "\\DRAFT");
             if (oSimulator.Search("UNDRAFT") != "1")
            throw new Exception("ERROR - Search or flag failed");

             oSimulator.SetFlagOnFirstMessage(true, "\\FLAGGED");
             if (oSimulator.Search("UNFLAGGED") != "")
            throw new Exception("ERROR - Search or flag failed");

             oSimulator.SetFlagOnFirstMessage(false, "\\FLAGGED");
             if (oSimulator.Search("UNFLAGGED") != "1")
            throw new Exception("ERROR - Search or flag failed");

             // SEARCH using LARGER & SMALLER
             if (oSimulator.Search("SMALLER 10") != "")
            throw new Exception("ERROR - Search or flag failed");

             if (oSimulator.Search("SMALLER 10000") != "1")
            throw new Exception("ERROR - Search or flag failed");

             if (oSimulator.Search("LARGER 10") != "1")
            throw new Exception("ERROR - Search or flag failed");

             if (oSimulator.Search("LARGER 10000") != "")
            throw new Exception("ERROR - Search or flag failed");
        }
Esempio n. 9
0
        public void TestSearchUTF8TEXT()
        {
            hMailServer.Account account = SingletonProvider<Utilities>.Instance.AddAccount(_domain, "*****@*****.**", "test");
             string body = Utilities.GetResource("Messages.MessageContainingGreekSubject.txt");
             SMTPClientSimulator.StaticSendRaw(account.Address, account.Address, body);

             POP3Simulator.AssertMessageCount(account.Address, "test", 1);

             IMAPSimulator oSimulator = new IMAPSimulator();
             Assert.IsTrue(oSimulator.ConnectAndLogon(account.Address, "test"));
             Assert.IsTrue(oSimulator.SelectFolder("INBOX"));

             string result = oSimulator.Search("CHARSET UTF-8 ALL TEXT GRΣΣK");
             Assert.AreEqual("1", result);

             result = oSimulator.Search("CHARSET UTF-8 ALL TEXT 標準語");
             Assert.AreEqual("1", result);

             result = oSimulator.Search("CHARSET UTF-8 ALL TEXT GRΣΣK標準語");
             Assert.AreEqual("1", result);

             result = oSimulator.Search("CHARSET UTF-8 ALL TEXT GRΣΣKWHAT標準語");
             Assert.AreEqual("", result);
        }
Esempio n. 10
0
        public void TestSearchUSASCII()
        {
            hMailServer.Account account = SingletonProvider<Utilities>.Instance.AddAccount(_domain, "*****@*****.**", "test");

             SMTPClientSimulator.StaticSend(account.Address, account.Address, "MySubject", "MyBody");

             POP3Simulator.AssertMessageCount(account.Address, "test", 1);

             IMAPSimulator oSimulator = new IMAPSimulator();
             Assert.IsTrue(oSimulator.ConnectAndLogon(account.Address, "test"));
             Assert.IsTrue(oSimulator.SelectFolder("INBOX"));

             string result = oSimulator.Search("CHARSET US-ASCII ALL SUBJECT MySubject");
             Assert.AreEqual("1", result);

             result = oSimulator.Search("CHARSET US-ASCII ALL SUBJECT MySubjact");
             Assert.AreEqual("", result);
        }
Esempio n. 11
0
        public void TestSearchORWithParenthesisSubjectNested()
        {
            hMailServer.Application application = SingletonProvider<Utilities>.Instance.GetApp();

              ;
              hMailServer.Account oAccount = SingletonProvider<Utilities>.Instance.AddAccount(_domain, "*****@*****.**", "test");

              // Send a message to this account.
              SMTPClientSimulator oSMTP = new SMTPClientSimulator();
              oSMTP.Send("*****@*****.**", "*****@*****.**", "Test1", "This is a test of IMAP Search");
              IMAPSimulator.AssertMessageCount("*****@*****.**", "test", "INBOX", 1);
              oSMTP.Send("*****@*****.**", "*****@*****.**", "Test2", "This is a test of IMAP Search");
              IMAPSimulator.AssertMessageCount("*****@*****.**", "test", "INBOX", 2);

              IMAPSimulator oSimulator = new IMAPSimulator();

              string sWelcomeMessage = oSimulator.Connect();
              oSimulator.Logon("*****@*****.**", "test");
              Assert.IsTrue(oSimulator.SelectFolder("INBOX"));

              if (oSimulator.Search("ALL (OR (HEADER SUBJECT \"Test1\") (HEADER SUBJECT \"Test2\"))") != "1 2")
              {
              throw new Exception("ERROR - Search or flag failed");
              }
        }