Skip to content

Commit

Permalink
Extend tests to include example of stripping charset
Browse files Browse the repository at this point in the history
  • Loading branch information
basdijkstra committed Dec 9, 2024
1 parent d57ac42 commit ac9e933
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion RestAssured.Net.Tests/JsonRequestBodySerializationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,16 @@ public class JsonRequestBodySerializationTests : TestBase
/// <summary>
/// A test demonstrating RestAssuredNet syntax for serializing
/// and sending a JSON request body when performing an HTTP POST.
/// This also shows how stripping the charset that is automatically
/// added to the Content-Type header works.
/// </summary>
[Test]
public void ObjectCanBeSerializedToJson()
{
this.CreateStubForJsonRequestBody();

Given()
.Body(this.GetLocation())
.Body(this.GetLocation(), stripCharset: true)
.When()
.Post($"{MOCK_SERVER_BASE_URL}/json-serialization")
.Then()
Expand Down Expand Up @@ -124,6 +126,7 @@ public void RecordCanBeSerializedToJson()
private void CreateStubForJsonRequestBody()
{
this.Server?.Given(Request.Create().WithPath("/json-serialization").UsingPost()
.WithHeader("Content-Type", new ExactMatcher("application/json"))
.WithBody(new JsonMatcher(this.expectedSerializedJsonRequestBody)))
.RespondWith(Response.Create()
.WithStatusCode(201));
Expand Down

0 comments on commit ac9e933

Please sign in to comment.