本文整理汇总了C#中RegressionTests.Shared.SmtpClientSimulator.SendRaw方法的典型用法代码示例。如果您正苦于以下问题:C# SmtpClientSimulator.SendRaw方法的具体用法?C# SmtpClientSimulator.SendRaw怎么用?C# SmtpClientSimulator.SendRaw使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RegressionTests.Shared.SmtpClientSimulator
的用法示例。
在下文中一共展示了SmtpClientSimulator.SendRaw方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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"));
}
示例2: 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"));
}
示例3: StaticSendRaw
public static void StaticSendRaw(string sFrom, string recipient, string sBody)
{
var oSimulator = new SmtpClientSimulator();
oSimulator.SendRaw(sFrom, recipient, sBody);
}
示例4: TestFetchHeaderFieldsNot
public void TestFetchHeaderFieldsNot()
{
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 BODY.PEEK[HEADER.FIELDS.NOT (Subject From)]");
oSimulator.Disconnect();
Assert.IsTrue(result.Contains("Received:"), result);
Assert.IsFalse(result.Contains("Subject:"), result);
Assert.IsFalse(result.Contains("From:"), result);
// The feedback should end with an empty header line.
Assert.IsTrue(result.Contains("\r\n\r\n)"), result);
}
示例5: 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"));
}
示例6: CriteriaContainsHTMLBody
public void CriteriaContainsHTMLBody()
{
// Add an account
Account account = SingletonProvider<TestSetup>.Instance.AddAccount(_domain, "[email protected]", "test");
Rule oRule = account.Rules.Add();
oRule.Name = "Criteria test";
oRule.Active = true;
RuleCriteria oRuleCriteria = oRule.Criterias.Add();
oRuleCriteria.UsePredefined = true;
oRuleCriteria.PredefinedField = eRulePredefinedField.eFTBody;
oRuleCriteria.MatchType = eRuleMatchType.eMTContains;
oRuleCriteria.MatchValue = "MyHTMLBody";
oRuleCriteria.Save();
// Add action
RuleAction oRuleAction = oRule.Actions.Add();
oRuleAction.Type = eRuleActionType.eRAMoveToImapFolder;
oRuleAction.IMAPFolder = "INBOX.Wildcard";
oRuleAction.Save();
// Save the rule in the database
oRule.Save();
var smtpClientSimulator = new SmtpClientSimulator();
string message = "From: Someone <[email protected]>" + Environment.NewLine +
"Content-Type: text/html; charset=\"Windows-1251\"" + Environment.NewLine +
"Content-Transfer-Encoding: quoted-printable" + Environment.NewLine +
Environment.NewLine +
"<HTML><Center>MyHTMLBody</Center></HTML>" + Environment.NewLine;
smtpClientSimulator.SendRaw("[email protected]", account.Address, message);
// The message should be placed in the Wildcard folder, since the HTML body of the message contains MyHTMLBody.
ImapClientSimulator.AssertMessageCount(account.Address, "test", "Inbox.Wildcard", 1);
ImapClientSimulator.AssertMessageCount(account.Address, "test", "Inbox", 0);
}
示例7: TestOverlappingBoundaryNames
public void TestOverlappingBoundaryNames()
{
string content = "Return-Path: <[email protected]>\r\n" +
"From: \"test\" <[email protected]>\r\n" +
"To: \"Test\" <[email protected]>\r\n" +
"Subject: rtest\r\n" +
"Date: Thu, 22 Jan 2009 13:20:32 +0100\r\n" +
"MIME-Version: 1.0\r\n" +
"Content-Type: multipart/mixed;\r\n" +
" boundary=\"----=_NextPart_000_000D_01C97C94.33D5E670\"\r\n" +
"\r\n" +
"This is a multi-part message in MIME format.\r\n" +
"\r\n" +
"------=_NextPart_000_000D_01C97C94.33D5E670\r\n" +
"Content-Type: multipart/alternative;\r\n" +
" boundary=\"----=_NextPart_000_000D_01C97C94.33D5E670.ALT\"\r\n" +
"\r\n" +
"\r\n" +
"------=_NextPart_000_000D_01C97C94.33D5E670.ALT\r\n" +
"Content-Type: text/plain;\r\n" +
" charset=\"iso-8859-1\"\r\n" +
"Content-Transfer-Encoding: quoted-printable\r\n" +
"\r\n" +
"test\r\n" +
"------=_NextPart_000_000D_01C97C94.33D5E670.ALT\r\n" +
"Content-Type: text/html;\r\n" +
" charset=\"iso-8859-1\"\r\n" +
"Content-Transfer-Encoding: quoted-printable\r\n" +
"\r\n" +
"<a>test</a>\r\n" +
"\r\n" +
"------=_NextPart_000_000D_01C97C94.33D5E670.ALT--\r\n" +
"\r\n" +
"------=_NextPart_000_000D_01C97C94.33D5E670\r\n" +
"Content-Type: application/octet-stream;\r\n" +
" name=\"test.vbs\"\r\n" +
"Content-Transfer-Encoding: 7bit\r\n" +
"Content-Disposition: attachment;\r\n" +
" filename=\"test.vbs\"\r\n" +
"\r\n" +
"s = \"abc\"\r\n" +
"\r\n" +
"msgbox mid(s,1,100000)\r\n" +
"------=_NextPart_000_000D_01C97C94.33D5E670--\r\n" +
"\r\n" +
"";
// Add an account
Account oAccount = SingletonProvider<TestSetup>.Instance.AddAccount(_domain, "[email protected]", "test");
Rule oRule = oAccount.Rules.Add();
oRule.Name = "Criteria test";
oRule.Active = true;
RuleCriteria oRuleCriteria = oRule.Criterias.Add();
oRuleCriteria.UsePredefined = false;
oRuleCriteria.HeaderField = "Subject";
oRuleCriteria.MatchType = eRuleMatchType.eMTContains;
oRuleCriteria.MatchValue = "rtest";
oRuleCriteria.Save();
// Add action
RuleAction oRuleAction = oRule.Actions.Add();
oRuleAction.Type = eRuleActionType.eRASetHeaderValue;
oRuleAction.HeaderName = "SomeHeader";
oRuleAction.Value = "SomeValue";
oRuleAction.Save();
// Save the rule in the database
oRule.Save();
var smtpClientSimulator = new SmtpClientSimulator();
// Spam folder
smtpClientSimulator.SendRaw("[email protected]", "[email protected]", content);
string sContents = Pop3ClientSimulator.AssertGetFirstMessageText("[email protected]", "test");
Assert.IsTrue(sContents.IndexOf("SomeHeader: SomeValue") > 0);
Assert.IsTrue(sContents.IndexOf("------=_NextPart_000_000D_01C97C94.33D5E670.ALT--") > 0);
}
示例8: TestLongLineInData
public void TestLongLineInData()
{
Account account = SingletonProvider<TestSetup>.Instance.AddAccount(_domain, "[email protected]", "test");
var sb = new StringBuilder();
for (int i = 0; i < 11000; i++)
{
sb.Append("1234567890");
}
var sim = new SmtpClientSimulator();
CustomAsserts.Throws<DeliveryFailedException>(() => sim.SendRaw("[email protected]", "[email protected]", sb.ToString()));
}