本文整理汇总了C#中IMAPSimulator.SendSingleCommand方法的典型用法代码示例。如果您正苦于以下问题:C# IMAPSimulator.SendSingleCommand方法的具体用法?C# IMAPSimulator.SendSingleCommand怎么用?C# IMAPSimulator.SendSingleCommand使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IMAPSimulator
的用法示例。
在下文中一共展示了IMAPSimulator.SendSingleCommand方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestDateSortOrderNonexistantDate
public void TestDateSortOrderNonexistantDate()
{
hMailServer.Account oAccount = SingletonProvider<Utilities>.Instance.AddAccount(_domain, "[email protected]", "test");
IMAPSimulator oSimulator = new IMAPSimulator();
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();
}
示例2: TestNestedOrSearch
public void TestNestedOrSearch()
{
hMailServer.Application application = SingletonProvider<Utilities>.Instance.GetApp();
;
hMailServer.Account oAccount = SingletonProvider<Utilities>.Instance.AddAccount(_domain, "[email protected]", "test");
// Send a message to this account.
SMTPClientSimulator oSMTP = new SMTPClientSimulator();
oSMTP.Send("[email protected]", "[email protected]", "Search test", "This is a test of IMAP Search");
IMAPSimulator.AssertMessageCount(oAccount.Address, "test", "Inbox", 1);
IMAPSimulator oSimulator = new IMAPSimulator();
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);
}
示例3: TestDateSortOrder
public void TestDateSortOrder()
{
hMailServer.Account oAccount = SingletonProvider<Utilities>.Instance.AddAccount(_domain, "[email protected]", "test");
IMAPSimulator oSimulator = new IMAPSimulator();
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();
}
示例4: TestSearchUID
public void TestSearchUID()
{
hMailServer.Application application = SingletonProvider<Utilities>.Instance.GetApp();
;
hMailServer.Account account = SingletonProvider<Utilities>.Instance.AddAccount(_domain, "[email protected]", "test");
// Send a message to this account.
SMTPClientSimulator oSMTP = new SMTPClientSimulator();
for (int i = 0; i < 3; i++)
oSMTP.Send("[email protected]", "[email protected]", "Test1", "This is a test of IMAP Search");
IMAPSimulator.AssertMessageCount("[email protected]", "test", "INBOX", 3);
// There should be 3 UID's, 1,2,3 or similar. No skips in the middle fo them.
IMAPSimulator oSimulator = new IMAPSimulator();
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 = Microsoft.VisualBasic.Strings.Split(result, " ", -1, Microsoft.VisualBasic.CompareMethod.Text);
List<int> 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]);
}
示例5: TestSearchRange
public void TestSearchRange()
{
hMailServer.Application application = SingletonProvider<Utilities>.Instance.GetApp();
;
hMailServer.Account oAccount = SingletonProvider<Utilities>.Instance.AddAccount(_domain, "[email protected]", "test");
// Send a message to this account.
SMTPClientSimulator oSMTP = new SMTPClientSimulator();
for (int i = 0; i <5 ; i++)
oSMTP.Send("[email protected]", "[email protected]", "Test1", "This is a test of IMAP Search");
IMAPSimulator.AssertMessageCount("[email protected]", "test", "INBOX", 5);
IMAPSimulator oSimulator = new IMAPSimulator();
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"));
}
示例6: TestSearchInvalidCharset
public void TestSearchInvalidCharset()
{
hMailServer.Account account = SingletonProvider<Utilities>.Instance.AddAccount(_domain, "[email protected]", "test");
SMTPClientSimulator.StaticSend(account.Address, account.Address, "MySubject", "MyBody");
POP3Simulator.AssertMessageCount(account.Address, "test", 1);
IMAPSimulator oSimulator = new IMAPSimulator();
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);
}
示例7: TestSearchSpecficUID
public void TestSearchSpecficUID()
{
hMailServer.Application application = SingletonProvider<Utilities>.Instance.GetApp();
hMailServer.Account oAccount = SingletonProvider<Utilities>.Instance.AddAccount(_domain, "[email protected]", "test");
// Send a message to this account.
SMTPClientSimulator oSMTP = new SMTPClientSimulator();
for (int i = 0; i < 5; i++)
oSMTP.Send("[email protected]", "[email protected]", "Test1", "This is a test of IMAP Search");
IMAPSimulator.AssertMessageCount("[email protected]", "test", "INBOX", 5);
hMailServer.Messages messages = oAccount.IMAPFolders.get_ItemByName("Inbox").Messages;
int second = messages[1].UID;
int third = messages[2].UID;
int fourth = messages[3].UID;
IMAPSimulator oSimulator = new IMAPSimulator();
string sWelcomeMessage = 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));
Assert.IsTrue(result.StartsWith("* SORT 3 2"));
result = oSimulator.SendSingleCommand(string.Format("a01 SORT (DATE) UTF-8 ALL UID {0},{1}", third, second));
Assert.IsTrue(result.StartsWith("* SORT 2 3"));
result = oSimulator.SendSingleCommand(string.Format("a01 SORT (DATE) UTF-8 ALL UID {0}:{1}", second, fourth));
Assert.IsTrue(result.StartsWith("* SORT 2 3 4"));
result = oSimulator.SendSingleCommand(string.Format("a01 SORT (DATE) UTF-8 ALL UID {0}:*", second));
Assert.IsTrue(result.StartsWith("* SORT 2 3 4 5"));
}
示例8: TestAuthenticate
public void TestAuthenticate()
{
hMailServer.Account oAccount = SingletonProvider<Utilities>.Instance.AddAccount(_domain, "[email protected]", "test");
IMAPSimulator oSimulator = new IMAPSimulator();
string sWelcomeMessage = oSimulator.Connect();
string result = oSimulator.SendSingleCommand("A01 AUTHENTICATE");
Assert.IsTrue(result.Contains("NO Unsupported authentication mechanism."));
oSimulator.Disconnect();
}
示例9: TestUnseenResponseInSelect
public void TestUnseenResponseInSelect()
{
hMailServer.Account account = SingletonProvider<Utilities>.Instance.AddAccount(_domain, "[email protected]", "test");
SMTPClientSimulator.StaticSend(account.Address, account.Address, "Test", "TestMessage");
IMAPSimulator.AssertMessageCount(account.Address, "test", "Inbox", 1);
IMAPSimulator sim = new IMAPSimulator();
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);
}
示例10: TestRecentRemovedOnMailboxClose
public void TestRecentRemovedOnMailboxClose()
{
hMailServer.Account account = SingletonProvider<Utilities>.Instance.AddAccount(_domain, "[email protected]", "test");
SMTPClientSimulator.StaticSend(account.Address, account.Address, "Test", "TestMessage");
IMAPSimulator.AssertMessageCount(account.Address, "test", "Inbox", 1);
IMAPSimulator sim = new IMAPSimulator();
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 IMAPSimulator();
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());
}