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


C# ImapClientSimulator.SendSingleCommand方法代码示例

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


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

示例1: 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

示例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: 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

示例4: TestAuthenticate

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

             var oSimulator = new ImapClientSimulator();

             string sWelcomeMessage = oSimulator.Connect();
             string result = oSimulator.SendSingleCommand("A01 AUTHENTICATE");
             Assert.IsTrue(result.Contains("NO Unsupported authentication mechanism."));
             oSimulator.Disconnect();
        }
开发者ID:baa-archieve,项目名称:hmailserver,代码行数:11,代码来源:Basics.cs

示例5: 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

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

示例7: TestDateSortOrderNonexistantDate

        public void TestDateSortOrderNonexistantDate()
        {
            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\" {4}", "ABCD");
             Assert.IsTrue(response.Contains("* 1 EXISTS"), response);

             response = oSimulator.SendSingleCommandWithLiteral("A04 APPEND INBOX \"22-Feb-2008 21:00:00 +0200\" {4}",
                                                            "ABCD");
             Assert.IsTrue(response.Contains("* 2 EXISTS"), response);

             response = oSimulator.SendSingleCommandWithLiteral("A04 APPEND INBOX \"22-Feb-2008 20:00:00 +0200\" {4}",
                                                            "ABCD");
             Assert.IsTrue(response.Contains("* 3 EXISTS"), response);

             response = oSimulator.SendSingleCommandWithLiteral("A04 APPEND INBOX \"23-Feb-2008 01:30:23 +0200\" {4}",
                                                            "ABCD");
             Assert.IsTrue(response.Contains("* 4 EXISTS"), response);

             /*
              * RFC 5256 "2.2. Sent Date" chapter. If the sent date cannot be determined (a Date: header is missing or cannot be parsed),
              * the INTERNALDATE for that message is used as the sent date.
              */

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

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

示例8: TestSearchSpecficUID

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

             // Send a message to this account.
             var smtpClientSimulator = new SmtpClientSimulator();
             for (int i = 0; i < 5; i++)
            smtpClientSimulator.Send("[email protected]", "[email protected]", "Test1", "This is a test of IMAP Search");

             ImapClientSimulator.AssertMessageCount("[email protected]", "test", "INBOX", 5);

             Messages messages = oAccount.IMAPFolders.get_ItemByName("Inbox").Messages;

             int second = messages[1].UID;
             int third = messages[2].UID;
             int fourth = messages[3].UID;

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

             string result = oSimulator.SendSingleCommand(string.Format("a01 SORT (REVERSE DATE) UTF-8 ALL UID {0},{1}", second, third));
             AssertSortResultContains(result, 2, 3);

             result = oSimulator.SendSingleCommand(string.Format("a01 SORT (DATE) UTF-8 ALL UID {0},{1}", third, second));
             AssertSortResultContains(result, 2, 3);

             result = oSimulator.SendSingleCommand(string.Format("a01 SORT (DATE) UTF-8 ALL UID {0}:{1}", second, fourth));
             AssertSortResultContains(result, 2, 3, 4);

             result = oSimulator.SendSingleCommand(string.Format("a01 SORT (DATE) UTF-8 ALL UID {0}:*", second));
             AssertSortResultContains(result, 2, 3, 4, 5);
        }
开发者ID:SpivEgin,项目名称:hmailserver,代码行数:34,代码来源:Sort.cs

示例9: TestSearchUID

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

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

             // Send a message to this account.
             var smtpClientSimulator = new SmtpClientSimulator();
             for (int i = 0; i < 3; i++)
            smtpClientSimulator.Send("[email protected]", "[email protected]", "Test1", "This is a test of IMAP Search");

             ImapClientSimulator.AssertMessageCount("[email protected]", "test", "INBOX", 3);

             // There should be 3 UID's, 1,2,3 or similar. No skips in the middle fo them.
             var oSimulator = new ImapClientSimulator();
             string sWelcomeMessage = oSimulator.Connect();
             oSimulator.Logon("[email protected]", "test");
             Assert.IsTrue(oSimulator.SelectFolder("INBOX"));

             string result = oSimulator.SendSingleCommand("* UID SEARCH UID 1:*");

             // Potentially, the response is multiline. (UID RESPONSE and an OK line). We only want the first line...
             result = result.Substring(0, result.IndexOf("\r\n"));

             string[] tokens = Strings.Split(result, " ", -1, CompareMethod.Text);

             var uids = new List<int>();
             foreach (string token in tokens)
             {
            int temp;
            if (Int32.TryParse(token, out temp))
            {
               uids.Add(temp);
            }
             }

             Assert.AreEqual(3, uids.Count, result);

             Assert.AreEqual(1, uids[0]);
             Assert.AreEqual(2, uids[1]);
             Assert.AreEqual(3, uids[2]);
        }
开发者ID:hmailserver,项目名称:hmailserver,代码行数:42,代码来源:Search.cs

示例10: TestSearchRange

        public void TestSearchRange()
        {
            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();
             for (int i = 0; i < 5; i++)
            smtpClientSimulator.Send("[email protected]", "[email protected]", "Test1", "This is a test of IMAP Search");

             ImapClientSimulator.AssertMessageCount("[email protected]", "test", "INBOX", 5);

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

             string result = oSimulator.SendSingleCommand("a01 search 2:4");
             Assert.IsTrue(result.StartsWith("* SEARCH 2 3 4"));

             result = oSimulator.SendSingleCommand("a01 search 3,2");
             Assert.IsTrue(result.StartsWith("* SEARCH 2 3"));

             result = oSimulator.SendSingleCommand("a01 search 3:*");
             Assert.IsTrue(result.StartsWith("* SEARCH 3 4 5"));

             result = oSimulator.SendSingleCommand("a01 search 3,1,3");
             Assert.IsTrue(result.StartsWith("* SEARCH 1 3"));

             result = oSimulator.SendSingleCommand("a01 search 1:*");
             Assert.IsTrue(result.StartsWith("* SEARCH 1 2 3 4 5"));
        }
开发者ID:hmailserver,项目名称:hmailserver,代码行数:33,代码来源:Search.cs

示例11: TestSearchInvalidCharset

        public void TestSearchInvalidCharset()
        {
            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();
             Assert.IsTrue(oSimulator.ConnectAndLogon(account.Address, "test"));
             Assert.IsTrue(oSimulator.SelectFolder("INBOX"));

             string result = oSimulator.SendSingleCommand("A01 SEARCH CHARSET NONEXISTANT ALL SUBJECT MySubject");
             Assert.AreEqual("A01 NO [BADCHARSET]\r\n", result);
        }
开发者ID:hmailserver,项目名称:hmailserver,代码行数:15,代码来源:Search.cs

示例12: StlsCommandShouldSwithToTls

        public void StlsCommandShouldSwithToTls()
        {
            var imapSimulator = new ImapClientSimulator(false, 14302);
             imapSimulator.Connect();
             var data = imapSimulator.GetCapabilities();
             imapSimulator.SendSingleCommand("A01 STARTTLS");
             imapSimulator.Handshake();

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

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


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