Пример #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");
             }
        }
Пример #2
0
        public void TestSearchORWithLiterals3()
        {
            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"));

            string result = oSimulator.Send("A01 SEARCH ALL OR (HEADER SUBJECT {5}");

            result = oSimulator.Send("Test5) (HEADER SUBJECT {5}");
            result = oSimulator.Send("Test2)");
            Assert.IsTrue(result.StartsWith("* SEARCH 2"));
        }
Пример #3
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");
            }
        }
Пример #4
0
        public void TestNestedOrSearch()
        {
            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(oAccount.Address, "test", "Inbox", 1);

            IMAPSimulator oSimulator      = new IMAPSimulator();
            string        sWelcomeMessage = oSimulator.Connect();

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

            string result = oSimulator.SendSingleCommand("A4 SEARCH ALL OR OR SINCE 28-May-2008 SINCE 28-May-2008 SINCE 28-May-2008");

            Assert.IsTrue(result.StartsWith("* SEARCH 1"), result);

            result = oSimulator.SendSingleCommand("A4 SEARCH ALL OR SMALLER 1 LARGER 10000");
            Assert.IsTrue(result.StartsWith("* SEARCH\r\n"), result);

            result = oSimulator.SendSingleCommand("A4 SEARCH ALL OR OR SMALLER 1 LARGER 10000 SMALLER 10000");
            Assert.IsTrue(result.StartsWith("* SEARCH 1\r\n"), result);
        }
Пример #5
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");
            }
        }
Пример #6
0
        public void TestSortReverseSize()
        {
            hMailServer.Domain  oDomain  = _application.Domains[0];
            hMailServer.Account oAccount = SingletonProvider <Utilities> .Instance.AddAccount(_domain, "*****@*****.**", "test");

            StringBuilder longBodyString = new StringBuilder();

            longBodyString.Append('A', 10000);

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

            oSMTP.Send("*****@*****.**", "*****@*****.**", "Test1", longBodyString.ToString());
            IMAPSimulator.AssertMessageCount("*****@*****.**", "test", "INBOX", 1);

            oSMTP.Send("*****@*****.**", "*****@*****.**", "Test2", "Test body");
            IMAPSimulator.AssertMessageCount("*****@*****.**", "test", "INBOX", 2);

            IMAPSimulator oSimulator = new IMAPSimulator();

            string sWelcomeMessage = oSimulator.Connect();

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

            Assert.AreEqual("2 1", oSimulator.Sort("(SIZE) UTF-8 ALL"));
            Assert.AreEqual("1 2", oSimulator.Sort("(REVERSE SIZE) UTF-8 ALL"));
        }
Пример #7
0
        public void TestFetchHeaderFieldsNot()
        {
            hMailServer.Account account = SingletonProvider <Utilities> .Instance.AddAccount(_domain, "*****@*****.**", "test");

            string message = "From: Someone <*****@*****.**>" + Environment.NewLine +
                             "To: Someoen <*****@*****.**>" + Environment.NewLine +
                             "Date: Wed, 22 Apr 2009 11:05:09 \"GMT\"" + Environment.NewLine +
                             "Subject: Something" + Environment.NewLine +
                             Environment.NewLine +
                             "Hello" + Environment.NewLine;

            SMTPClientSimulator smtpSimulator = new SMTPClientSimulator();

            Assert.IsTrue(smtpSimulator.SendRaw(account.Address, account.Address, message));

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

            IMAPSimulator oSimulator      = new IMAPSimulator();
            string        sWelcomeMessage = oSimulator.Connect();

            oSimulator.Logon(account.Address, "test");
            oSimulator.SelectFolder("INBOX");
            string result = oSimulator.Fetch("1 BODY.PEEK[HEADER.FIELDS.NOT (Subject From)]");

            oSimulator.Disconnect();


            Assert.IsTrue(result.Contains("Received:"), result);
            Assert.IsFalse(result.Contains("Subject:"), result);
            Assert.IsFalse(result.Contains("From:"), result);
            // The feedback should end with an empty header line.
            Assert.IsTrue(result.Contains("\r\n\r\n)"), result);
        }
Пример #8
0
        public void TestSubjectSearchMultipleMatches()
        {
            hMailServer.Domain  oDomain  = _application.Domains[0];
            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("*****@*****.**", "*****@*****.**", "TestA", "This is a test of IMAP Search");
            IMAPSimulator.AssertMessageCount("*****@*****.**", "test", "INBOX", 2);
            oSMTP.Send("*****@*****.**", "*****@*****.**", "Test1", "This is a test of IMAP Search");
            IMAPSimulator.AssertMessageCount("*****@*****.**", "test", "INBOX", 3);

            IMAPSimulator oSimulator = new IMAPSimulator();

            string sWelcomeMessage = oSimulator.Connect();

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

            Assert.AreEqual("1 3", oSimulator.Sort("(SUBJECT) UTF-8 ALL HEADER SUBJECT \"Test1\""));
            Assert.AreEqual("2", oSimulator.Sort("(SUBJECT) UTF-8 ALL HEADER SUBJECT \"TestA\""));
            Assert.AreEqual("3 1", oSimulator.Sort("(REVERSE SUBJECT) UTF-8 ALL HEADER SUBJECT \"Test1\""));
            Assert.AreEqual("2", oSimulator.Sort("(REVERSE SUBJECT) UTF-8 ALL HEADER SUBJECT \"TestA\""));
            Assert.AreEqual("3 1", oSimulator.Sort("(REVERSE SUBJECT) UTF-8 ALL (HEADER SUBJECT) \"Test1\""));
            Assert.AreEqual("2", oSimulator.Sort("(REVERSE SUBJECT) UTF-8 ALL (HEADER SUBJECT) \"TestA\""));
        }
Пример #9
0
        public void TestSortSubjectSearch()
        {
            hMailServer.Domain  oDomain  = _application.Domains[0];
            hMailServer.Account oAccount = SingletonProvider <Utilities> .Instance.AddAccount(_domain, "*****@*****.**", "test");

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

            oSMTP.Send("*****@*****.**", "*****@*****.**", "aa", "This is a test of IMAP Search");
            IMAPSimulator.AssertMessageCount("*****@*****.**", "test", "INBOX", 1);
            oSMTP.Send("*****@*****.**", "*****@*****.**", "bb", "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"));

            Assert.AreEqual("1 2", oSimulator.Sort("(DATE) UTF-8 ALL UNANSWERED OR HEADER SUBJECT aa HEADER SUBJECT bb"));
            Assert.AreEqual("1 2", oSimulator.Sort("(DATE) UTF-8 ALL UNANSWERED OR (HEADER SUBJECT aa) (HEADER SUBJECT bb)"));
            Assert.AreEqual("1 2", oSimulator.Sort("(DATE) UTF-8 ALL UNANSWERED (OR HEADER SUBJECT aa HEADER SUBJECT bb)"));

            Assert.AreEqual("1", oSimulator.Sort("(DATE) UTF-8 ALL UNANSWERED OR HEADER SUBJECT aa HEADER SUBJECT cc"));
            Assert.AreEqual("1", oSimulator.Sort("(DATE) UTF-8 ALL UNANSWERED OR (HEADER SUBJECT aa) (HEADER SUBJECT cc)"));
            Assert.AreEqual("1", oSimulator.Sort("(DATE) UTF-8 ALL UNANSWERED (OR HEADER SUBJECT aa HEADER SUBJECT cc)"));

            Assert.AreEqual("2", oSimulator.Sort("(DATE) UTF-8 ALL UNANSWERED OR HEADER SUBJECT bb HEADER SUBJECT cc"));
            Assert.AreEqual("2", oSimulator.Sort("(DATE) UTF-8 ALL UNANSWERED OR (HEADER SUBJECT bb) (HEADER SUBJECT cc)"));
            Assert.AreEqual("2", oSimulator.Sort("(DATE) UTF-8 ALL UNANSWERED (OR HEADER SUBJECT bb HEADER SUBJECT cc)"));
        }
Пример #10
0
        public void TestFetchEnvelopeWithDateContainingQuote()
        {
            hMailServer.Account account = SingletonProvider <Utilities> .Instance.AddAccount(_domain, "*****@*****.**", "test");

            string message = "From: Someone <*****@*****.**>" + Environment.NewLine +
                             "To: Someoen <*****@*****.**>" + Environment.NewLine +
                             "Date: Wed, 22 Apr 2009 11:05:09 \"GMT\"" + Environment.NewLine +
                             "Subject: Something" + Environment.NewLine +
                             Environment.NewLine +
                             "Hello" + Environment.NewLine;

            SMTPClientSimulator smtpSimulator = new SMTPClientSimulator();

            smtpSimulator.SendRaw(account.Address, account.Address, message);

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

            IMAPSimulator oSimulator      = new IMAPSimulator();
            string        sWelcomeMessage = oSimulator.Connect();

            oSimulator.Logon(account.Address, "test");
            oSimulator.SelectFolder("INBOX");
            string result = oSimulator.Fetch("1 ENVELOPE");

            oSimulator.Disconnect();

            Assert.IsTrue(result.Contains("Wed, 22 Apr 2009 11:05:09 GMT"));
        }
Пример #11
0
        public void TestListSpecial()
        {
            hMailServer.Account oAccount = SingletonProvider <Utilities> .Instance.AddAccount(_domain, "*****@*****.**", "test");

            IMAPSimulator oSimulator      = new IMAPSimulator();
            string        sWelcomeMessage = oSimulator.Connect();

            oSimulator.Logon(oAccount.Address, "test");
            string response = oSimulator.List("");

            Assert.IsTrue(response.StartsWith("* LIST (\\Noselect) \".\" \"\""));
            oSimulator.Disconnect();

            _settings.IMAPHierarchyDelimiter = "/";

            oSimulator      = new IMAPSimulator();
            sWelcomeMessage = oSimulator.Connect();
            oSimulator.Logon(oAccount.Address, "test");
            response = oSimulator.List("");
            Assert.IsTrue(response.StartsWith("* LIST (\\Noselect) \"/\" \"\""));
            oSimulator.Disconnect();

            _settings.IMAPHierarchyDelimiter = "\\";

            oSimulator      = new IMAPSimulator();
            sWelcomeMessage = oSimulator.Connect();
            oSimulator.Logon(oAccount.Address, "test");
            response = oSimulator.List("", false);
            string expectedResponse = "* LIST (\\Noselect) \"\\\\\" \"\"";

            Assert.IsTrue(response.StartsWith(expectedResponse));
            oSimulator.Disconnect();
        }
Пример #12
0
        public void TestNestedOrSearch()
        {
            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(oAccount.Address, "test", "Inbox", 1);

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

              string result = oSimulator.SendSingleCommand("A4 SEARCH ALL OR OR SINCE 28-May-2008 SINCE 28-May-2008 SINCE 28-May-2008");
              Assert.IsTrue(result.StartsWith("* SEARCH 1"), result);

              result = oSimulator.SendSingleCommand("A4 SEARCH ALL OR SMALLER 1 LARGER 10000");
              Assert.IsTrue(result.StartsWith("* SEARCH\r\n"), result);

              result = oSimulator.SendSingleCommand("A4 SEARCH ALL OR OR SMALLER 1 LARGER 10000 SMALLER 10000");
              Assert.IsTrue(result.StartsWith("* SEARCH 1\r\n"), result);
        }
Пример #13
0
        public void TestSortReverseArrival()
        {
            hMailServer.Domain  oDomain  = _application.Domains[0];
            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);

            // The two messages needs to be sent a second apart, so we actually need to pause a bit here.

            System.Threading.Thread.Sleep(1000);
            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"));

            Assert.AreEqual("1 2", oSimulator.Sort("(ARRIVAL) UTF-8 ALL"));
            Assert.AreEqual("2 1", oSimulator.Sort("(REVERSE ARRIVAL) UTF-8 ALL"));
        }
Пример #14
0
        public void TestHierarchyDelimiterDelete()
        {
            hMailServer.Application application = SingletonProvider <Utilities> .Instance.GetApp();

            hMailServer.Settings settings = _settings;
            settings.IMAPHierarchyDelimiter = "\\";

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

            string folderName = "Test\\Test";

            IMAPSimulator oSimulator      = new IMAPSimulator();
            string        sWelcomeMessage = oSimulator.Connect();

            oSimulator.Logon(account.Address, "test");
            Assert.IsTrue(oSimulator.CreateFolder(folderName));
            string listResponse = oSimulator.List();

            Assert.IsTrue(listResponse.Contains("\"Test\\Test\""));
            Assert.IsTrue(listResponse.Contains("\"Test\""));
            Assert.IsTrue(oSimulator.DeleteFolder("Test\\Test"));
            listResponse = oSimulator.List();
            Assert.IsFalse(listResponse.Contains("Test\\Test"));
            Assert.IsTrue(listResponse.Contains("Test"));
            oSimulator.Disconnect();
        }
Пример #15
0
        public void TestCreateFolderWithHash()
        {
            hMailServer.Account oAccount = SingletonProvider<Utilities>.Instance.AddAccount(_domain, "*****@*****.**", "test");

             IMAPSimulator oSimulator = new IMAPSimulator();

             string sWelcomeMessage = oSimulator.Connect();
             oSimulator.Logon(oAccount.Address, "test");
             Assert.IsFalse(oSimulator.CreateFolder("#Test"));
             Assert.IsTrue(oSimulator.CreateFolder("Test.#Testar"));
             oSimulator.Disconnect();
        }
Пример #16
0
        public void TestCreateFolderWithHash()
        {
            hMailServer.Account oAccount = SingletonProvider <Utilities> .Instance.AddAccount(_domain, "*****@*****.**", "test");

            IMAPSimulator oSimulator = new IMAPSimulator();

            string sWelcomeMessage = oSimulator.Connect();

            oSimulator.Logon(oAccount.Address, "test");
            Assert.IsFalse(oSimulator.CreateFolder("#Test"));
            Assert.IsTrue(oSimulator.CreateFolder("Test.#Testar"));
            oSimulator.Disconnect();
        }
Пример #17
0
        public void TestFolderLSUBUnsubscribedFolder()
        {
            hMailServer.Account oAccount = SingletonProvider <Utilities> .Instance.AddAccount(_domain, "*****@*****.**", "test");

            string folderName = "ABC.def.GHI";

            IMAPSimulator oSimulator      = new IMAPSimulator();
            string        sWelcomeMessage = oSimulator.Connect();

            oSimulator.Logon(oAccount.Address, "test");
            Assert.IsTrue(oSimulator.CreateFolder(folderName));
            Assert.IsFalse(oSimulator.LSUB().Contains("\r\n\r\n"));
            oSimulator.Disconnect();
        }
Пример #18
0
        public void TestCreateFolderWithSlash()
        {
            hMailServer.Account oAccount = SingletonProvider<Utilities>.Instance.AddAccount(_domain, "*****@*****.**", "test");

              string folderName = "ABC\\123";

              IMAPSimulator oSimulator = new IMAPSimulator();
              string sWelcomeMessage = oSimulator.Connect();
              oSimulator.Logon(oAccount.Address, "test");
              Assert.IsTrue(oSimulator.CreateFolder(folderName));
              Assert.IsTrue(oSimulator.List().Contains(folderName));
              Assert.IsTrue(oSimulator.SelectFolder(folderName));
              oSimulator.Disconnect();
        }
Пример #19
0
        public void TestExamine()
        {
            hMailServer.Account oAccount = SingletonProvider <Utilities> .Instance.AddAccount(_domain, "*****@*****.**", "test");

            IMAPSimulator oSimulator = new IMAPSimulator();

            string sWelcomeMessage = oSimulator.Connect();

            oSimulator.Logon(oAccount.Address, "test");
            Assert.IsTrue(oSimulator.CreateFolder("TestFolder"));
            string result = oSimulator.ExamineFolder("TestFolder");

            Assert.IsTrue(result.Contains("[PERMANENTFLAGS ()]"), result);
            Assert.IsTrue(result.Contains("[READ-ONLY]"), result);
        }
Пример #20
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();
        }
Пример #21
0
        public void TestCreateFolderWithSlash()
        {
            hMailServer.Account oAccount = SingletonProvider <Utilities> .Instance.AddAccount(_domain, "*****@*****.**", "test");

            string folderName = "ABC\\123";

            IMAPSimulator oSimulator      = new IMAPSimulator();
            string        sWelcomeMessage = oSimulator.Connect();

            oSimulator.Logon(oAccount.Address, "test");
            Assert.IsTrue(oSimulator.CreateFolder(folderName));
            Assert.IsTrue(oSimulator.List().Contains(folderName));
            Assert.IsTrue(oSimulator.SelectFolder(folderName));
            oSimulator.Disconnect();
        }
Пример #22
0
        public void TestSearchUID()
        {
            hMailServer.Application application = SingletonProvider <Utilities> .Instance.GetApp();

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

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

            for (int i = 0; i < 3; i++)
            {
                oSMTP.Send("*****@*****.**", "*****@*****.**", "Test1", "This is a test of IMAP Search");
            }

            IMAPSimulator.AssertMessageCount("*****@*****.**", "test", "INBOX", 3);

            // There should be 3 UID's, 1,2,3 or similar. No skips in the middle fo them.
            IMAPSimulator oSimulator      = new IMAPSimulator();
            string        sWelcomeMessage = oSimulator.Connect();

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

            string result = oSimulator.SendSingleCommand("* UID SEARCH UID 1:*");

            // Potentially, the response is multiline. (UID RESPONSE and an OK line). We only want the first line...
            result = result.Substring(0, result.IndexOf("\r\n"));

            string [] tokens = Microsoft.VisualBasic.Strings.Split(result, " ", -1, Microsoft.VisualBasic.CompareMethod.Text);

            List <int> uids = new List <int>();

            foreach (string token in tokens)
            {
                int temp;
                if (Int32.TryParse(token, out temp))
                {
                    uids.Add(temp);
                }
            }

            Assert.AreEqual(3, uids.Count, result);

            Assert.AreEqual(1, uids[0]);
            Assert.AreEqual(2, uids[1]);
            Assert.AreEqual(3, uids[2]);
        }
Пример #23
0
        public void TestFolderCaseInLIST()
        {
            hMailServer.Account oAccount = SingletonProvider <Utilities> .Instance.AddAccount(_domain, "*****@*****.**", "test");

            string folderName = "ABC.def.GHI";

            IMAPSimulator oSimulator      = new IMAPSimulator();
            string        sWelcomeMessage = oSimulator.Connect();

            oSimulator.Logon(oAccount.Address, "test");
            Assert.IsTrue(oSimulator.CreateFolder(folderName));
            Assert.IsFalse(oSimulator.List("ABC.DEF.*").Contains("ABC.def.GHI"));
            Assert.IsTrue(oSimulator.List("ABC.DEF.*").Contains("ABC.DEF.GHI"));
            Assert.IsFalse(oSimulator.List("ABC.def.*").Contains("ABC.DEF"));
            Assert.IsTrue(oSimulator.List("ABC.def.*").Contains("ABC.def.GHI"));
            Assert.IsTrue(oSimulator.SelectFolder(folderName));
            oSimulator.Disconnect();
        }
        public void TestHierarchyDelimiterListResponse()
        {
            hMailServer.Application application = SingletonProvider<Utilities>.Instance.GetApp();
            hMailServer.Settings settings = _settings;
            settings.IMAPHierarchyDelimiter = "\\";

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

            string folderName = "Test\\Test";

            IMAPSimulator oSimulator = new IMAPSimulator();
            string sWelcomeMessage = oSimulator.Connect();
            oSimulator.Logon(account.Address, "test");
            Assert.IsTrue(oSimulator.CreateFolder(folderName));
            string listResponse = oSimulator.List();
            Assert.IsTrue(listResponse.Contains("\"Test\\Test\""));
            Assert.IsTrue(listResponse.Contains("\"Test\""));
            oSimulator.Disconnect();
        }
Пример #25
0
        public void TestSearchSpecficUID()
        {
            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();

            for (int i = 0; i < 5; i++)
            {
                oSMTP.Send("*****@*****.**", "*****@*****.**", "Test1", "This is a test of IMAP Search");
            }

            IMAPSimulator.AssertMessageCount("*****@*****.**", "test", "INBOX", 5);

            hMailServer.Messages messages = oAccount.IMAPFolders.get_ItemByName("Inbox").Messages;

            int second = messages[1].UID;
            int third  = messages[2].UID;
            int fourth = messages[3].UID;


            IMAPSimulator oSimulator      = new IMAPSimulator();
            string        sWelcomeMessage = oSimulator.Connect();

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

            string result = oSimulator.SendSingleCommand(string.Format("a01 SORT (REVERSE DATE) UTF-8 ALL UID {0},{1}", second, third));

            Assert.IsTrue(result.StartsWith("* SORT 3 2"));

            result = oSimulator.SendSingleCommand(string.Format("a01 SORT (DATE) UTF-8 ALL UID {0},{1}", third, second));
            Assert.IsTrue(result.StartsWith("* SORT 2 3"));

            result = oSimulator.SendSingleCommand(string.Format("a01 SORT (DATE) UTF-8 ALL UID {0}:{1}", second, fourth));
            Assert.IsTrue(result.StartsWith("* SORT 2 3 4"));

            result = oSimulator.SendSingleCommand(string.Format("a01 SORT (DATE) UTF-8 ALL UID {0}:*", second));
            Assert.IsTrue(result.StartsWith("* SORT 2 3 4 5"));
        }
Пример #26
0
        public void TestSortDeletedOrAnswered()
        {
            hMailServer.Domain  oDomain  = _application.Domains[0];
            hMailServer.Account oAccount = SingletonProvider <Utilities> .Instance.AddAccount(_domain, "*****@*****.**", "test");

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

            oSMTP.Send("*****@*****.**", "*****@*****.**", "aa", "This is a test of IMAP Search");
            IMAPSimulator.AssertMessageCount("*****@*****.**", "test", "INBOX", 1);
            oSMTP.Send("*****@*****.**", "*****@*****.**", "bb", "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"));

            Assert.AreEqual("", oSimulator.Sort("(DATE) UTF-8 ALL OR ANSWERED DELETED"));
        }
Пример #27
0
        public void TestSearchRange()
        {
            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();

            for (int i = 0; i < 5; i++)
            {
                oSMTP.Send("*****@*****.**", "*****@*****.**", "Test1", "This is a test of IMAP Search");
            }

            IMAPSimulator.AssertMessageCount("*****@*****.**", "test", "INBOX", 5);

            IMAPSimulator oSimulator      = new IMAPSimulator();
            string        sWelcomeMessage = oSimulator.Connect();

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

            string result = oSimulator.SendSingleCommand("a01 search 2:4");

            Assert.IsTrue(result.StartsWith("* SEARCH 2 3 4"));

            result = oSimulator.SendSingleCommand("a01 search 3,2");
            Assert.IsTrue(result.StartsWith("* SEARCH 2 3"));

            result = oSimulator.SendSingleCommand("a01 search 3:*");
            Assert.IsTrue(result.StartsWith("* SEARCH 3 4 5"));

            result = oSimulator.SendSingleCommand("a01 search 3,1,3");
            Assert.IsTrue(result.StartsWith("* SEARCH 1 3"));

            result = oSimulator.SendSingleCommand("a01 search 1:*");
            Assert.IsTrue(result.StartsWith("* SEARCH 1 2 3 4 5"));
        }
Пример #28
0
        public void TestAppendFolderNameInOctet()
        {
            hMailServer.Account oAccount = SingletonProvider<Utilities>.Instance.AddAccount(_domain, "*****@*****.**", "test");

             IMAPSimulator oSimulator = new IMAPSimulator();

             string sWelcomeMessage = oSimulator.Connect();
             oSimulator.Logon("*****@*****.**", "test");
             oSimulator.SelectFolder("INBOX");
             oSimulator.CreateFolder("MONK");
             oSimulator.SendRaw("A01 APPEND {4}\r\n");
             string result = oSimulator.Receive();
             Assert.IsTrue(result.StartsWith("+ Ready for additional command text."));

             oSimulator.SendRaw("MONK (\\Seen) \"20-Jan-2009 12:59:50 +0100\" {5}\r\n");
             result = oSimulator.Receive();
             Assert.IsTrue(result.StartsWith("+ Ready for literal data"));

             oSimulator.SendRaw("WOOOT\r\n");
             result = oSimulator.Receive();

             Assert.AreEqual("A01 OK APPEND completed\r\n", result);
        }
Пример #29
0
        public void TestExamineResponse()
        {
            hMailServer.Account account = SingletonProvider<Utilities>.Instance.AddAccount(_domain, "*****@*****.**", "test");

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

             IMAPSimulator oSimulator = new IMAPSimulator();
             string sWelcomeMessage = oSimulator.Connect();
             oSimulator.Logon("*****@*****.**", "test");
             string result = oSimulator.ExamineFolder("Inbox");
             oSimulator.Disconnect();

             Assert.IsTrue(result.Contains("* FLAGS"), result);
             Assert.IsTrue(result.Contains("* 1 EXISTS"), result);
             Assert.IsTrue(result.Contains("* 1 RECENT"), result);
             Assert.IsTrue(result.Contains("* OK [UNSEEN 1]"), result);
             Assert.IsTrue(result.Contains("* OK [PERMANENTFLAGS"), result);
             Assert.IsTrue(result.Contains("* OK [UIDNEXT 2]"), result);
             Assert.IsTrue(result.Contains("* OK [UIDVALIDITY"), result);
             Assert.IsTrue(result.Contains("OK [READ-ONLY]"), result);
        }
Пример #30
0
        public void TestLsubInclusion()
        {
            hMailServer.Account oAccount = SingletonProvider<Utilities>.Instance.AddAccount(_domain, "*****@*****.**", "test");

              string folderName = "Folder1";

              IMAPSimulator oSimulator = new IMAPSimulator();
              string sWelcomeMessage = oSimulator.Connect();
              oSimulator.Logon(oAccount.Address, "test");
              Assert.IsTrue(oSimulator.CreateFolder(folderName));
              Assert.IsFalse(oSimulator.LSUB().Contains(folderName));
              Assert.IsTrue(oSimulator.Subscribe(folderName));
              Assert.IsTrue(oSimulator.LSUB().Contains(folderName));

              oSimulator.Disconnect();
        }
Пример #31
0
        public void TestAppendFolderNameInOctetNoFlagList()
        {
            hMailServer.Account oAccount = SingletonProvider<Utilities>.Instance.AddAccount(_domain, "*****@*****.**", "test");

             IMAPSimulator oSimulator = new IMAPSimulator();

             string sWelcomeMessage = oSimulator.Connect();
             oSimulator.Logon("*****@*****.**", "test");
             oSimulator.SelectFolder("INBOX");
             oSimulator.CreateFolder("MONK");
             oSimulator.SendRaw("A01 APPEND {4}\r\n");
             string result = oSimulator.Receive();
             Assert.IsTrue(result.StartsWith("+ Ready for additional command text."));

             oSimulator.SendRaw("MONK  \"12-Jan-2009 12:12:12 +0100\" {5}\r\n");
             result = oSimulator.Receive();
             Assert.IsTrue(result.StartsWith("+ Ready for literal data"));

             oSimulator.SendRaw("WOOOT\r\n");
             result = oSimulator.Receive();

             Assert.AreEqual("A01 OK APPEND completed\r\n", result);

             DateTime date = Convert.ToDateTime(oAccount.IMAPFolders.get_ItemByName("MONK").Messages[0].InternalDate);

             Assert.AreEqual(2009, date.Year);
             Assert.AreEqual(12, date.Day);
             Assert.AreEqual(1, date.Month);
        }
Пример #32
0
        public void TestSearchUID()
        {
            hMailServer.Application application = SingletonProvider<Utilities>.Instance.GetApp();

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

             // Send a message to this account.
             SMTPClientSimulator oSMTP = new SMTPClientSimulator();
             for (int i = 0; i < 3; i++)
            oSMTP.Send("*****@*****.**", "*****@*****.**", "Test1", "This is a test of IMAP Search");

             IMAPSimulator.AssertMessageCount("*****@*****.**", "test", "INBOX", 3);

             // There should be 3 UID's, 1,2,3 or similar. No skips in the middle fo them.
             IMAPSimulator oSimulator = new IMAPSimulator();
             string sWelcomeMessage = oSimulator.Connect();
             oSimulator.Logon("*****@*****.**", "test");
             Assert.IsTrue(oSimulator.SelectFolder("INBOX"));

             string result = oSimulator.SendSingleCommand("* UID SEARCH UID 1:*");

             // Potentially, the response is multiline. (UID RESPONSE and an OK line). We only want the first line...
             result = result.Substring(0, result.IndexOf("\r\n"));

             string [] tokens = Microsoft.VisualBasic.Strings.Split(result, " ", -1, Microsoft.VisualBasic.CompareMethod.Text);

             List<int> uids = new List<int>();
             foreach (string token in tokens)
             {
            int temp;
            if (Int32.TryParse(token, out temp))
            {
               uids.Add(temp);
            }
             }

             Assert.AreEqual(3, uids.Count, result);

             Assert.AreEqual(1, uids[0]);
             Assert.AreEqual(2, uids[1]);
             Assert.AreEqual(3, uids[2]);
        }
Пример #33
0
        public void TestListSpecial()
        {
            hMailServer.Account oAccount = SingletonProvider<Utilities>.Instance.AddAccount(_domain, "*****@*****.**", "test");

              IMAPSimulator oSimulator = new IMAPSimulator();
              string sWelcomeMessage = oSimulator.Connect();
              oSimulator.Logon(oAccount.Address, "test");
              string response = oSimulator.List("");
              Assert.IsTrue(response.StartsWith("* LIST (\\Noselect) \".\" \"\""));
              oSimulator.Disconnect();

              _settings.IMAPHierarchyDelimiter = "/";

              oSimulator = new IMAPSimulator();
              sWelcomeMessage = oSimulator.Connect();
              oSimulator.Logon(oAccount.Address, "test");
              response = oSimulator.List("");
              Assert.IsTrue(response.StartsWith("* LIST (\\Noselect) \"/\" \"\""));
              oSimulator.Disconnect();

              _settings.IMAPHierarchyDelimiter = "\\";

              oSimulator = new IMAPSimulator();
              sWelcomeMessage = oSimulator.Connect();
              oSimulator.Logon(oAccount.Address, "test");
              response = oSimulator.List("", false);
              string expectedResponse = "* LIST (\\Noselect) \"\\\\\" \"\"";
              Assert.IsTrue(response.StartsWith(expectedResponse));
              oSimulator.Disconnect();
        }
Пример #34
0
        public void TestExamineNonexistantFolder()
        {
            hMailServer.Account oAccount = SingletonProvider<Utilities>.Instance.AddAccount(_domain, "*****@*****.**", "test");

              IMAPSimulator oSimulator = new IMAPSimulator();

              string sWelcomeMessage = oSimulator.Connect();
              oSimulator.Logon("*****@*****.**", "test");
              string result = oSimulator.ExamineFolder("NonexistantFolder");

              Assert.IsTrue(result.Contains("BAD Folder could not be found."));
        }
Пример #35
0
        public void TestConnectionObjectRelease()
        {
            Utilities.DeleteCurrentDefaultLog();

              _settings.IMAPIdleEnabled = true;

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

              IMAPSimulator simulator = new IMAPSimulator();

              string data;

              string sWelcomeMessage = simulator.Connect();
              simulator.Logon(account.Address, "test");
              Assert.IsTrue(simulator.SelectFolder("INBOX"));
              Assert.IsTrue(simulator.StartIdle());
              Assert.IsTrue(simulator.EndIdle(true, out data));
              Assert.IsTrue(simulator.Logout());

              string logData = Utilities.ReadCurrentDefaultLog();

              Assert.IsTrue(Utilities.DefaultLogContains("Ending session"));
        }
Пример #36
0
        public void TestLiterals()
        {
            hMailServer.Account oAccount = SingletonProvider<Utilities>.Instance.AddAccount(_domain, "*****@*****.**", "test");

             IMAPSimulator oSimulator = new IMAPSimulator();

             string sWelcomeMessage = oSimulator.Connect();
             oSimulator.Logon("*****@*****.**", "test");
             string result = oSimulator.Send("A01 CREATE {4}");
             result = oSimulator.Send("HEJS");

             oSimulator.Disconnect();
        }
Пример #37
0
        public void TestSortSubjectSearch()
        {
            hMailServer.Domain oDomain = _application.Domains[0];
             hMailServer.Account oAccount = SingletonProvider<Utilities>.Instance.AddAccount(_domain, "*****@*****.**", "test");

             // Send a message to this account.
             SMTPClientSimulator oSMTP = new SMTPClientSimulator();
             oSMTP.Send("*****@*****.**", "*****@*****.**", "aa", "This is a test of IMAP Search");
             IMAPSimulator.AssertMessageCount("*****@*****.**", "test", "INBOX", 1);
             oSMTP.Send("*****@*****.**", "*****@*****.**", "bb", "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"));

             Assert.AreEqual("1 2", oSimulator.Sort("(DATE) UTF-8 ALL UNANSWERED OR HEADER SUBJECT aa HEADER SUBJECT bb"));
             Assert.AreEqual("1 2", oSimulator.Sort("(DATE) UTF-8 ALL UNANSWERED OR (HEADER SUBJECT aa) (HEADER SUBJECT bb)"));
             Assert.AreEqual("1 2", oSimulator.Sort("(DATE) UTF-8 ALL UNANSWERED (OR HEADER SUBJECT aa HEADER SUBJECT bb)"));

             Assert.AreEqual("1", oSimulator.Sort("(DATE) UTF-8 ALL UNANSWERED OR HEADER SUBJECT aa HEADER SUBJECT cc"));
             Assert.AreEqual("1", oSimulator.Sort("(DATE) UTF-8 ALL UNANSWERED OR (HEADER SUBJECT aa) (HEADER SUBJECT cc)"));
             Assert.AreEqual("1", oSimulator.Sort("(DATE) UTF-8 ALL UNANSWERED (OR HEADER SUBJECT aa HEADER SUBJECT cc)"));

             Assert.AreEqual("2", oSimulator.Sort("(DATE) UTF-8 ALL UNANSWERED OR HEADER SUBJECT bb HEADER SUBJECT cc"));
             Assert.AreEqual("2", oSimulator.Sort("(DATE) UTF-8 ALL UNANSWERED OR (HEADER SUBJECT bb) (HEADER SUBJECT cc)"));
             Assert.AreEqual("2", oSimulator.Sort("(DATE) UTF-8 ALL UNANSWERED (OR HEADER SUBJECT bb HEADER SUBJECT cc)"));
        }
Пример #38
0
        public void TestSortDeletedOrAnswered()
        {
            hMailServer.Domain oDomain = _application.Domains[0];
             hMailServer.Account oAccount = SingletonProvider<Utilities>.Instance.AddAccount(_domain, "*****@*****.**", "test");

             // Send a message to this account.
             SMTPClientSimulator oSMTP = new SMTPClientSimulator();
             oSMTP.Send("*****@*****.**", "*****@*****.**", "aa", "This is a test of IMAP Search");
             IMAPSimulator.AssertMessageCount("*****@*****.**", "test", "INBOX", 1);
             oSMTP.Send("*****@*****.**", "*****@*****.**", "bb", "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"));

             Assert.AreEqual("", oSimulator.Sort("(DATE) UTF-8 ALL OR ANSWERED DELETED"));
        }
Пример #39
0
        public void TestSearchRange()
        {
            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();
              for (int i = 0; i <5 ; i++)
            oSMTP.Send("*****@*****.**", "*****@*****.**", "Test1", "This is a test of IMAP Search");

              IMAPSimulator.AssertMessageCount("*****@*****.**", "test", "INBOX", 5);

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

              string result = oSimulator.SendSingleCommand("a01 search 2:4");
              Assert.IsTrue(result.StartsWith("* SEARCH 2 3 4"));

              result = oSimulator.SendSingleCommand("a01 search 3,2");
              Assert.IsTrue(result.StartsWith("* SEARCH 2 3"));

              result = oSimulator.SendSingleCommand("a01 search 3:*");
              Assert.IsTrue(result.StartsWith("* SEARCH 3 4 5"));

              result = oSimulator.SendSingleCommand("a01 search 3,1,3");
              Assert.IsTrue(result.StartsWith("* SEARCH 1 3"));

              result = oSimulator.SendSingleCommand("a01 search 1:*");
              Assert.IsTrue(result.StartsWith("* SEARCH 1 2 3 4 5"));
        }
Пример #40
0
        public void TestSortReverseArrival()
        {
            hMailServer.Domain oDomain = _application.Domains[0];
             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);

             // The two messages needs to be sent a second apart, so we actually need to pause a bit here.

             System.Threading.Thread.Sleep(1000);
             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"));

             Assert.AreEqual("1 2", oSimulator.Sort("(ARRIVAL) UTF-8 ALL"));
             Assert.AreEqual("2 1", oSimulator.Sort("(REVERSE ARRIVAL) UTF-8 ALL"));
        }
Пример #41
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");
        }
Пример #42
0
        public void TestSearchWithLiterals()
        {
            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"));

              string result = oSimulator.SendSingleCommandWithLiteral("A01 SEARCH HEADER SUBJECT {5}", "Test1");
              Assert.IsTrue(result.StartsWith("* SEARCH 1\r\n"));

              result = oSimulator.SendSingleCommandWithLiteral("A01 SEARCH HEADER SUBJECT {5}", "Test2");
              Assert.IsTrue(result.StartsWith("* SEARCH 2\r\n"));
        }
Пример #43
0
        public void TestSearchSpecficUID()
        {
            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();
             for (int i = 0; i < 5; i++)
            oSMTP.Send("*****@*****.**", "*****@*****.**", "Test1", "This is a test of IMAP Search");

             IMAPSimulator.AssertMessageCount("*****@*****.**", "test", "INBOX", 5);

             hMailServer.Messages messages = oAccount.IMAPFolders.get_ItemByName("Inbox").Messages;

             int second = messages[1].UID;
             int third = messages[2].UID;
             int fourth = messages[3].UID;

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

             string result = oSimulator.SendSingleCommand(string.Format("a01 SORT (REVERSE DATE) UTF-8 ALL UID {0},{1}", second, third));
             Assert.IsTrue(result.StartsWith("* SORT 3 2"));

             result = oSimulator.SendSingleCommand(string.Format("a01 SORT (DATE) UTF-8 ALL UID {0},{1}", third, second));
             Assert.IsTrue(result.StartsWith("* SORT 2 3"));

             result = oSimulator.SendSingleCommand(string.Format("a01 SORT (DATE) UTF-8 ALL UID {0}:{1}", second, fourth));
             Assert.IsTrue(result.StartsWith("* SORT 2 3 4"));

             result = oSimulator.SendSingleCommand(string.Format("a01 SORT (DATE) UTF-8 ALL UID {0}:*", second));
             Assert.IsTrue(result.StartsWith("* SORT 2 3 4 5"));
        }
Пример #44
0
        public void TestSubjectSearchValueWithParanthesis()
        {
            hMailServer.Domain oDomain = _application.Domains[0];
             hMailServer.Account oAccount = SingletonProvider<Utilities>.Instance.AddAccount(_domain, "*****@*****.**", "test");

             // Send a message to this account.
             SMTPClientSimulator oSMTP = new SMTPClientSimulator();
             oSMTP.Send("*****@*****.**", "*****@*****.**", "Te(st1", "This is a test of IMAP Search");
             IMAPSimulator.AssertMessageCount("*****@*****.**", "test", "INBOX", 1);
             oSMTP.Send("*****@*****.**", "*****@*****.**", "Te)st2", "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"));

             Assert.AreEqual("1", oSimulator.Sort("(SUBJECT) UTF-8 ALL HEADER SUBJECT \"Te(st1\""));
             Assert.AreEqual("2", oSimulator.Sort("(SUBJECT) UTF-8 ALL HEADER SUBJECT \"Te)st2\""));
        }
Пример #45
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");
            }
        }
Пример #46
0
        public void TestGetQuota()
        {
            hMailServer.Account oAccount = SingletonProvider<Utilities>.Instance.AddAccount(_domain, "*****@*****.**", "test");

              IMAPSimulator oSimulator = new IMAPSimulator();

              string sWelcomeMessage = oSimulator.Connect();
              oSimulator.Logon("*****@*****.**", "test");
              string result = oSimulator.GetQuota("Inbox");
              Assert.IsTrue(result.Contains("A01 OK"));
              oSimulator.Disconnect();
        }
Пример #47
0
        public void TestDelete()
        {
            hMailServer.Account oAccount = SingletonProvider<Utilities>.Instance.AddAccount(_domain, "*****@*****.**", "test");

             IMAPSimulator oSimulator = new IMAPSimulator();

             string sWelcomeMessage = oSimulator.Connect();
             oSimulator.Logon("*****@*****.**", "test");
             Assert.IsFalse(oSimulator.DeleteFolder("DoesNotExist"));
             Assert.IsTrue(oSimulator.CreateFolder("DoesExist"));
             Assert.IsTrue(oSimulator.SelectFolder("DoesExist"));
             oSimulator.Close();
             Assert.IsTrue(oSimulator.DeleteFolder("DoesExist"));
             Assert.IsFalse(oSimulator.SelectFolder("DoesExist"));
        }
Пример #48
0
        public void TestFolderCaseInLSUB()
        {
            hMailServer.Account oAccount = SingletonProvider<Utilities>.Instance.AddAccount(_domain, "*****@*****.**", "test");

              string folderName = "ABC.def.GHI";

              IMAPSimulator oSimulator = new IMAPSimulator();
              string sWelcomeMessage = oSimulator.Connect();
              oSimulator.Logon(oAccount.Address, "test");
              Assert.IsTrue(oSimulator.CreateFolder(folderName));
              Assert.IsTrue(oSimulator.Subscribe(folderName));
              Assert.IsFalse(oSimulator.LSUB("ABC.DEF.*").Contains("ABC.def.GHI"));
              Assert.IsTrue(oSimulator.LSUB("ABC.DEF.*").Contains("ABC.DEF.GHI"));
              Assert.IsFalse(oSimulator.LSUB("ABC.def.*").Contains("ABC.DEF"));
              Assert.IsTrue(oSimulator.LSUB("ABC.def.*").Contains("ABC.def.GHI"));
              Assert.IsTrue(oSimulator.SelectFolder(folderName));
              oSimulator.Disconnect();
        }
Пример #49
0
        public void TestList()
        {
            hMailServer.Account oAccount = SingletonProvider<Utilities>.Instance.AddAccount(_domain, "*****@*****.**", "test");

             IMAPSimulator oSimulator = new IMAPSimulator();

             string sWelcomeMessage = oSimulator.Connect();
             oSimulator.Logon("*****@*****.**", "test");
             string result = oSimulator.Send("A01 LIST \"\" \"*\"\r\n").Substring(0, 1);
             Assert.AreEqual("*", result);
        }
Пример #50
0
        public void TestSortReverseSize()
        {
            hMailServer.Domain oDomain = _application.Domains[0];
             hMailServer.Account oAccount = SingletonProvider<Utilities>.Instance.AddAccount(_domain, "*****@*****.**", "test");

             StringBuilder longBodyString = new StringBuilder();
             longBodyString.Append('A', 10000);

             // Send a message to this account.
             SMTPClientSimulator oSMTP = new SMTPClientSimulator();
             oSMTP.Send("*****@*****.**", "*****@*****.**", "Test1", longBodyString.ToString());
             IMAPSimulator.AssertMessageCount("*****@*****.**", "test", "INBOX", 1);

             oSMTP.Send("*****@*****.**", "*****@*****.**", "Test2", "Test body");
             IMAPSimulator.AssertMessageCount("*****@*****.**", "test", "INBOX", 2);

             IMAPSimulator oSimulator = new IMAPSimulator();

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

             Assert.AreEqual("2 1", oSimulator.Sort("(SIZE) UTF-8 ALL"));
             Assert.AreEqual("1 2", oSimulator.Sort("(REVERSE SIZE) UTF-8 ALL"));
        }
Пример #51
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");
              }
        }
Пример #52
0
        public void TestIdle()
        {
            _settings.IMAPIdleEnabled = true;

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

             IMAPSimulator oSimulator = new IMAPSimulator();

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

             oSimulator.StartIdle();

             if (oSimulator.GetPendingDataExists())
            throw new Exception("Unexpected data exists");

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

             string data;
             Assert.IsTrue(oSimulator.EndIdle(false, out data));
        }