mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-04-18 15:10:17 +02:00
ContentType "application/vnd.api+json" is not recognized as json (#186)
* Admin API GetRequestsAsync Json/JsonApi request body tests * Fix code + update unit-tests
This commit is contained in:
committed by
Stef Heyenrath
parent
b57d118c3d
commit
fb6b25a9c5
@@ -9,6 +9,36 @@ namespace WireMock.Net.Tests.Util
|
||||
{
|
||||
public class BodyParserTests
|
||||
{
|
||||
[Fact]
|
||||
public async Task BodyParser_Parse_ApplicationJson()
|
||||
{
|
||||
// Assign
|
||||
var memoryStream = new MemoryStream(Encoding.UTF8.GetBytes("{ \"x\": 1 }"));
|
||||
|
||||
// Act
|
||||
var body = await BodyParser.Parse(memoryStream, "application/json");
|
||||
|
||||
// Assert
|
||||
Check.That(body.BodyAsBytes).IsNull();
|
||||
Check.That(body.BodyAsJson).IsNotNull();
|
||||
Check.That(body.BodyAsString).Equals("{ \"x\": 1 }");
|
||||
}
|
||||
|
||||
[Fact] // http://jsonapi.org/
|
||||
public async Task BodyParser_Parse_ApplicationJsonApi()
|
||||
{
|
||||
// Assign
|
||||
var memoryStream = new MemoryStream(Encoding.UTF8.GetBytes("{ \"x\": 1 }"));
|
||||
|
||||
// Act
|
||||
var body = await BodyParser.Parse(memoryStream, "application/vnd.api+json");
|
||||
|
||||
// Assert
|
||||
Check.That(body.BodyAsBytes).IsNull();
|
||||
Check.That(body.BodyAsJson).IsNotNull();
|
||||
Check.That(body.BodyAsString).Equals("{ \"x\": 1 }");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task BodyParser_Parse_ApplicationXml()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user