Skip to content

Commit 68c6417

Browse files
committed
xxx
1 parent 09b2413 commit 68c6417

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

test/Directory.Build.props

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project>
22
<Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.props', '$(MSBuildThisFileDirectory)../'))" />
33

4-
<ItemGroup>
4+
<ItemGroup Condition=" '$(TargetFramework)' != 'net45' and '$(TargetFramework)' != 'net452' and '$(TargetFramework)' != 'net461' ">
55
<AssemblyAttribute Include="System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverageAttribute" />
66
</ItemGroup>
77

test/WireMock.Net.Tests/ResponseBuilders/ResponseWithTransformerTests.cs

+8-4
Original file line numberDiff line numberDiff line change
@@ -130,23 +130,27 @@ public async Task Response_ProvideResponse_Handlebars_PathSegments()
130130
Check.That(response.Message.BodyData!.BodyAsString).Equals("a wiremock");
131131
}
132132

133-
[Fact]
134-
public async Task Response_ProvideResponse_Handlebars_BodyAsJson_PathSegments()
133+
[Theory]
134+
[InlineData("{{request.PathSegments.[0]}}", "a")]
135+
[InlineData("prefix_{{request.PathSegments.[0]}}", "prefix_a")]
136+
[InlineData("{{request.PathSegments.[0]}}_postfix", "a_postfix")]
137+
[InlineData("prefix_{{request.PathSegments.[0]}}_postfix", "prefix_a_postfix")]
138+
public async Task Response_ProvideResponse_Handlebars_BodyAsJson_PathSegments(string field, string expected)
135139
{
136140
// Assign
137141
var urlDetails = UrlUtils.Parse(new Uri("http://localhost/wiremock/a/b"), new PathString("/wiremock"));
138142
var request = new RequestMessage(urlDetails, "POST", ClientIp);
139143

140144
var responseBuilder = Response.Create()
141-
.WithBodyAsJson(new { field = "prefix_{{request.PathSegments.[0]}}_postfix" })
145+
.WithBodyAsJson(new { field })
142146
.WithTransformer();
143147

144148
// Act
145149
var response = await responseBuilder.ProvideResponseAsync(_mappingMock.Object, request, _settings).ConfigureAwait(false);
146150

147151
// Assert
148152
var json = (JObject)response.Message.BodyData!.BodyAsJson!;
149-
Check.That(json["field"]!.Value<string>()).Equals("prefix_a_postfix");
153+
Check.That(json["field"]!.Value<string>()).Equals(expected);
150154
}
151155

152156
[Theory(Skip = "Invalid token `OpenBracket`")]

0 commit comments

Comments
 (0)