当前位置: 首页>>代码示例>>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();
             CustomAssert.IsTrue(sim.ConnectAndLogon(account.Address, "test"));
             sim.Disconnect();

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

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

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

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

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

             string logText = TestSetup.ReadCurrentDefaultLog();
             CustomAssert.IsTrue(logText.Contains("Blocked either by IP range or by connection limit."), logText);
        }
开发者ID:digitalsoft,项目名称: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 IMAPClientSimulator(true, 14301);
               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:digitalsoft,项目名称:hmailserver,代码行数:27,代码来源:SslServerTests.cs

示例3: TestChangeSeenFlag

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

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

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

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

示例4: 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 IMAPClientSimulator();
             oSimulator.ConnectAndLogon(account.Address, "test");
             oSimulator.SelectFolder("INBOX");
             string result = oSimulator.Fetch("1 BODYSTRUCTURE");
             oSimulator.Disconnect();

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

示例5: TestChangeRecentFlag

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

             CustomAssert.IsTrue(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");
             CustomAssert.IsTrue(result.Contains("* 1 RECENT"), result);
             simulator.Close();
             simulator.Disconnect();

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

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

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

             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);
        }
开发者ID:digitalsoft,项目名称:hmailserver,代码行数:59,代码来源:Basics.cs

示例7: TestChangeFlags

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

             CustomAssert.IsTrue(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");
             CustomAssert.IsFalse(simulator.SetFlagOnMessage(1, true, @"\Deleted"));
        }
开发者ID:digitalsoft,项目名称:hmailserver,代码行数:12,代码来源:Examine.cs

示例8: TestEmptyPassword

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

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

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

             var simSMTP = new SMTPClientSimulator();
             CustomAssert.IsFalse(simSMTP.ConnectAndLogon("dGVzdEB0ZXN0LmNvbQ==", "", out message));
             CustomAssert.AreEqual("535 Authentication failed. Restarting authentication process.\r\n", message);
        }
开发者ID:digitalsoft,项目名称: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 IMAPClientSimulator();
             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:digitalsoft,项目名称:hmailserver,代码行数:40,代码来源:IMAPClientSimulator.cs

示例10: TestFetch

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

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

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

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

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

示例11: TestListWithReference

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

             var oSimulator = new IMAPClientSimulator();
             oSimulator.ConnectAndLogon(oAccount.Address, "test");
             oSimulator.CreateFolder("Main.Sub1.Sub2.Sub3");
             oSimulator.CreateFolder("SomeOtherFolder");

             oSimulator.Subscribe("Main");
             oSimulator.Subscribe("Main.Sub1");
             oSimulator.Subscribe("Main.Sub1.Sub2");
             oSimulator.Subscribe("Main.Sub1.Sub2.Sub3");
             oSimulator.Subscribe("SomeOtherFolder");

             string response = oSimulator.List("Main", "*", true);
             CustomAssert.IsFalse(response.Contains("INBOX"));
             CustomAssert.IsFalse(response.Contains("SomeOtherFolder"));
             CustomAssert.IsTrue(response.Contains("* LIST (\\HasChildren) \".\" \"Main.Sub1\""));
             CustomAssert.IsTrue(response.Contains("* LIST (\\HasChildren) \".\" \"Main.Sub1.Sub2\""));
             CustomAssert.IsTrue(response.Contains("* LIST (\\HasNoChildren) \".\" \"Main.Sub1.Sub2.Sub3\""));

             response = oSimulator.List("Main.Sub1", "*", true);
             CustomAssert.IsFalse(response.Contains("INBOX"));
             CustomAssert.IsFalse(response.Contains("SomeOtherFolder"));
             CustomAssert.IsTrue(response.Contains("* LIST (\\HasChildren) \".\" \"Main.Sub1.Sub2\""));
             CustomAssert.IsTrue(response.Contains("* LIST (\\HasNoChildren) \".\" \"Main.Sub1.Sub2.Sub3\""));

             response = oSimulator.LSUB("Main", "*");
             CustomAssert.IsFalse(response.Contains("INBOX"));
             CustomAssert.IsFalse(response.Contains("SomeOtherFolder"));
             CustomAssert.IsTrue(response.Contains("* LSUB (\\HasChildren) \".\" \"Main.Sub1\""));
             CustomAssert.IsTrue(response.Contains("* LSUB (\\HasChildren) \".\" \"Main.Sub1.Sub2\""));
             CustomAssert.IsTrue(response.Contains("* LSUB (\\HasNoChildren) \".\" \"Main.Sub1.Sub2.Sub3\""));

             response = oSimulator.LSUB("Main.Sub1", "*");
             CustomAssert.IsFalse(response.Contains("INBOX"));
             CustomAssert.IsFalse(response.Contains("SomeOtherFolder"));
             CustomAssert.IsTrue(response.Contains("* LSUB (\\HasChildren) \".\" \"Main.Sub1.Sub2\""));
             CustomAssert.IsTrue(response.Contains("* LSUB (\\HasNoChildren) \".\" \"Main.Sub1.Sub2.Sub3\""));

             oSimulator.Disconnect();
        }
开发者ID:digitalsoft,项目名称:hmailserver,代码行数:43,代码来源:Folders.cs

示例12: TestFolderUpdateNotification

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

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

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

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

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

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

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

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

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

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

示例13: TestBasics

        public void TestBasics()
        {
            // Fetch the default domain

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

             // Add a rule to this account.
             SingletonProvider<TestSetup>.Instance.AddSpamRule(oAccount);
             SingletonProvider<TestSetup>.Instance.AddCorporateRule(oAccount);
             SingletonProvider<TestSetup>.Instance.AddExactMatchRule(oAccount);

             var oSMTP = new SMTPClientSimulator();

             // Spam folder
             oSMTP.Send("[email protected]", "[email protected]", "**SPAM** INBOX->SPAM",
                    "Detta ska hamna i mappen Inbox\\Spam");

             // Corporate folder
             oSMTP.Send("[email protected]", "[email protected]", "**CORPORATE** INBOX->CORPORATE",
                    "Detta ska hamna i mappen Inbox\\Corporate");
             oSMTP.Send("[email protected]", "[email protected]", "CORPORATE EXACT MATCH",
                    "Detta ska hamna i mappen Inbox\\Corporate");

             // Inbox folder
             oSMTP.Send("[email protected]", "[email protected]", "**CORPORATE EXACT MATCH**",
                    "Detta ska hamna i mappen Inbox");
             oSMTP.Send("[email protected]", "[email protected]", "INBOX", "Detta ska hamna i mappen Inbox");
             oSMTP.Send("[email protected]", "[email protected]", "INBOX", "Detta ska hamna i mappen Inbox");
             oSMTP.Send("[email protected]", "[email protected]", "INBOX", "Detta ska hamna i mappen Inbox");

             IMAPClientSimulator.AssertMessageCount("[email protected]", "test", "Inbox.Spam", 1);
             IMAPClientSimulator.AssertMessageCount("[email protected]", "test", "Inbox.Corporate", 2);
             IMAPClientSimulator.AssertMessageCount("[email protected]", "test", "Inbox", 4);

             // Test move to imap with mail with multiple recipients.

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

             // Send email to both recipients
             var lstRecipients = new List<string> {"[email protected]", "[email protected]"};

             const string sBody = "Test of sending same email to multiple accounts.";

             oSMTP.Send(oAccount1.Address, lstRecipients, "**SPAM** INBOX->SPAM", sBody);

             IMAPClientSimulator.AssertMessageCount(oAccount1.Address, "test", "Inbox.Spam", 1);
             IMAPClientSimulator.AssertMessageCount(oAccount2.Address, "test", "Inbox", 1);

             var sim = new IMAPClientSimulator();
             sim.ConnectAndLogon(oAccount2.Address, "test");
             CustomAssert.IsFalse(sim.SelectFolder("Inbox.Spam"));
        }
开发者ID:digitalsoft,项目名称:hmailserver,代码行数:55,代码来源:Rules.cs

示例14: TestSearchUSASCII

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

             SMTPClientSimulator.StaticSend(account.Address, account.Address, "MySubject", "MyBody");

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

             var oSimulator = new IMAPClientSimulator();
             CustomAssert.IsTrue(oSimulator.ConnectAndLogon(account.Address, "test"));
             CustomAssert.IsTrue(oSimulator.SelectFolder("INBOX"));

             string result = oSimulator.Search("CHARSET US-ASCII ALL SUBJECT MySubject");
             CustomAssert.AreEqual("1", result);

             result = oSimulator.Search("CHARSET US-ASCII ALL SUBJECT MySubjact");
             CustomAssert.AreEqual("", result);
        }
开发者ID:digitalsoft,项目名称:hmailserver,代码行数:18,代码来源:Search.cs

示例15: TestSearchUTF8TEXT

        public void TestSearchUTF8TEXT()
        {
            Account account = SingletonProvider<TestSetup>.Instance.AddAccount(_domain, "[email protected]", "test");
             string body = TestSetup.GetResource("Messages.MessageContainingGreekSubject.txt");
             SMTPClientSimulator.StaticSendRaw(account.Address, account.Address, body);

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

             var oSimulator = new IMAPClientSimulator();
             CustomAssert.IsTrue(oSimulator.ConnectAndLogon(account.Address, "test"));
             CustomAssert.IsTrue(oSimulator.SelectFolder("INBOX"));

             string result = oSimulator.Search("CHARSET UTF-8 ALL TEXT GRΣΣK");
             CustomAssert.AreEqual("1", result);

             result = oSimulator.Search("CHARSET UTF-8 ALL TEXT 標準語");
             CustomAssert.AreEqual("1", result);

             result = oSimulator.Search("CHARSET UTF-8 ALL TEXT GRΣΣK標準語");
             CustomAssert.AreEqual("1", result);

             result = oSimulator.Search("CHARSET UTF-8 ALL TEXT GRΣΣKWHAT標準語");
             CustomAssert.AreEqual("", result);
        }
开发者ID:digitalsoft,项目名称:hmailserver,代码行数:24,代码来源:Search.cs


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