mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-03-19 07:54:53 +01:00
Add unit test example for Transformer Handlebars String.Append String.Join (#877)
* Response_ProvideResponse_Transformer_WithBodyAsJson_Handlebars_StringAppend * fix
This commit is contained in:
@@ -682,6 +682,27 @@ public class ResponseWithTransformerTests
|
||||
Check.That(JsonConvert.SerializeObject(response.Message.BodyData!.BodyAsJson)).Equals("\"test\"");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Response_ProvideResponse_Transformer_WithBodyAsJson_Handlebars_StringAppend()
|
||||
{
|
||||
// Assign
|
||||
var request = new RequestMessage(new UrlDetails("https://localhost/token?scope=scope1 scope2 scope3"), "POST", ClientIp);
|
||||
|
||||
var responseBuilder = Response.Create()
|
||||
.WithBodyAsJson(
|
||||
new
|
||||
{
|
||||
scope = "{{String.Append (String.Join request.query.scope) \" helloworld\" }}"
|
||||
})
|
||||
.WithTransformer();
|
||||
|
||||
// Act
|
||||
var response = await responseBuilder.ProvideResponseAsync(_mappingMock.Object, request, _settings).ConfigureAwait(false);
|
||||
|
||||
// Assert
|
||||
JsonConvert.SerializeObject(response.Message.BodyData!.BodyAsJson).Should().Be("{\"scope\":\"scope1 scope2 scope3 helloworld\"}");
|
||||
}
|
||||
|
||||
[Fact(Skip = "todo...")]
|
||||
//[Fact]
|
||||
public async Task Response_ProvideResponse_Handlebars_WithBodyAsJson_ResultAsTemplatedString()
|
||||
|
||||
Reference in New Issue
Block a user