public void TestAddMessage() { Application app = SingletonProvider <TestSetup> .Instance.GetApp(); Utilities utilities = app.Utilities; Account account = SingletonProvider <TestSetup> .Instance.AddAccount(_domain, "*****@*****.**", "test"); // Create a new folder. IMAPFolder folder = account.IMAPFolders.get_ItemByName("INBOX"); folder.Save(); for (int i = 0; i < 3; i++) { hMailServer.Message message = folder.Messages.Add(); message.set_Flag(eMessageFlag.eMFSeen, true); message.Save(); POP3ClientSimulator.AssertMessageCount(account.Address, "test", ((i + 1) * 2) - 1); SMTPClientSimulator.StaticSend("*****@*****.**", account.Address, "Test", "Test"); POP3ClientSimulator.AssertMessageCount(account.Address, "test", (i + 1) * 2); } POP3ClientSimulator.AssertMessageCount(account.Address, "test", 6); var sim = new IMAPClientSimulator(); sim.ConnectAndLogon(account.Address, "test"); sim.SelectFolder("Inbox"); string response = sim.Fetch("1:6 UID"); string[] lines = Strings.Split(response, Environment.NewLine, -1, CompareMethod.Text); var uids = new List <string>(); foreach (string line in lines) { int paraPos = line.IndexOf("("); int paraEndPos = line.IndexOf(")"); if (paraPos < 0 || paraEndPos < 0) { continue; } string paraContent = line.Substring(paraPos + 1, paraEndPos - paraPos - 1); if (!uids.Contains(paraContent)) { uids.Add(paraContent); } } CustomAssert.AreEqual(6, uids.Count); // Make sure the UIDS are sorted properly by creating a copy, sort the copy // and then compare to original. var copy = new List <string>(); copy.InsertRange(0, uids); copy.Sort(); CustomAssert.AreEqual(copy, uids); }