diff --git a/test/RestSharp.Tests.Integrated/MultipartFormDataTests.cs b/test/RestSharp.Tests.Integrated/MultipartFormDataTests.cs index 389329235..28d0ac825 100644 --- a/test/RestSharp.Tests.Integrated/MultipartFormDataTests.cs +++ b/test/RestSharp.Tests.Integrated/MultipartFormDataTests.cs @@ -13,6 +13,7 @@ public MultipartFormDataTests(ITestOutputHelper output) { _server = WireMockServer.Start(); _capturer = _server.ConfigureBodyCapturer(Method.Post); + var options = new RestClientOptions($"{_server.Url!}{RequestBodyCapturer.Resource}") { ConfigureMessageHandler = handler => new HttpTracerHandler(handler, new OutputLogger(output), HttpMessageParts.All) }; @@ -180,7 +181,7 @@ public async Task MultipartFormDataAsync() { _capturer.Body.Should().Be(expected); } - + [Fact] public async Task MultipartFormData_Without_File_Creates_A_Valid_RequestBody() { using var client = new RestClient(_server.Url!); @@ -206,4 +207,29 @@ public async Task MultipartFormData_Without_File_Creates_A_Valid_RequestBody() { var actual = capturer.Body!.Replace("\n", string.Empty).Split('\r'); actual.Should().Contain(expectedBody); } + + [Fact] + public async Task PostParameter_contentType_in_multipart_form() { + using var client = new RestClient(_server.Url!); + + var request = new RestRequest(RequestBodyCapturer.Resource, Method.Post) { + AlwaysMultipartFormData = true + }; + var capturer = _server.ConfigureBodyCapturer(Method.Post); + + const string parameterName = "Arequest"; + const string parameterValue = "{\"attributeFormat\":\"pdf\"}"; + + var parameter = new GetOrPostParameter(parameterName, parameterValue) { + ContentType = "application/json" + }; + request.AddParameter(parameter); + + await client.ExecuteAsync(request); + + var actual = capturer.Body!.Replace("\n", string.Empty).Split('\r'); + actual[1].Should().Be("Content-Type: application/json; charset=utf-8"); + actual[2].Should().Be($"Content-Disposition: form-data; name={parameterName}"); + actual[4].Should().Be(parameterValue); + } } \ No newline at end of file