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"); }
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"); }
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); }