Skip to content

Commit

Permalink
Added unit test. Test works with the old code in .NET 6, but cannot t…
Browse files Browse the repository at this point in the history
…est .NET 4.8 as the test framework needs all the .NET 6 stuff.
  • Loading branch information
kendallb committed Mar 29, 2022
1 parent 8144a6d commit 23dbb72
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
16 changes: 16 additions & 0 deletions test/RestSharp.Tests.Integrated/PostTests.cs
@@ -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 class PostTests {

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
Expand Up @@ -53,6 +53,7 @@ public sealed class HttpServer {

// 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

0 comments on commit 23dbb72

Please sign in to comment.