Skip to content

Commit 23dbb72

Browse files
committed
Added unit test. Test works with the old code in .NET 6, but cannot test .NET 4.8 as the test framework needs all the .NET 6 stuff.
1 parent 8144a6d commit 23dbb72

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

test/RestSharp.Tests.Integrated/PostTests.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using System.Net;
12
using RestSharp.Tests.Integrated.Server;
23

34
namespace RestSharp.Tests.Integrated;
@@ -33,4 +34,19 @@ public async Task Should_post_json_with_PostJsonAsync() {
3334

3435
response.Message.Should().Be(body.Data);
3536
}
37+
38+
class Response {
39+
public string Message { get; set; }
40+
}
41+
42+
[Fact]
43+
public async Task Should_post_large_form_data() {
44+
const int length = 1024 * 1024;
45+
var superLongString = new string('?', length);
46+
var request = new RestRequest("post/form", Method.Post).AddParameter("big_string", superLongString);
47+
var response = await _client.ExecuteAsync<Response>(request);
48+
49+
response.StatusCode.Should().Be(HttpStatusCode.OK);
50+
response.Data!.Message.Should().Be($"Works! Length: {length}");
51+
}
3652
}

test/RestSharp.Tests.Integrated/Server/TestServer.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ public HttpServer(ITestOutputHelper output = null) {
5353

5454
// POST
5555
_app.MapPost("/post/json", (TestRequest request) => new TestResponse { Message = request.Data });
56+
_app.MapPost("/post/form", (HttpContext context) => new TestResponse { Message = $"Works! Length: {context.Request.Form["big_string"].ToString().Length}" });
5657

5758
IResult HandleHeaders(HttpContext ctx) {
5859
var response = ctx.Request.Headers.Select(x => new TestServerResponse(x.Key, x.Value));

0 commit comments

Comments
 (0)