public async Task AddFormDataTextTest() { string get(string name, string value) { return($@"Content-Disposition: form-data; name=""{name}"" {HttpUtil.UrlEncode(value, Encoding.UTF8)}"); } var reqeust = new HttpApiRequestMessageImpl(); reqeust.Method = System.Net.Http.HttpMethod.Post; reqeust.RequestUri = new Uri("http://webapiclient.com"); reqeust.AddFormDataText("name", "laojiu"); reqeust.AddFormDataText(new[] { new KeyValue("age", "18") }); await Assert.ThrowsAsync <NotSupportedException>(() => reqeust.AddFormFieldAsync("key", "value")); var body = await reqeust.Content.ReadAsStringAsync(); Assert.Contains(get("name", "laojiu"), body); Assert.Contains(get("age", "18"), body); Assert.True(reqeust.Content.Headers.ContentType.MediaType == "multipart/form-data"); }