mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-03-19 07:43:48 +01:00
Update BodyParser logic (#212)
* Update BodyParser logic * update logic for byte[] * small update * MyGetKey * myget * dotnet nuget push * dotnet build * Release * . * StringContent * 1.0.4.18-preview-02 * Debug * 1.0.4.18-preview-02 * disable some proxy tests * myget * packagesToPack * fix * <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> <GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType> * Release * <VersionPrefix>1.0.4.18</VersionPrefix> * fix * BodyParserTests * ResponseBodyData (#216) * ResponseBodyData * refactor tests * LogEntryMapperTests
This commit is contained in:
@@ -17,11 +17,7 @@ namespace WireMock.Net.Tests.Http
|
||||
{
|
||||
// Assign
|
||||
var headers = new Dictionary<string, string[]> { { "x", new[] { "value-1" } } };
|
||||
var body = new BodyData
|
||||
{
|
||||
BodyAsString = "<xml>hello</xml>"
|
||||
};
|
||||
var request = new RequestMessage(new UrlDetails("http://localhost/foo"), "PUT", ClientIp, body, headers);
|
||||
var request = new RequestMessage(new UrlDetails("http://localhost/foo"), "PUT", ClientIp, null, headers);
|
||||
|
||||
// Act
|
||||
var message = HttpRequestMessageHelper.Create(request, "http://url");
|
||||
@@ -36,7 +32,8 @@ namespace WireMock.Net.Tests.Http
|
||||
// Assign
|
||||
var body = new BodyData
|
||||
{
|
||||
BodyAsBytes = Encoding.UTF8.GetBytes("hi")
|
||||
BodyAsBytes = Encoding.UTF8.GetBytes("hi"),
|
||||
DetectedBodyType = BodyType.Bytes
|
||||
};
|
||||
var request = new RequestMessage(new UrlDetails("http://localhost/foo"), "GET", ClientIp, body);
|
||||
|
||||
@@ -53,7 +50,8 @@ namespace WireMock.Net.Tests.Http
|
||||
// Assign
|
||||
var body = new BodyData
|
||||
{
|
||||
BodyAsJson = new { x = 42 }
|
||||
BodyAsJson = new { x = 42 },
|
||||
DetectedBodyType = BodyType.Json
|
||||
};
|
||||
var request = new RequestMessage(new UrlDetails("http://localhost/foo"), "GET", ClientIp, body);
|
||||
|
||||
@@ -71,7 +69,28 @@ namespace WireMock.Net.Tests.Http
|
||||
var headers = new Dictionary<string, string[]> { { "Content-Type", new[] { "application/json" } } };
|
||||
var body = new BodyData
|
||||
{
|
||||
BodyAsJson = new { x = 42 }
|
||||
BodyAsJson = new { x = 42 },
|
||||
DetectedBodyType = BodyType.Json
|
||||
};
|
||||
var request = new RequestMessage(new UrlDetails("http://localhost/foo"), "GET", ClientIp, body, headers);
|
||||
|
||||
// Act
|
||||
var message = HttpRequestMessageHelper.Create(request, "http://url");
|
||||
|
||||
// Assert
|
||||
Check.That(await message.Content.ReadAsStringAsync()).Equals("{\"x\":42}");
|
||||
Check.That(message.Content.Headers.GetValues("Content-Type")).ContainsExactly("application/json");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async void HttpRequestMessageHelper_Create_Json_With_ContentType_ApplicationJson_UTF8()
|
||||
{
|
||||
// Assign
|
||||
var headers = new Dictionary<string, string[]> { { "Content-Type", new[] { "application/json; charset=utf-8" } } };
|
||||
var body = new BodyData
|
||||
{
|
||||
BodyAsJson = new { x = 42 },
|
||||
DetectedBodyType = BodyType.Json
|
||||
};
|
||||
var request = new RequestMessage(new UrlDetails("http://localhost/foo"), "GET", ClientIp, body, headers);
|
||||
|
||||
@@ -90,7 +109,8 @@ namespace WireMock.Net.Tests.Http
|
||||
var headers = new Dictionary<string, string[]> { { "Content-Type", new[] { "application/xml" } } };
|
||||
var body = new BodyData
|
||||
{
|
||||
BodyAsString = "<xml>hello</xml>"
|
||||
BodyAsString = "<xml>hello</xml>",
|
||||
DetectedBodyType = BodyType.String
|
||||
};
|
||||
var request = new RequestMessage(new UrlDetails("http://localhost/foo"), "PUT", ClientIp, body, headers);
|
||||
|
||||
@@ -98,7 +118,7 @@ namespace WireMock.Net.Tests.Http
|
||||
var message = HttpRequestMessageHelper.Create(request, "http://url");
|
||||
|
||||
// Assert
|
||||
Check.That(message.Content.Headers.GetValues("Content-Type")).ContainsExactly("application/xml; charset=utf-8");
|
||||
Check.That(message.Content.Headers.GetValues("Content-Type")).ContainsExactly("application/xml");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -108,7 +128,8 @@ namespace WireMock.Net.Tests.Http
|
||||
var headers = new Dictionary<string, string[]> { { "Content-Type", new[] { "application/xml; charset=UTF-8" } } };
|
||||
var body = new BodyData
|
||||
{
|
||||
BodyAsString = "<xml>hello</xml>"
|
||||
BodyAsString = "<xml>hello</xml>",
|
||||
DetectedBodyType = BodyType.String
|
||||
};
|
||||
var request = new RequestMessage(new UrlDetails("http://localhost/foo"), "PUT", ClientIp, body, headers);
|
||||
|
||||
@@ -126,7 +147,8 @@ namespace WireMock.Net.Tests.Http
|
||||
var headers = new Dictionary<string, string[]> { { "Content-Type", new[] { "application/xml; charset=Ascii" } } };
|
||||
var body = new BodyData
|
||||
{
|
||||
BodyAsString = "<xml>hello</xml>"
|
||||
BodyAsString = "<xml>hello</xml>",
|
||||
DetectedBodyType = BodyType.String
|
||||
};
|
||||
var request = new RequestMessage(new UrlDetails("http://localhost/foo"), "PUT", ClientIp, body, headers);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user