Add unit test example for Transformer Handlebars String.Append String.Join (#877)

* Response_ProvideResponse_Transformer_WithBodyAsJson_Handlebars_StringAppend

* fix
This commit is contained in:
Stef Heyenrath
2023-01-20 08:21:59 +01:00
committed by GitHub
parent b2a8178161
commit c85eaf1072

View File

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