本文整理汇总了C#中RegressionTests.Shared.ImapClientSimulator.Fetch方法的典型用法代码示例。如果您正苦于以下问题:C# ImapClientSimulator.Fetch方法的具体用法?C# ImapClientSimulator.Fetch怎么用?C# ImapClientSimulator.Fetch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RegressionTests.Shared.ImapClientSimulator
的用法示例。
在下文中一共展示了ImapClientSimulator.Fetch方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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"));
}
示例2: TestChangeSeenFlag
public void TestChangeSeenFlag()
{
Account oAccount = SingletonProvider<TestSetup>.Instance.AddAccount(_domain, "[email protected]", "test");
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();
Assert.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();
Assert.AreNotEqual(secondFlags, secondFlagsAfter);
}
示例3: 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"));
}
示例4: 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);
}
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);
}
示例5: TestParseMultipartNoBody
public void TestParseMultipartNoBody()
{
Account account = SingletonProvider<TestSetup>.Instance.AddAccount(_domain, "[email protected]", "test");
string body = TestSetup.GetResource("Messages.MultipartMessageWithNoMainBodyText.txt");
SmtpClientSimulator.StaticSendRaw(account.Address, account.Address, body);
Pop3ClientSimulator.AssertMessageCount(account.Address, "test", 1);
var imapSim = new ImapClientSimulator("[email protected]", "test", "INBOX");
string result = imapSim.Fetch("1 (BODY.PEEK[HEADER] BODY.PEEK[TEXT])");
imapSim.Logout();
}
示例6: TestFetchCharsetInQuotesWithoutSpace
public void TestFetchCharsetInQuotesWithoutSpace()
{
Account account = SingletonProvider<TestSetup>.Instance.AddAccount(_domain, "[email protected]", "test");
SmtpClientSimulator.StaticSendRaw(account.Address, account.Address,
"From: [email protected]\r\n" +
"Content-Type: text/plain; charset =\"iso-8859-1\"\r\n" +
"\r\n" +
"Test\r\n");
ImapClientSimulator.AssertMessageCount(account.Address, "test", "Inbox", 1);
var sim = new ImapClientSimulator(account.Address, "test", "Inbox");
string result = sim.Fetch("1 BODYSTRUCTURE");
sim.Disconnect();
Assert.IsTrue(result.Contains("(\"CHARSET\" \"iso-8859-1\")"), result);
}
示例7: TestBeforeLogon
public void TestBeforeLogon()
{
Account oAccount = SingletonProvider<TestSetup>.Instance.AddAccount(_domain, "[email protected]", "test");
var oSimulator = new ImapClientSimulator();
string sWelcomeMessage = oSimulator.Connect();
Assert.IsTrue(oSimulator.ExamineFolder("NonexistantFolder").Contains("NO Authenticate first"));
Assert.IsFalse(oSimulator.SelectFolder("NonexistantFolder"));
Assert.IsFalse(oSimulator.Copy(1, "SomeFolder"));
Assert.IsFalse(oSimulator.CheckFolder("SomeFolder"));
Assert.IsTrue(oSimulator.Fetch("123 a").Contains("NO Authenticate first"));
Assert.IsTrue(oSimulator.List().Contains("NO Authenticate first"));
Assert.IsTrue(oSimulator.LSUB().Contains("NO Authenticate first"));
Assert.IsTrue(oSimulator.GetMyRights("APA").Contains("NO Authenticate first"));
Assert.IsFalse(oSimulator.RenameFolder("A", "B"));
Assert.IsFalse(oSimulator.Status("SomeFolder", "MESSAGES").Contains("A01 OK"));
}
示例8: 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);
}
示例9: 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();
CustomAsserts.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:
Assert.IsTrue(result.Contains("=?utf-8?B?5pys5pys5pys?=.zip"));
}
示例10: TestFetchInvalid
public void TestFetchInvalid()
{
Account account = SingletonProvider<TestSetup>.Instance.AddAccount(_domain, "[email protected]", "test");
SmtpClientSimulator.StaticSend(account.Address, account.Address, "Test", "SampleBody1");
SmtpClientSimulator.StaticSend(account.Address, account.Address, "Test", "SampleBody2");
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("0 BODY[1]");
Assert.IsTrue(result.StartsWith("A17 OK FETCH completed"));
result = sim.Fetch("-1 BODY[1]");
Assert.IsTrue(result.StartsWith("A17 BAD"));
result = sim.Fetch("-100 BODY[1]");
Assert.IsTrue(result.StartsWith("A17 BAD"));
}
示例11: TestBodyStructureWithNonLatinCharacterSingleLineWithSpace
public void TestBodyStructureWithNonLatinCharacterSingleLineWithSpace()
{
string @messageText =
"Return-Path: [email protected]\r\n" +
"Delivered-To: [email protected]\r\n" +
"Received: from www.hmailserver.com ([127.0.0.1])\r\n" +
" by mail.hmailserver.com\r\n" +
" ; Tue, 16 Jun 2009 21:39:18 +0200\r\n" +
"MIME-Version: 1.0\r\n" +
"Date: Tue, 16 Jun 2009 21:39:18 +0200\r\n" +
"From: <[email protected]>\r\n" +
"To: <[email protected]>\r\n" +
"Subject: sdafsda\r\n" +
"Message-ID: <[email protected]>\r\n" +
"X-Sender: [email protected]\r\n" +
"User-Agent: RoundCube Webmail/0.2.2\r\n" +
"Content-Type: multipart/mixed;\r\n" +
" boundary=\"=_b63968892a76b1a5be17f4d37b085f54\"\r\n" +
"\r\n" +
"--=_b63968892a76b1a5be17f4d37b085f54\r\n" +
"Content-Transfer-Encoding: 8bit\r\n" +
"Content-Type: text/plain; charset=\"UTF-8\"\r\n" +
"\r\n" +
"--=_b63968892a76b1a5be17f4d37b085f54\r\n" +
"Content-Transfer-Encoding: base64\r\n" +
"Content-Type: application/x-zip; charset=\"UTF-8\";\r\n" +
" name*=\"UTF-8''m%C3%A4%C3%B6 m%C3%A4%C3%B6.zip\"; \r\n" +
"Content-Disposition: attachment;\r\n" +
" filename*=\"UTF-8''m%C3%A4%C3%B6 m%C3%A4%C3%B6.zip\"; \r\n" +
"\r\n" +
"iVBORw0KGgoAAAANSUhEUgAAAqgAAAH4CAIAAAAJvIhhAAAAAXNSR0IArs4c6QAAAARnQU1BAACx\r\n" +
"jwv8YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAIr1JREFU\r\n" +
"eF7t29GSYzluBND1/3/0ejb6wY6emK2WrpQEkaefdQvAAcn02OH/+fe///0v/wgQIECAAIESgb+C\r\n" +
"3z8CBAgQIECgROBfJXMakwABAgQIEPjP/5qfAgECBAgQINAjIPh7dm1SAgQIECDgv/idAQIECBAg\r\n" +
"--=_b63968892a76b1a5be17f4d37b085f54--\r\n" +
"";
Account account = SingletonProvider<TestSetup>.Instance.AddAccount(_domain, "[email protected]", "test");
SmtpClientSimulator.StaticSendRaw(account.Address, account.Address, messageText);
CustomAsserts.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();
Assert.IsFalse(result.Contains("''"), result);
Assert.IsTrue(result.Contains("\"FILENAME\" \"=?UTF-8?Q?m=C3=A4=C3=B6 m=C3=A4=C3=B6.zip?=\""), result);
Assert.IsTrue(result.Contains("\"NAME\" \"=?UTF-8?Q?m=C3=A4=C3=B6 m=C3=A4=C3=B6.zip?=\""), result);
}
示例12: TestFetchEnvelopeWithDateContainingQuote
public void TestFetchEnvelopeWithDateContainingQuote()
{
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: 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.IsTrue(result.Contains("Wed, 22 Apr 2009 11:05:09 GMT"));
}
示例13: TestFetchBody
public void TestFetchBody()
{
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();
CustomAsserts.AssertFolderMessageCount(account.IMAPFolders[0], 1);
var oSimulator = new ImapClientSimulator();
oSimulator.ConnectAndLogon(account.Address, "test");
oSimulator.SelectFolder("INBOX");
string bodyStructureResponse = oSimulator.Fetch("1 BODYSTRUCTURE");
string bodyResponse = oSimulator.Fetch("1 BODY");
oSimulator.Disconnect();
Assert.IsTrue(bodyStructureResponse.Contains("BOUNDARY"));
Assert.IsFalse(bodyResponse.Contains("BOUNDARY"));
}
示例14: 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]");
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);
}
示例15: 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");
SmtpClientSimulator.StaticSendRaw(account.Address, account.Address, messageText);
CustomAsserts.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();
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);
}