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


C# ImapClientSimulator.Connect方法代码示例

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


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

示例1: TestBatchOfCommands

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

             var oSimulator = new ImapClientSimulator();
             string sWelcomeMessage = oSimulator.Connect();
             oSimulator.Logon(account.Address, "test");

             string commandSequence = "";
             for (int i = 0; i < 200; i++)
             {
            commandSequence += "A" + i.ToString() + " SELECT INBOX\r\n";
             }
             commandSequence = commandSequence.TrimEnd("\r\n".ToCharArray());

             string result = oSimulator.Send(commandSequence);
             Assert.IsFalse(result.StartsWith("* BYE"));

             oSimulator.Disconnect();

             sWelcomeMessage = oSimulator.Connect();
             oSimulator.Logon(account.Address, "test");
             commandSequence = "";
             for (int i = 0; i < 500; i++)
             {
            commandSequence += "A" + i.ToString() + " SELECT INBOX\r\n";
             }
             commandSequence = commandSequence.TrimEnd("\r\n".ToCharArray());

             result = oSimulator.Send(commandSequence);
             Assert.IsFalse(result.StartsWith("* BYE Excessive number of buffered commands"));
             oSimulator.Disconnect();
        }
开发者ID:SpivEgin,项目名称:hmailserver,代码行数:33,代码来源:CommandSequences.cs

示例2: TestDateSortOrder

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

             string sWelcomeMessage = oSimulator.Connect();
             oSimulator.LogonWithLiteral("[email protected]", "test");
             Assert.IsTrue(oSimulator.SelectFolder("Inbox"));

             string response =
            oSimulator.SendSingleCommandWithLiteral("A04 APPEND INBOX \"22-Feb-2008 22:00:00 +0200\" {37}",
                                                    "Date: Wed, 15 Dec 2010 13:00:00 +0000");
             Assert.IsTrue(response.Contains("* 1 EXISTS"), response);

             response = oSimulator.SendSingleCommandWithLiteral("A04 APPEND INBOX \"22-Feb-2008 21:00:00 +0200\" {37}",
                                                            "Date: Wed, 15 Dec 2010 14:00:00 +0000");
             Assert.IsTrue(response.Contains("* 2 EXISTS"), response);

             response = oSimulator.SendSingleCommandWithLiteral("A04 APPEND INBOX \"22-Feb-2008 20:00:00 +0200\" {37}",
                                                            "Date: Wed, 15 Dec 2010 12:00:00 +0000");
             Assert.IsTrue(response.Contains("* 3 EXISTS"), response);

             response = oSimulator.SendSingleCommandWithLiteral("A04 APPEND INBOX \"23-Feb-2008 01:30:23 +0200\" {37}",
                                                            "Date: Wed, 15 Dec 2010 11:00:00 +0000");
             Assert.IsTrue(response.Contains("* 4 EXISTS"), response);

             string sortDateResponse = oSimulator.SendSingleCommand("A10 SORT (DATE) US-ASCII ALL");

             Assert.IsTrue(sortDateResponse.Contains(" 4 3 1 2"));
             oSimulator.Disconnect();
        }
开发者ID:SpivEgin,项目名称:hmailserver,代码行数:31,代码来源:Sort.cs

示例3: RequestingSameHeaderFieldMultipleTimesShouldReturnItOnce

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

             string message = "From: Someone <[email protected]>" + Environment.NewLine +
                          "To: Someoen <[email protected]>" + Environment.NewLine +
                          "Date: Wed, 22 Apr 2009 11:05:09 \"GMT\"" + Environment.NewLine +
                          "Subject: SubjectText" + Environment.NewLine +
                          Environment.NewLine +
                          "Hello" + Environment.NewLine;

             var smtpSimulator = new SmtpClientSimulator();
             smtpSimulator.SendRaw(account.Address, account.Address, message);

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

             var oSimulator = new ImapClientSimulator();
             string sWelcomeMessage = oSimulator.Connect();
             oSimulator.Logon(account.Address, "test");
             oSimulator.SelectFolder("INBOX");
             string result = oSimulator.Fetch("1 BODY.PEEK[HEADER.FIELDS (Subject Subject)]");
             oSimulator.Disconnect();

             Assert.AreEqual(1, StringExtensions.Occurences(result, "SubjectText"));
        }
开发者ID:SpivEgin,项目名称:hmailserver,代码行数:25,代码来源:Fetch.cs

示例4: IfInReplyToFieldContainsQuoteThenFetchHeadersShouldEncodeIt

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

             string message = "From: Someone <[email protected]>" + Environment.NewLine +
                          "To: Someoen <[email protected]>" + Environment.NewLine +
                          "In-Reply-To: ShouldBeEncodedDueToQuote\"" + Environment.NewLine +
                          "Subject: Something" + Environment.NewLine +
                          Environment.NewLine +
                          "Hello" + Environment.NewLine;

             var smtpSimulator = new SmtpClientSimulator();
             smtpSimulator.SendRaw(account.Address, account.Address, message);

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

             var oSimulator = new ImapClientSimulator();
             string sWelcomeMessage = oSimulator.Connect();
             oSimulator.Logon(account.Address, "test");
             oSimulator.SelectFolder("INBOX");
             string result = oSimulator.Fetch("1 ENVELOPE");
             oSimulator.Disconnect();

             Assert.IsFalse(result.Contains("ShouldBeEncodedDueToQuote"));
        }
开发者ID:SpivEgin,项目名称:hmailserver,代码行数:25,代码来源:Fetch.cs

示例5: TestNestedOrSearch

        public void TestNestedOrSearch()
        {
            Application application = SingletonProvider<TestSetup>.Instance.GetApp();

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

             // Send a message to this account.
             var smtpClientSimulator = new SmtpClientSimulator();
             smtpClientSimulator.Send("[email protected]", "[email protected]", "Search test", "This is a test of IMAP Search");

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

             var oSimulator = new ImapClientSimulator();
             string sWelcomeMessage = oSimulator.Connect();
             oSimulator.Logon("[email protected]", "test");
             oSimulator.SelectFolder("INBOX");

             string result =
            oSimulator.SendSingleCommand("A4 SEARCH ALL OR OR SINCE 28-May-2008 SINCE 28-May-2008 SINCE 28-May-2008");
             Assert.IsTrue(result.StartsWith("* SEARCH 1"), result);

             result = oSimulator.SendSingleCommand("A4 SEARCH ALL OR SMALLER 1 LARGER 10000");
             Assert.IsTrue(result.StartsWith("* SEARCH\r\n"), result);

             result = oSimulator.SendSingleCommand("A4 SEARCH ALL OR OR SMALLER 1 LARGER 10000 SMALLER 10000");
             Assert.IsTrue(result.StartsWith("* SEARCH 1\r\n"), result);
        }
开发者ID:hmailserver,项目名称:hmailserver,代码行数:27,代码来源:Search.cs

示例6: ExamineFolderRequiresReadPermission

        public void ExamineFolderRequiresReadPermission()
        {
            Application application = SingletonProvider<TestSetup>.Instance.GetApp();

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

             IMAPFolders publicFolders = _settings.PublicFolders;
             IMAPFolder folder = publicFolders.Add("Share1");
             folder.Save();

             IMAPFolderPermission permission = folder.Permissions.Add();
             permission.PermissionAccountID = account1.ID;
             permission.PermissionType = eACLPermissionType.ePermissionTypeUser;
             permission.set_Permission(eACLPermission.ePermissionLookup, true);
             permission.Save();

             string selectResult = string.Empty;

             var imapClientSimulator = new ImapClientSimulator();
             imapClientSimulator.Connect();
             imapClientSimulator.LogonWithLiteral(account1.Address, "test");
             string examineResult = imapClientSimulator.ExamineFolder("#Public.Share1");
             imapClientSimulator.Disconnect();

             Assert.IsTrue(examineResult.Contains("ACL: Read permission denied (Required for EXAMINE command)."),
                       examineResult);
        }
开发者ID:SpivEgin,项目名称:hmailserver,代码行数:27,代码来源:ACL.cs

示例7: FolderMarkedAsReadOnlyWhenUserHasReadOnlyRights

        public void FolderMarkedAsReadOnlyWhenUserHasReadOnlyRights()
        {
            Application application = SingletonProvider<TestSetup>.Instance.GetApp();

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

             IMAPFolders publicFolders = _settings.PublicFolders;
             IMAPFolder folder = publicFolders.Add("Share1");
             folder.Save();

             IMAPFolderPermission permission = folder.Permissions.Add();
             permission.PermissionAccountID = account1.ID;
             permission.PermissionType = eACLPermissionType.ePermissionTypeUser;
             permission.set_Permission(eACLPermission.ePermissionLookup, true);
             permission.set_Permission(eACLPermission.ePermissionRead, true);
             permission.Save();

             string selectResult = string.Empty;

             var imapClientSimulator = new ImapClientSimulator();
             imapClientSimulator.Connect();
             imapClientSimulator.LogonWithLiteral(account1.Address, "test");
             imapClientSimulator.SelectFolder("#Public.Share1", out selectResult);
             imapClientSimulator.Disconnect();

             Assert.IsTrue(selectResult.Contains("[READ-ONLY]"), selectResult);
             Assert.IsFalse(selectResult.Contains("[READ-WRITE]"), selectResult);
        }
开发者ID:SpivEgin,项目名称:hmailserver,代码行数:28,代码来源:ACL.cs

示例8: ConfirmFileAddedToCorrectAccountFolder

        public void ConfirmFileAddedToCorrectAccountFolder()
        {
            TestSetup testSetup = SingletonProvider<TestSetup>.Instance;
             Account oAccount = testSetup.AddAccount(_domain, "[email protected]", "test");
             var oSimulator = new ImapClientSimulator();

             // Confirm that the public folder is empty before we start our test.
             string publicDir = GetPublicDirectory();
             CustomAsserts.AssertFilesInDirectory(publicDir, 0);

             // Add a message to the inbox.
             oSimulator.Connect();
             oSimulator.LogonWithLiteral("[email protected]", "test");
             oSimulator.SendSingleCommandWithLiteral("A01 APPEND INBOX {4}", "ABCD");

             // Confirm it exists in the IMAP folder.
             Assert.AreEqual(1, oSimulator.GetMessageCount("INBOX"));
             oSimulator.Disconnect();

             // The public directory should still be empty - the message was added to the user account.
             CustomAsserts.AssertFilesInDirectory(publicDir, 0);

             // There should be a single file in the users directory.
             CustomAsserts.AssertFilesInUserDirectory(oAccount, 1);
        }
开发者ID:SpivEgin,项目名称:hmailserver,代码行数:25,代码来源:Append.cs

示例9: TestIMAPServerLiteral

 public void TestIMAPServerLiteral()
 {
     var sim = new ImapClientSimulator();
      sim.Connect();
      Assert.IsTrue(sim.Send("a01 login " + GetUsername() + " {4}").StartsWith("+"));
      sim.Send(GetPassword());
      EnsureNoPassword();
 }
开发者ID:SpivEgin,项目名称:hmailserver,代码行数:8,代码来源:PasswordMasking.cs

示例10: IfStartTlsNotEnabledStartTlsShouldNotBeShownInEhloResponse

        public void IfStartTlsNotEnabledStartTlsShouldNotBeShownInEhloResponse()
        {
            var imapSimulator = new ImapClientSimulator(false, 143);
             imapSimulator.Connect();
             var data = imapSimulator.GetCapabilities();

             Assert.IsFalse(data.Contains("STARTTLS"));
        }
开发者ID:SpivEgin,项目名称:hmailserver,代码行数:8,代码来源:ImapServerTests.cs

示例11: IfStlsRequiredLogonShouldFailIfNoStls

        public void IfStlsRequiredLogonShouldFailIfNoStls()
        {
            var imapSimulator = new ImapClientSimulator(false, 14303);
             imapSimulator.Connect();

             string errorMessage;
             Assert.IsFalse(imapSimulator.Logon(_account.Address, "test", out errorMessage));

             Assert.IsTrue(errorMessage.Contains("A01 BAD STARTTLS is required."));
        }
开发者ID:SpivEgin,项目名称:hmailserver,代码行数:10,代码来源:ImapServerTests.cs

示例12: TestCreateFolderWithHash

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

             var oSimulator = new ImapClientSimulator();

             oSimulator.Connect();
             oSimulator.Logon(oAccount.Address, "test");
             Assert.IsFalse(oSimulator.CreateFolder("#Test"));
             Assert.IsTrue(oSimulator.CreateFolder("Test.#Testar"));
             oSimulator.Disconnect();
        }
开发者ID:SpivEgin,项目名称:hmailserver,代码行数:12,代码来源:Folders.cs

示例13: TestAppendBadLiteral

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

             var oSimulator = new ImapClientSimulator();

             string sWelcomeMessage = oSimulator.Connect();
             oSimulator.LogonWithLiteral("[email protected]", "test");
             oSimulator.SendSingleCommandWithLiteral("A01 APPEND INBOX {TEST}", "ABCD");
             Assert.AreEqual(0, oSimulator.GetMessageCount("INBOX"));
             oSimulator.Disconnect();
        }
开发者ID:baa-archieve,项目名称:hmailserver,代码行数:12,代码来源:Basics.cs

示例14: IfStlsRequiredLogonShouldSucceedIfStls

        public void IfStlsRequiredLogonShouldSucceedIfStls()
        {
            var imapSimulator = new ImapClientSimulator(false, 14303);
             imapSimulator.Connect();
             imapSimulator.SendSingleCommand("A01 STARTTLS");
             imapSimulator.Handshake();

             // command is sent over TLS.
             imapSimulator.GetCapabilities();

             Assert.IsTrue(imapSimulator.Logon(_account.Address, "test"));
        }
开发者ID:SpivEgin,项目名称:hmailserver,代码行数:12,代码来源:ImapServerTests.cs

示例15: IfStlsOptionalButSslRequiredByIpRangeForAuthThenAuthShouldFail

        public void IfStlsOptionalButSslRequiredByIpRangeForAuthThenAuthShouldFail()
        {
            var range = SingletonProvider<TestSetup>.Instance.GetApp().Settings.SecurityRanges.get_ItemByName("My computer");
             range.RequireSSLTLSForAuth = true;
             range.Save();

             var imapSimulator = new ImapClientSimulator(false, 14302);
             imapSimulator.Connect();

             string errorMessage;
             Assert.IsFalse(imapSimulator.Logon(_account.Address, "test", out errorMessage));
             Assert.IsTrue(errorMessage.Contains("A01 BAD A SSL/TLS-connection is required for authentication."));
        }
开发者ID:SpivEgin,项目名称:hmailserver,代码行数:13,代码来源:ImapServerTests.cs


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