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


C# IMAPSimulator.ConnectAndLogon方法代码示例

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


在下文中一共展示了IMAPSimulator.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 IMAPSimulator();
             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 = TestSetup.ReadCurrentDefaultLog();
             Assert.IsTrue(logText.Contains("Blocked either by IP range or by connection limit."), logText);
        }
开发者ID:jrallo,项目名称:hMailServer,代码行数:35,代码来源:AutoBan.cs

示例2: TestIMAPServer

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

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

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

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

示例3: TestBodyStructureWithNonLatinCharacter

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

             string attachmentName = "本本本.zip";

             string filename = Path.Combine(Path.GetTempPath(), attachmentName);
             File.WriteAllText(filename, "tjena moss");

             var message = new Message();
             message.Charset = "utf-8";
             message.AddRecipient("test", account.Address);
             message.From = "Test";
             message.FromAddress = account.Address;
             message.Body = "hejsan";
             message.Attachments.Add(filename);
             message.Save();

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

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

             // utf-8 representation of 本本本.zip:
             Assert.IsTrue(result.Contains("=?utf-8?B?5pys5pys5pys?=.zip"));
        }
开发者ID:jrallo,项目名称:hMailServer,代码行数:29,代码来源:Fetch.cs

示例4: TestChangeRecentFlag

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

             Assert.IsTrue(SMTPClientSimulator.StaticSend("[email protected]", oAccount.Address, "Test", "test"));
             POP3Simulator.AssertMessageCount(oAccount.Address, "test", 1);

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

             simulator = new IMAPSimulator();
             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 IMAPSimulator();
             simulator.ConnectAndLogon(oAccount.Address, "test");
             result = simulator.ExamineFolder("Inbox");
             Assert.IsTrue(result.Contains("* 0 RECENT"), result);
             simulator.Close();
             simulator.Disconnect();
        }
开发者ID:jrallo,项目名称:hMailServer,代码行数:28,代码来源:Examine.cs

示例5: TestChangeSeenFlag

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

             Assert.IsTrue(SMTPClientSimulator.StaticSend("[email protected]", oAccount.Address, "Test", "test"));
             POP3Simulator.AssertMessageCount(oAccount.Address, "test", 1);

             var simulator = new IMAPSimulator();
             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 IMAPSimulator();
             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:jrallo,项目名称:hMailServer,代码行数:29,代码来源:Examine.cs

示例6: 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();

            POP3Simulator.AssertMessageCount(account.Address, "test", ((i + 1)*2) - 1);

            SMTPClientSimulator.StaticSend("[email protected]", account.Address, "Test", "Test");
            POP3Simulator.AssertMessageCount(account.Address, "test", (i + 1)*2);
             }

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

             var sim = new IMAPSimulator();
             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:jrallo,项目名称:hMailServer,代码行数:59,代码来源:Basics.cs

示例7: TestChangeFlags

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

             Assert.IsTrue(SMTPClientSimulator.StaticSend("[email protected]", oAccount.Address, "Test", "test"));
             POP3Simulator.AssertMessageCount(oAccount.Address, "test", 1);

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

示例8: TestEmptyPassword

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

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

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

             var simSMTP = new SMTPClientSimulator();
             Assert.IsFalse(simSMTP.ConnectAndLogon(25, "dGVzdEB0ZXN0LmNvbQ==", "", out message));
             Assert.AreEqual("535 Authentication failed. Restarting authentication process.\r\n", message);
        }
开发者ID:jrallo,项目名称: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.
            TestSetup.AssertRecipientsInDeliveryQueue(0);
             }

             var oIMAP = new IMAPSimulator();
             CustomAssert.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();
             CustomAssert.Fail(error);
        }
开发者ID:japi,项目名称:hmailserver,代码行数:40,代码来源:IMAPSimulator.cs

示例10: Test

        public void Test()
        {
            IMAPSimulator sim = new IMAPSimulator();
             sim.ConnectAndLogon("[email protected]", "test");
             sim.SelectFolder("Inbox");

             Stopwatch watch = new Stopwatch();

             watch.Start();
             string result = sim.SendSingleCommand("A282 SORT (SIZE) UTF-8");
             watch.Stop();

             long sortSizeTime = watch.ElapsedMilliseconds;
             watch.Reset();

             watch.Start();
             result = sim.SendSingleCommand("A282 SORT (FROM) UTF-8");
             watch.Stop();

             long sortFromTime = watch.ElapsedMilliseconds;
             watch.Reset();

             watch.Start();
             result = sim.SendSingleCommand("A282 SORT (FROM) UTF-8 1:15");
             watch.Stop();

             long sortFromTimeLimit15 = watch.ElapsedMilliseconds;
             watch.Reset();

             watch.Start();
             result = sim.SendSingleCommand("A282 SORT (DATE) UTF-8");
             watch.Stop();

             long sortDateTime = watch.ElapsedMilliseconds;
             watch.Reset();

             System.Threading.Thread.Sleep(1);
        }
开发者ID:Bill48105,项目名称:hmailserver,代码行数:38,代码来源:IMAPSortPerformance.cs

示例11: TestFetch

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

             SMTPClientSimulator.StaticSend(account.Address, account.Address, "Test", "SampleBody1");
             IMAPSimulator.AssertMessageCount(account.Address, "test", "Inbox", 1);

             SMTPClientSimulator.StaticSend(account.Address, account.Address, "Test", "SampleBody2");
             IMAPSimulator.AssertMessageCount(account.Address, "test", "Inbox", 2);

             SMTPClientSimulator.StaticSend(account.Address, account.Address, "Test", "SampleBody3");
             IMAPSimulator.AssertMessageCount(account.Address, "test", "Inbox", 3);

             var sim = new IMAPSimulator();
             sim.ConnectAndLogon(account.Address, "test");
             sim.SelectFolder("INBOX");
             string result = sim.Fetch("1 BODY[1]");
             Assert.IsTrue(result.Contains("SampleBody1"), result);
             result = sim.Fetch("2 BODY[1]");
             Assert.IsTrue(result.Contains("SampleBody2"), result);
             result = sim.Fetch("3 BODY[1]");
             Assert.IsTrue(result.Contains("SampleBody3"), result);
        }
开发者ID:jrallo,项目名称:hMailServer,代码行数:23,代码来源:Fetch.cs

示例12: 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");

             Assert.IsTrue(SMTPClientSimulator.StaticSendRaw(account.Address, account.Address, messageText));

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

             var oSimulator = new IMAPSimulator();
             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:jrallo,项目名称:hMailServer,代码行数:52,代码来源:Basics.cs

示例13: ConnectAndLogon

 private static IMAPSimulator ConnectAndLogon()
 {
     IMAPSimulator sim = new IMAPSimulator();
     sim.ConnectAndLogon("[email protected]", "test");
     return sim;
 }
开发者ID:Bill48105,项目名称:hmailserver,代码行数:6,代码来源:Program.cs

示例14: TestFolderUpdateNotification

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

             SMTPClientSimulator.StaticSend(account.Address, account.Address, "TestSubject", "TestBody");

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

             var simulator1 = new IMAPSimulator();
             var simulator2 = new IMAPSimulator();

             simulator1.ConnectAndLogon(account.Address, "test");
             simulator2.ConnectAndLogon(account.Address, "test");

             simulator1.SelectFolder("Inbox");
             simulator2.SelectFolder("Inbox");

             string result = simulator2.NOOP() + simulator2.NOOP();
             Assert.IsFalse(result.Contains("Deleted"));
             Assert.IsFalse(result.Contains("Seen"));

             simulator1.SetDeletedFlag(1);
             simulator1.SetSeenFlag(1);

             result = simulator2.NOOP() + simulator2.NOOP();
             Assert.IsTrue(result.Contains("Deleted"));
             Assert.IsTrue(result.Contains("Seen"));

             simulator1.Disconnect();
             simulator2.Disconnect();
        }
开发者ID:jrallo,项目名称:hMailServer,代码行数:31,代码来源:Basics.cs

示例15: TestFolderExpungeNotification

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

             SMTPClientSimulator.StaticSend(account.Address, account.Address, "TestSubject", "TestBody");
             IMAPSimulator.AssertMessageCount(account.Address, "test", "Inbox", 1);

             var simulator1 = new IMAPSimulator();
             var simulator2 = new IMAPSimulator();

             simulator1.ConnectAndLogon(account.Address, "test");
             simulator2.ConnectAndLogon(account.Address, "test");

             simulator1.SelectFolder("Inbox");
             simulator2.SelectFolder("Inbox");

             string result = simulator2.NOOP();
             Assert.IsFalse(result.Contains("Deleted"));
             Assert.IsFalse(result.Contains("Seen"));

             simulator1.SetDeletedFlag(1);
             simulator1.Expunge();

             // the result may (should) come after the first NOOP response stream so do noop twice.
             result = simulator2.NOOP() + simulator2.NOOP();
             Assert.IsTrue(result.Contains("* 1 EXPUNGE"));

             simulator1.Disconnect();
             simulator2.Disconnect();
        }
开发者ID:jrallo,项目名称:hMailServer,代码行数:30,代码来源:Basics.cs


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