Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Added unit test. Test works with the old code in .NET 6, but cannot t…
…est .NET 4.8 as the test framework needs all the .NET 6 stuff.
  • Loading branch information
kendallb committed Apr 4, 2022
commit 96de5c99d0899e1cb41b90fde1276e937fd76212
16 changes: 16 additions & 0 deletions test/RestSharp.Tests.Integrated/PostTests.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Net;
using RestSharp.Tests.Integrated.Server;

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

response.Message.Should().Be(body.Data);
}

class Response {
public string Message { get; set; }
}

[Fact]
public async Task Should_post_large_form_data() {
const int length = 1024 * 1024;
var superLongString = new string('?', length);
var request = new RestRequest("post/form", Method.Post).AddParameter("big_string", superLongString);
var response = await _client.ExecuteAsync<Response>(request);

response.StatusCode.Should().Be(HttpStatusCode.OK);
response.Data!.Message.Should().Be($"Works! Length: {length}");
}
}
1 change: 1 addition & 0 deletions test/RestSharp.Tests.Integrated/Server/TestServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public HttpServer(ITestOutputHelper output = null) {

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

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