mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-02-16 07:17:42 +01:00
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
409d55350f | ||
|
|
e7ac620721 | ||
|
|
ceb6596823 | ||
|
|
47e599214f | ||
|
|
b99e300acf |
@@ -1,3 +1,12 @@
|
||||
# 1.0.11.0 (30 March 2019)
|
||||
- [#261](https://github.com/WireMock-Net/WireMock.Net/pull/261) - Fix BodyAsJson transform bug in ResponseMessageTransformer contributed by [psypilat](https://github.com/psypilat)
|
||||
- [#262](https://github.com/WireMock-Net/WireMock.Net/pull/262) - Add ProvideResponse_WithJsonBodyAndTransform test contributed by [psypilat](https://github.com/psypilat)
|
||||
|
||||
# 1.0.10.0 (27 March 2019)
|
||||
- [#260](https://github.com/WireMock-Net/WireMock.Net/pull/260) - Fix Response.Delay property serialization [bug] contributed by [StefH](https://github.com/StefH)
|
||||
- [#257](https://github.com/WireMock-Net/WireMock.Net/issues/257) - Doc: Update outdated [question]
|
||||
- [#258](https://github.com/WireMock-Net/WireMock.Net/issues/258) - InvalidProgramException when following running as standalone process example with dotnetcore [invalid]
|
||||
|
||||
# 1.0.9.0 (25 March 2019)
|
||||
- [#256](https://github.com/WireMock-Net/WireMock.Net/pull/256) - Fixed Multi Param Match logic contributed by [StefH](https://github.com/StefH)
|
||||
- [#255](https://github.com/WireMock-Net/WireMock.Net/issues/255) - ExactMatcher with array pattern not working? [bug]
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<VersionPrefix>1.0.9</VersionPrefix>
|
||||
<VersionPrefix>1.0.11</VersionPrefix>
|
||||
</PropertyGroup>
|
||||
|
||||
<Choose>
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
https://github.com/StefH/GitHubReleaseNotes
|
||||
|
||||
GitHubReleaseNotes.exe --output CHANGELOG.md --skip-empty-releases --version 1.0.9.0
|
||||
GitHubReleaseNotes.exe --output CHANGELOG.md --skip-empty-releases --version 1.0.11.0
|
||||
@@ -77,7 +77,7 @@ namespace WireMock.Serialization
|
||||
},
|
||||
Response = new ResponseModel
|
||||
{
|
||||
Delay = response.Delay?.Milliseconds
|
||||
Delay = (int?) response.Delay?.TotalMilliseconds
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ namespace WireMock.Transformers
|
||||
switch (original.BodyData.BodyAsJson)
|
||||
{
|
||||
case JObject bodyAsJObject:
|
||||
jToken = bodyAsJObject;
|
||||
jToken = bodyAsJObject.DeepClone();
|
||||
break;
|
||||
|
||||
case Array bodyAsArray:
|
||||
@@ -160,4 +160,4 @@ namespace WireMock.Transformers
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ using WireMock.Models;
|
||||
using WireMock.ResponseBuilders;
|
||||
using WireMock.Util;
|
||||
using Xunit;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace WireMock.Net.Tests.ResponseBuilders
|
||||
{
|
||||
@@ -199,5 +200,36 @@ namespace WireMock.Net.Tests.ResponseBuilders
|
||||
Check.That(responseMessage.Headers["H1"].ToString()).IsEqualTo("X1");
|
||||
Check.That(responseMessage.Headers["H2"].ToString()).IsEqualTo("X2");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Response_ProvideResponse_WithJsonBodyAndTransform_Func()
|
||||
{
|
||||
// Assign
|
||||
const int request1Id = 1;
|
||||
const int request2Id = 2;
|
||||
|
||||
var request1 = new RequestMessage(new UrlDetails($"http://localhost/test?id={request1Id}"), "GET", ClientIp);
|
||||
var request2 = new RequestMessage(new UrlDetails($"http://localhost/test?id={request2Id}"), "GET", ClientIp);
|
||||
|
||||
var response = Response.Create()
|
||||
.WithStatusCode(200)
|
||||
.WithBodyAsJson(JObject.Parse("{ \"id\": \"{{request.query.id}}\" }"))
|
||||
.WithTransformer();
|
||||
|
||||
// Act
|
||||
var response1Message = await response.ProvideResponseAsync(request1);
|
||||
var response2Message = await response.ProvideResponseAsync(request2);
|
||||
|
||||
// Assert
|
||||
Check.That(((JToken)response1Message.BodyData.BodyAsJson).SelectToken("id")?.Value<int>()).IsEqualTo(request1Id);
|
||||
Check.That(response1Message.BodyData.BodyAsBytes).IsNull();
|
||||
Check.That(response1Message.BodyData.BodyAsString).IsNull();
|
||||
Check.That(response1Message.StatusCode).IsEqualTo(200);
|
||||
|
||||
Check.That(((JToken)response2Message.BodyData.BodyAsJson).SelectToken("id")?.Value<int>()).IsEqualTo(request2Id);
|
||||
Check.That(response2Message.BodyData.BodyAsBytes).IsNull();
|
||||
Check.That(response2Message.BodyData.BodyAsString).IsNull();
|
||||
Check.That(response2Message.StatusCode).IsEqualTo(200);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user