本文整理汇总了C#中System.Net.Http.MultipartFormDataContent.First方法的典型用法代码示例。如果您正苦于以下问题:C# MultipartFormDataContent.First方法的具体用法?C# MultipartFormDataContent.First怎么用?C# MultipartFormDataContent.First使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Net.Http.MultipartFormDataContent
的用法示例。
在下文中一共展示了MultipartFormDataContent.First方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Add_2
public void Add_2()
{
var m = new MultipartFormDataContent ("b");
var other = new MultipartFormDataContent ("44");
m.Add (other, "name", "fname");
Assert.AreEqual ("multipart/form-data", m.Headers.ContentType.MediaType, "#1");
Assert.AreEqual (165, m.Headers.ContentLength, "#2");
Assert.AreEqual ("--b\r\nContent-Type: multipart/form-data; boundary=\"44\"\r\nContent-Disposition: form-data; name=name; filename=fname; filename*=utf-8''fname\r\n\r\n--44\r\n\r\n--44--\r\n\r\n--b--\r\n", m.ReadAsStringAsync ().Result, "#3");
Assert.AreEqual (other, m.First (), "#4");
Assert.IsNull (m.Headers.ContentDisposition, "#5");
Assert.AreEqual ("form-data; name=name; filename=fname; filename*=utf-8''fname", other.Headers.ContentDisposition.ToString (), "#6");
}
示例2: Add
public void Add()
{
var m = new MultipartFormDataContent ("b");
var other = new MultipartFormDataContent ("44");
other.Headers.Expires = new DateTimeOffset (2020, 11, 30, 19, 55, 22, TimeSpan.Zero);
m.Add (other);
Assert.AreEqual ("multipart/form-data", m.Headers.ContentType.MediaType, "#1");
Assert.AreEqual (154, m.Headers.ContentLength, "#2");
Assert.AreEqual ("--b\r\nContent-Type: multipart/form-data; boundary=\"44\"\r\nExpires: Mon, 30 Nov 2020 19:55:22 GMT\r\nContent-Disposition: form-data\r\n\r\n--44\r\n\r\n--44--\r\n\r\n--b--\r\n", m.ReadAsStringAsync ().Result, "#3");
Assert.AreEqual (other, m.First (), "#4");
Assert.IsNull (m.Headers.ContentDisposition, "#5");
Assert.AreEqual ("form-data", other.Headers.ContentDisposition.ToString (), "#6");
}
示例3: Does_not_match_form_data_on_non_form_data_multipart_entries
public void Does_not_match_form_data_on_non_form_data_multipart_entries()
{
var content = new MultipartFormDataContent
{
new FormUrlEncodedContent(HttpHelpers.ParseQueryString("key1=value1")),
new FormUrlEncodedContent(HttpHelpers.ParseQueryString("key2=value2"))
};
content.First().Headers.ContentType = new MediaTypeHeaderValue("text/plain");
var result = Test(
expected: "key1=value1&key2=value2",
actual: content
);
Assert.False(result);
}