當前位置: 首頁>>代碼示例>>C#>>正文


C# Header.SetValue方法代碼示例

本文整理匯總了C#中MimeKit.Header.SetValue方法的典型用法代碼示例。如果您正苦於以下問題:C# Header.SetValue方法的具體用法?C# Header.SetValue怎麽用?C# Header.SetValue使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在MimeKit.Header的用法示例。


在下文中一共展示了Header.SetValue方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: TestReceivedHeaderFolding

		public void TestReceivedHeaderFolding ()
		{
			var header = new Header ("Received", "");

			foreach (var received in ReceivedHeaderValues) {
				header.SetValue (Encoding.ASCII, received.Replace (FormatOptions.Default.NewLine + "\t", " ").Trim ());

				var raw = ByteArrayToString (header.RawValue);

				Assert.IsTrue (raw[raw.Length - 1] == '\n', "The RawValue does not end with a new line.");

				Assert.AreEqual (received + FormatOptions.Default.NewLine, raw, "The folded Received header does not match the expected value.");
			}
		}
開發者ID:AldeaAlexandra,項目名稱:MimeKit,代碼行數:14,代碼來源:HeaderTests.cs

示例2: TestArgumentExceptions

		public void TestArgumentExceptions  ()
		{
			var header = new Header ("utf-8", HeaderId.Subject, "This is a subject...");

			Assert.Throws<ArgumentOutOfRangeException> (() => new Header (HeaderId.Unknown, "value"));
			Assert.Throws<ArgumentNullException> (() => new Header (HeaderId.Subject, null));
			Assert.Throws<ArgumentNullException> (() => new Header (null, "value"));
			Assert.Throws<ArgumentException> (() => new Header (string.Empty, "value"));
			Assert.Throws<ArgumentNullException> (() => new Header ("field", null));
			Assert.Throws<ArgumentNullException> (() => new Header ((Encoding) null, HeaderId.Subject, "value"));
			Assert.Throws<ArgumentOutOfRangeException> (() => new Header (Encoding.UTF8, HeaderId.Unknown, "value"));
			Assert.Throws<ArgumentNullException> (() => new Header (Encoding.UTF8, HeaderId.Subject, null));
			Assert.Throws<ArgumentNullException> (() => new Header ((string) null, "field", "value"));
			Assert.Throws<ArgumentNullException> (() => new Header ("utf-8", null, "value"));
			Assert.Throws<ArgumentException> (() => new Header ("utf-8", string.Empty, "value"));
			Assert.Throws<ArgumentNullException> (() => new Header ("utf-8", "field", null));
			Assert.Throws<ArgumentNullException> (() => new Header ((Encoding) null, "field", "value"));
			Assert.Throws<ArgumentNullException> (() => new Header (Encoding.UTF8, null, "value"));
			Assert.Throws<ArgumentException> (() => new Header (Encoding.UTF8, string.Empty, "value"));
			Assert.Throws<ArgumentNullException> (() => new Header (Encoding.UTF8, "field", null));
			Assert.Throws<ArgumentNullException> (() => new Header ((string) null, HeaderId.Subject, "value"));
			Assert.Throws<ArgumentOutOfRangeException> (() => new Header ("utf-8", HeaderId.Unknown, "value"));
			Assert.Throws<ArgumentNullException> (() => new Header ("utf-8", HeaderId.Subject, null));

			// GetValue
			Assert.Throws<ArgumentNullException> (() => header.GetValue ((Encoding) null));
			Assert.Throws<ArgumentNullException> (() => header.GetValue ((string) null));

			// SetValue
			Assert.Throws<ArgumentNullException> (() => header.SetValue (null, Encoding.UTF8, "value"));
			Assert.Throws<ArgumentNullException> (() => header.SetValue (FormatOptions.Default, (Encoding) null, "value"));
			Assert.Throws<ArgumentNullException> (() => header.SetValue (FormatOptions.Default, Encoding.UTF8, null));
			Assert.Throws<ArgumentNullException> (() => header.SetValue (null, "utf-8", "value"));
			Assert.Throws<ArgumentNullException> (() => header.SetValue (FormatOptions.Default, (string) null, "value"));
			Assert.Throws<ArgumentNullException> (() => header.SetValue (FormatOptions.Default, "utf-8", null));
			Assert.Throws<ArgumentNullException> (() => header.SetValue ((Encoding) null, "value"));
			Assert.Throws<ArgumentNullException> (() => header.SetValue (Encoding.UTF8, null));
			Assert.Throws<ArgumentNullException> (() => header.SetValue ((string) null, "value"));
			Assert.Throws<ArgumentNullException> (() => header.SetValue ("utf-8", null));
		}
開發者ID:cybercircuits,項目名稱:MimeKit,代碼行數:40,代碼來源:HeaderTests.cs


注:本文中的MimeKit.Header.SetValue方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。