当前位置: 首页>>代码示例>>C#>>正文


C# ImapClientSimulator.ConnectAndLogon方法代码示例

本文整理汇总了C#中RegressionTests.Shared.ImapClientSimulator.ConnectAndLogon方法的典型用法代码示例。如果您正苦于以下问题:C# ImapClientSimulator.ConnectAndLogon方法的具体用法?C# ImapClientSimulator.ConnectAndLogon怎么用?C# ImapClientSimulator.ConnectAndLogon使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在RegressionTests.Shared.ImapClientSimulator的用法示例。


在下文中一共展示了ImapClientSimulator.ConnectAndLogon方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TestIMAPLogonFailure

        public void TestIMAPLogonFailure()
        {
            _settings.AutoBanOnLogonFailure = true;
             _settings.MaxInvalidLogonAttempts = 4;
             _settings.MaxInvalidLogonAttemptsWithin = 5;
             _settings.AutoBanMinutes = 3;

             Account account = SingletonProvider<TestSetup>.Instance.AddAccount(_domain, "[email protected]", "test");

             var sim = new ImapClientSimulator();
             Assert.IsTrue(sim.ConnectAndLogon(account.Address, "test"));
             sim.Disconnect();

             // confirm that we can retrieve welcome message.
             Assert.IsTrue(sim.GetWelcomeMessage().StartsWith("* OK"));

             // fail to log on 3 times.
             for (int i = 0; i < 4; i++)
             {
            string errorMessage;

            Assert.IsFalse(sim.ConnectAndLogon(account.Address, "testA", out errorMessage));
            sim.Disconnect();

            if (i == 3)
            {
               Assert.IsTrue(errorMessage.Contains("Too many invalid logon attempts."));
            }
             }

             Assert.IsTrue(sim.GetWelcomeMessage().Length == 0);

             string logText = LogHandler.ReadCurrentDefaultLog();
             Assert.IsTrue(logText.Contains("Blocked either by IP range or by connection limit."), logText);
        }
开发者ID:SpivEgin,项目名称:hmailserver,代码行数:35,代码来源:AutoBan.cs

示例2: TestChangeSeenFlag

        public void TestChangeSeenFlag()
        {
            Account oAccount = SingletonProvider<TestSetup>.Instance.AddAccount(_domain, "[email protected]", "test");

             SmtpClientSimulator.StaticSend("[email protected]", oAccount.Address, "Test", "test");
             Pop3ClientSimulator.AssertMessageCount(oAccount.Address, "test", 1);

             var simulator = new ImapClientSimulator();
             simulator.ConnectAndLogon(oAccount.Address, "test");
             simulator.ExamineFolder("Inbox");
             string flags = simulator.GetFlags(1);
             string body = simulator.Fetch("1 RFC822");
             string flagsAfter = simulator.GetFlags(1);
             simulator.Close();
             simulator.Disconnect();

             Assert.AreEqual(flags, flagsAfter);

             var secondSimulator = new ImapClientSimulator();
             secondSimulator.ConnectAndLogon(oAccount.Address, "test");
             secondSimulator.SelectFolder("Inbox");
             string secondFlags = secondSimulator.GetFlags(1);
             string secondBody = secondSimulator.Fetch("1 RFC822");
             string secondFlagsAfter = secondSimulator.GetFlags(1);
             secondSimulator.Close();
             secondSimulator.Disconnect();

             Assert.AreNotEqual(secondFlags, secondFlagsAfter);
        }
开发者ID:SpivEgin,项目名称:hmailserver,代码行数:29,代码来源:Examine.cs

示例3: TestChangeRecentFlag

        public void TestChangeRecentFlag()
        {
            Account oAccount = SingletonProvider<TestSetup>.Instance.AddAccount(_domain, "[email protected]", "test");

             SmtpClientSimulator.StaticSend("[email protected]", oAccount.Address, "Test", "test");
             Pop3ClientSimulator.AssertMessageCount(oAccount.Address, "test", 1);

             var simulator = new ImapClientSimulator();
             simulator.ConnectAndLogon(oAccount.Address, "test");
             string result = simulator.ExamineFolder("Inbox");
             Assert.IsTrue(result.Contains("* 1 RECENT"), result);
             simulator.Close();
             simulator.Disconnect();

             simulator = new ImapClientSimulator();
             simulator.ConnectAndLogon(oAccount.Address, "test");
             Assert.IsTrue(simulator.SelectFolder("Inbox", out result));
             Assert.IsTrue(result.Contains("* 1 RECENT"), result);
             simulator.Close();
             simulator.Disconnect();

             simulator = new ImapClientSimulator();
             simulator.ConnectAndLogon(oAccount.Address, "test");
             result = simulator.ExamineFolder("Inbox");
             Assert.IsTrue(result.Contains("* 0 RECENT"), result);
             simulator.Close();
             simulator.Disconnect();
        }
开发者ID:SpivEgin,项目名称:hmailserver,代码行数:28,代码来源:Examine.cs

示例4: TestIMAPServer

        public void TestIMAPServer()
        {
            LogHandler.DeleteCurrentDefaultLog();

             Account account = SingletonProvider<TestSetup>.Instance.AddAccount(_domain, "[email protected]", "test");

             for (int i = 0; i < 30; i++)
             {
            try
            {
               var imapSim = new ImapClientSimulator(true, 14301);
               imapSim.ConnectAndLogon(account.Address, "test");
               Assert.IsTrue(imapSim.SelectFolder("Inbox"), "SelectInbox");
               imapSim.CreateFolder("Test");
               Assert.IsTrue(imapSim.SelectFolder("Test"), "SelectTest");
               Assert.IsTrue(imapSim.Logout(), "Logout");

               imapSim.Disconnect();
               break;
            }
            catch (Exception)
            {
               if (i == 29)
                  throw;
            }
             }
        }
开发者ID:baa-archieve,项目名称:hmailserver,代码行数:27,代码来源:SslServerTests.cs

示例5: TestAddMessage

        public void TestAddMessage()
        {
            Application app = SingletonProvider<TestSetup>.Instance.GetApp();
             Utilities utilities = app.Utilities;

             Account account = SingletonProvider<TestSetup>.Instance.AddAccount(_domain, "[email protected]", "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("[email protected]", 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);
             }

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

             Assert.AreEqual(copy, uids);
        }
开发者ID:SpivEgin,项目名称:hmailserver,代码行数:59,代码来源:Basics.cs

示例6: TestChangeFlags

        public void TestChangeFlags()
        {
            Account oAccount = SingletonProvider<TestSetup>.Instance.AddAccount(_domain, "[email protected]", "test");

             SmtpClientSimulator.StaticSend("[email protected]", oAccount.Address, "Test", "test");
             Pop3ClientSimulator.AssertMessageCount(oAccount.Address, "test", 1);

             var simulator = new ImapClientSimulator();
             simulator.ConnectAndLogon(oAccount.Address, "test");
             simulator.ExamineFolder("Inbox");
             Assert.IsFalse(simulator.SetFlagOnMessage(1, true, @"\Deleted"));
        }
开发者ID:SpivEgin,项目名称:hmailserver,代码行数:12,代码来源:Examine.cs

示例7: SetupEnvWith50MillionMessages

        public void SetupEnvWith50MillionMessages()
        {
            const int accountCount = 1;
             const int folderCount = 1;
             const int messageCount = 100000;

             var accounts = new List<string>();
             for (int accountIdx = 0; accountIdx < accountCount; accountIdx++)
             {
            var account = string.Format("test-{0}@test.com", accountIdx);
            accounts.Add(account);

            TestTracer.WriteTraceInfo("Setting up {0}...", account);
            SingletonProvider<TestSetup>.Instance.AddAccount(_domain, account, "test");
             }

             var folders = new List<string>();
             for (int folderIdx = 0; folderIdx < folderCount; folderIdx++)
            folders.Add(string.Format("Folder-{0}", folderIdx));

             var parallelOptions = new ParallelOptions();
             parallelOptions.MaxDegreeOfParallelism = 10;

             var watch = new Stopwatch();
             watch.Start();

             Parallel.ForEach(accounts, parallelOptions, account =>
            {
               TestTracer.WriteTraceInfo("Processing messages for {0}...", account);

               var sim = new ImapClientSimulator();
               Assert.IsTrue(sim.ConnectAndLogon(account, "test"));

               foreach (var folder in folders)
               {
                  Assert.IsTrue(sim.CreateFolder(folder));

                  for (int i = 0; i < messageCount; i++)
                  {
                     string f = sim.SendSingleCommandWithLiteral("A01 APPEND " + folder + " {1}", "A");
                     Assert.IsTrue(f.Contains("A01 OK APPEND completed"), f);
                  }
               }

               sim.Disconnect();
            });

             watch.Stop();
             TestTracer.WriteTraceInfo(watch.ElapsedMilliseconds.ToString());
        }
开发者ID:SpivEgin,项目名称:hmailserver,代码行数:50,代码来源:PerfTestEnvironmentSetUp.cs

示例8: TestEmptyPassword

        public void TestEmptyPassword()
        {
            Account account1 = SingletonProvider<TestSetup>.Instance.AddAccount(_domain, "[email protected]", "");

             string message;
             var sim = new Pop3ClientSimulator();
             Assert.IsFalse(sim.ConnectAndLogon(account1.Address, "", out message));

             var simIMAP = new ImapClientSimulator();
             Assert.IsFalse(simIMAP.ConnectAndLogon(account1.Address, "", out message));
             Assert.AreEqual("A01 NO Invalid user name or password.\r\n", message);

             var simSMTP = new SmtpClientSimulator();
             CustomAsserts.Throws<AuthenticationException>(() => simSMTP.ConnectAndLogon("dGVzdEB0ZXN0LmNvbQ==", "", out message));
             Assert.AreEqual("535 Authentication failed. Restarting authentication process.\r\n", message);
        }
开发者ID:SpivEgin,项目名称:hmailserver,代码行数:16,代码来源:Basics.cs

示例9: AssertMessageCount

        public static void AssertMessageCount(string accountName, string accountPassword, string folderName,
                                            int expectedCount)
        {
            if (expectedCount == 0)
             {
            // make sure that we aren't currently delivering messages.
            CustomAsserts.AssertRecipientsInDeliveryQueue(0);
             }

             var oIMAP = new ImapClientSimulator();
             Assert.IsTrue(oIMAP.ConnectAndLogon(accountName, accountPassword));

             if (expectedCount != 0)
            oIMAP.AssertFolderExists(folderName);

             int currentCount = 0;
             int timeout = 1000; // 1000 * 25 = 25 seconds.
             while (timeout > 0)
             {
            currentCount = oIMAP.GetMessageCount(folderName);

            if (currentCount > expectedCount)
               break;

            if (currentCount == expectedCount)
            {
               oIMAP.Disconnect();
               return;
            }

            timeout--;
            Thread.Sleep(25);
             }

             oIMAP.Disconnect();

             string error = "Wrong number of messages in mailbox " + folderName + " in account " + accountName +
                        " Actual: " + currentCount.ToString() + " Expected: " + expectedCount.ToString();
             Assert.Fail(error);
        }
开发者ID:SpivEgin,项目名称:hmailserver,代码行数:40,代码来源:IMAPClientSimulator.cs

示例10: ChangingFlagShouldAffectAllConnections

        public void ChangingFlagShouldAffectAllConnections()
        {
            var account = SingletonProvider<TestSetup>.Instance.AddAccount(_domain, "[email protected]", "test");
             SmtpClientSimulator.StaticSend(account.Address, account.Address, "Test", "Test");

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

             var sim1 = new ImapClientSimulator();
             Assert.IsTrue(sim1.ConnectAndLogon(account.Address, "test"));
             Assert.IsTrue(sim1.SelectFolder("Inbox"));

             var sim2 = new ImapClientSimulator();
             Assert.IsTrue(sim2.ConnectAndLogon(account.Address, "test"));
             Assert.IsTrue(sim2.SelectFolder("Inbox"));

             sim1.SetFlagOnMessage(1, true, "\\Deleted");

             var flags1 = sim1.GetFlags(1);
             var flags2 = sim2.GetFlags(1);

             Assert.IsTrue(flags2.Contains(@"* 1 FETCH (FLAGS (\Deleted))"), flags2);
             Assert.IsTrue(flags2.Contains(@"* 1 FETCH (FLAGS (\Deleted) UID 1)"), flags2);
        }
开发者ID:SpivEgin,项目名称:hmailserver,代码行数:23,代码来源:ConcurrentConnections.cs

示例11: TestBodyStructureWithNonLatinCharacterSingleLineWithSpace

        public void TestBodyStructureWithNonLatinCharacterSingleLineWithSpace()
        {
            string @messageText =
            "Return-Path: [email protected]\r\n" +
            "Delivered-To: [email protected]\r\n" +
            "Received: from www.hmailserver.com ([127.0.0.1])\r\n" +
            "	by mail.hmailserver.com\r\n" +
            "	; Tue, 16 Jun 2009 21:39:18 +0200\r\n" +
            "MIME-Version: 1.0\r\n" +
            "Date: Tue, 16 Jun 2009 21:39:18 +0200\r\n" +
            "From: <[email protected]>\r\n" +
            "To: <[email protected]>\r\n" +
            "Subject: sdafsda\r\n" +
            "Message-ID: <[email protected]>\r\n" +
            "X-Sender: [email protected]\r\n" +
            "User-Agent: RoundCube Webmail/0.2.2\r\n" +
            "Content-Type: multipart/mixed;\r\n" +
            "	boundary=\"=_b63968892a76b1a5be17f4d37b085f54\"\r\n" +
            "\r\n" +
            "--=_b63968892a76b1a5be17f4d37b085f54\r\n" +
            "Content-Transfer-Encoding: 8bit\r\n" +
            "Content-Type: text/plain; charset=\"UTF-8\"\r\n" +
            "\r\n" +
            "--=_b63968892a76b1a5be17f4d37b085f54\r\n" +
            "Content-Transfer-Encoding: base64\r\n" +
            "Content-Type: application/x-zip; charset=\"UTF-8\";\r\n" +
            " name*=\"UTF-8''m%C3%A4%C3%B6 m%C3%A4%C3%B6.zip\"; \r\n" +
            "Content-Disposition: attachment;\r\n" +
            " filename*=\"UTF-8''m%C3%A4%C3%B6 m%C3%A4%C3%B6.zip\"; \r\n" +
            "\r\n" +
            "iVBORw0KGgoAAAANSUhEUgAAAqgAAAH4CAIAAAAJvIhhAAAAAXNSR0IArs4c6QAAAARnQU1BAACx\r\n" +
            "jwv8YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAIr1JREFU\r\n" +
            "eF7t29GSYzluBND1/3/0ejb6wY6emK2WrpQEkaefdQvAAcn02OH/+fe///0v/wgQIECAAIESgb+C\r\n" +
            "3z8CBAgQIECgROBfJXMakwABAgQIEPjP/5qfAgECBAgQINAjIPh7dm1SAgQIECDgv/idAQIECBAg\r\n" +
            "--=_b63968892a76b1a5be17f4d37b085f54--\r\n" +
            "";

             Account account = SingletonProvider<TestSetup>.Instance.AddAccount(_domain, "[email protected]", "test");

             SmtpClientSimulator.StaticSendRaw(account.Address, account.Address, messageText);

             CustomAsserts.AssertFolderMessageCount(account.IMAPFolders[0], 1);

             var oSimulator = new ImapClientSimulator();
             oSimulator.ConnectAndLogon(account.Address, "test");
             oSimulator.SelectFolder("INBOX");
             string result = oSimulator.Fetch("1 BODYSTRUCTURE");
             oSimulator.Disconnect();

             Assert.IsFalse(result.Contains("''"), result);
             Assert.IsTrue(result.Contains("\"FILENAME\" \"=?UTF-8?Q?m=C3=A4=C3=B6 m=C3=A4=C3=B6.zip?=\""), result);
             Assert.IsTrue(result.Contains("\"NAME\" \"=?UTF-8?Q?m=C3=A4=C3=B6 m=C3=A4=C3=B6.zip?=\""), result);
        }
开发者ID:baa-archieve,项目名称:hmailserver,代码行数:53,代码来源:Basics.cs

示例12: TestBodyStructureWithNonLatinCharacterSingleLineEncoded

        public void TestBodyStructureWithNonLatinCharacterSingleLineEncoded()
        {
            string @messageText =
            "Message-ID: <[email protected]*******.**>\r\n" +
            "Date: Fri, 29 May 2009 11:53:03 +0200\r\n" +
            "Subject: attachment's name test\r\n" +
            "From: [email protected]\r\n" +
            "To: [email protected]\r\n" +
            "User-Agent: SquirrelMail/1.4.19\r\n" +
            "MIME-Version: 1.0\r\n" +
            "Content-Type: multipart/mixed;boundary=\"----=_20090529115303_60479\"\r\n" +
            "X-Priority: 3 (Normal)\r\n" +
            "Importance: Normal\r\n" +
            "\r\n" +
            "------=_20090529115303_60479\r\n" +
            "Content-Type: text/plain; charset=\"iso-8859-2\"\r\n" +
            "Content-Transfer-Encoding: 8bit\r\n" +
            "\r\n" +
            "test.±æê³ñ󶼿.txt\r\n" +
            "------=_20090529115303_60479\r\n" +
            "Content-Type: text/plain; name=\r\n" +
            "    =?iso-8859-2?Q?test.=B1=E6=EA=B3=F1=F3=B6=BC=BF.txt?=\r\n" +
            "Content-Transfer-Encoding: 8bit\r\n" +
            "Content-Disposition: attachment; filename=\"\r\n" +
            "    =?iso-8859-2?Q?test.=B1=E6=EA=B3=F1=F3=B6=BC=BF.txt?=\"\r\n" +
            "\r\n" +
            "1234\r\n" +
            "------=_20090529115303_60479--\r\n";

             Account account = SingletonProvider<TestSetup>.Instance.AddAccount(_domain, "[email protected]", "test");

             SmtpClientSimulator.StaticSendRaw(account.Address, account.Address, messageText);

             CustomAsserts.AssertFolderMessageCount(account.IMAPFolders[0], 1);

             var oSimulator = new ImapClientSimulator();
             oSimulator.ConnectAndLogon(account.Address, "test");
             oSimulator.SelectFolder("INBOX");
             string result = oSimulator.Fetch("1 BODYSTRUCTURE");
             oSimulator.Disconnect();

             Assert.IsTrue(result.Contains("(\"NAME\" \"=?iso-8859-2?Q?test.=B1=E6=EA=B3=F1=F3=B6=BC=BF.txt?=\")"));
             Assert.IsTrue(result.Contains("(\"FILENAME\" \"=?iso-8859-2?Q?test.=B1=E6=EA=B3=F1=F3=B6=BC=BF.txt?=\")"));
        }
开发者ID:baa-archieve,项目名称:hmailserver,代码行数:44,代码来源:Basics.cs

示例13: TestBodyStructureWithNonLatinCharacterInAttachmentHeader

        public void TestBodyStructureWithNonLatinCharacterInAttachmentHeader()
        {
            string @messageText =
            "From: \"Test\" <[email protected]>" + "\r\n" +
            "To: \"Test\" <[email protected]>" + "\r\n" +
            "Subject: test" + "\r\n" +
            "MIME-Version: 1.0" + "\r\n" +
            "Content-Type: multipart/mixed;" + "\r\n" +
            "   boundary=\"----=_NextPart_000_000C_01C9EEB2.08D2EC80\"" + "\r\n" +
            "X-Priority: 3" + "\r\n" +
            "" + "\r\n" +
            "This is a multi-part message in MIME format." + "\r\n" +
            "" + "\r\n" +
            "------=_NextPart_000_000C_01C9EEB2.08D2EC80" + "\r\n" +
            "Content-Type: text/plain;" + "\r\n" +
            "  format=flowed;" + "\r\n" +
            "	charset=\"iso-8859-1\";" + "\r\n" +
            "	reply-type=original" + "\r\n" +
            "Content-Transfer-Encoding: 7bit" + "\r\n" +
            "" + "\r\n" +
            "" + "\r\n" +
            "------=_NextPart_000_000C_01C9EEB2.08D2EC80" + "\r\n" +
            "Content-Type: application/octet-stream;" + "\r\n" +
            "	name=\"=?iso-8859-1?B?beT2LnppcA==?=\"" + "\r\n" +
            "Content-Transfer-Encoding: base64" + "\r\n" +
            "Content-Disposition: attachment;" + "\r\n" +
            "	filename=\"=?iso-8859-1?B?beT2LnppcA==?=\"" + "\r\n" +
            "" + "\r\n" +
            "iVBORw0KGgoAAAANSUhEUgAAAqgAAAH4CAIAAAAJvIhhAAAAAXNSR0IArs4c6QAAAARnQU1BAACx" + "\r\n" +
            "uIDgj5MrSIAAAQIEzgkI/nP2KhMgQIAAgbiA4I+TK0iAAAECBM4JCP5z9ioTIECAAIG4wP8ChvJS" + "\r\n" +
            "wXUaKVoAAAAASUVORK5CYII=" + "\r\n" +
            "" + "\r\n" +
            "------=_NextPart_000_000C_01C9EEB2.08D2EC80--" + "\r\n";

             Account account = SingletonProvider<TestSetup>.Instance.AddAccount(_domain, "[email protected]", "test");

             SmtpClientSimulator.StaticSendRaw(account.Address, account.Address, messageText);

             CustomAsserts.AssertFolderMessageCount(account.IMAPFolders[0], 1);

             var oSimulator = new ImapClientSimulator();
             oSimulator.ConnectAndLogon(account.Address, "test");
             oSimulator.SelectFolder("INBOX");
             string result = oSimulator.Fetch("1 BODYSTRUCTURE");
             oSimulator.Disconnect();

             Assert.IsTrue(result.Contains("(\"NAME\" \"=?iso-8859-1?B?beT2LnppcA==?=\")"));
             Assert.IsTrue(result.Contains("(\"FILENAME\" \"=?iso-8859-1?B?beT2LnppcA==?=\")"));

             string fileName = account.IMAPFolders.get_ItemByName("INBOX").Messages[0].Attachments[0].Filename;
             Assert.AreEqual("mäö.zip", fileName);
        }
开发者ID:baa-archieve,项目名称:hmailserver,代码行数:52,代码来源:Basics.cs

示例14: TestUnseenResponseInSelect

        public void TestUnseenResponseInSelect()
        {
            Account account = SingletonProvider<TestSetup>.Instance.AddAccount(_domain, "[email protected]", "test");

             SmtpClientSimulator.StaticSend(account.Address, account.Address, "Test", "TestMessage");

             ImapClientSimulator.AssertMessageCount(account.Address, "test", "Inbox", 1);

             var sim = new ImapClientSimulator();
             Assert.IsTrue(sim.ConnectAndLogon(account.Address, "test"));
             Assert.IsTrue(sim.SelectFolder("Inbox"));
             Assert.IsTrue(sim.CreateFolder("Dummy"));
             Assert.IsTrue(sim.Copy(1, "Dummy"));

             string result = sim.SendSingleCommand("a01 select Dummy");
             Assert.IsTrue(result.Contains("* 1 EXISTS\r\n* 1 RECENT"), result);

             string searchResponse = sim.SendSingleCommand("srch1 SEARCH ALL UNSEEN");

             // We should have at least one message here.
             Assert.IsTrue(searchResponse.Contains("* SEARCH 1\r\n"), searchResponse);

             // Now fetch the body.
             string bodyText = sim.Fetch("1 BODY[TEXT]");

             // Now the message is no longer unseen. Confirm this.
             searchResponse = sim.SendSingleCommand("srch1 SEARCH ALL UNSEEN");
             Assert.IsTrue(searchResponse.Contains("* SEARCH\r\n"), searchResponse);

             // Close the messages to mark them as no longer recent.
             Assert.IsTrue(sim.Close());

             result = sim.SendSingleCommand("a01 select Dummy");
             Assert.IsTrue(result.Contains("* 1 EXISTS\r\n* 0 RECENT"), result);
        }
开发者ID:baa-archieve,项目名称:hmailserver,代码行数:35,代码来源:Basics.cs

示例15: TestRecentRemovedOnMailboxClose

        public void TestRecentRemovedOnMailboxClose()
        {
            Account account = SingletonProvider<TestSetup>.Instance.AddAccount(_domain, "[email protected]", "test");

             SmtpClientSimulator.StaticSend(account.Address, account.Address, "Test", "TestMessage");
             ImapClientSimulator.AssertMessageCount(account.Address, "test", "Inbox", 1);

             var sim = new ImapClientSimulator();
             Assert.IsTrue(sim.ConnectAndLogon(account.Address, "test"));
             Assert.IsTrue(sim.SelectFolder("Inbox"));
             Assert.IsTrue(sim.CreateFolder("Dummy"));
             Assert.IsTrue(sim.Copy(1, "Dummy"));
             string result = sim.SendSingleCommand("a01 select Dummy");
             Assert.IsTrue(result.Contains("* 1 EXISTS\r\n* 1 RECENT"), result);
             Assert.IsTrue(sim.Logout());

             sim = new ImapClientSimulator();
             Assert.IsTrue(sim.ConnectAndLogon(account.Address, "test"));
             result = sim.SendSingleCommand("a01 select Dummy");
             Assert.IsFalse(result.Contains("* 1 EXISTS\r\n* 1 RECENT"), result);
             Assert.IsTrue(sim.Logout());
        }
开发者ID:baa-archieve,项目名称:hmailserver,代码行数:22,代码来源:Basics.cs


注:本文中的RegressionTests.Shared.ImapClientSimulator.ConnectAndLogon方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。