Compare commits

..

5 Commits

Author SHA1 Message Date
Stef Heyenrath
409d55350f 1.0.11.0 2019-03-30 09:47:28 +01:00
Alex Kursov
e7ac620721 Add ProvideResponse_WithJsonBodyAndTransform test (#262) 2019-03-30 09:34:13 +01:00
Alex Kursov
ceb6596823 Fix ResponseMessageTransformer to not replace BodyAsJson in an original message (#261)
Fix ResponseMessageTransformer to not replace BodyAsJson in an original message with transformed results
2019-03-30 09:33:49 +01:00
Stef Heyenrath
47e599214f 1.0.10.0 2019-03-27 08:34:30 +01:00
Stef Heyenrath
b99e300acf Fix Response.Delay property serialization (#260)
* Fix Response.Delay property serialization issue

* Fix Response.Delay
2019-03-27 08:26:55 +01:00
6 changed files with 47 additions and 6 deletions

View File

@@ -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]

View File

@@ -4,7 +4,7 @@
</PropertyGroup>
<PropertyGroup>
<VersionPrefix>1.0.9</VersionPrefix>
<VersionPrefix>1.0.11</VersionPrefix>
</PropertyGroup>
<Choose>

View File

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

View File

@@ -77,7 +77,7 @@ namespace WireMock.Serialization
},
Response = new ResponseModel
{
Delay = response.Delay?.Milliseconds
Delay = (int?) response.Delay?.TotalMilliseconds
}
};

View File

@@ -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
};
}
}
}
}

View File

@@ -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);
}
}
}
}