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