Skip to content

Commit 0eeeb3f

Browse files
authored
chore: bump Mockolate to v1.4.1 (#63)
Updates Mockolate to v1.4.1 and adjusts the HttpContent JSON-content matcher surface/tests accordingly. ### Key Changes: - Bump Mockolate package version from 1.4.0 to 1.4.1. - Add additional verification assertions in JSON content matching tests (ensuring expected request bodies are actually observed). - Remove several obsolete pass-through overloads from the `IsJsonContent` wrapper API.
1 parent 0d30a9d commit 0eeeb3f

3 files changed

Lines changed: 39 additions & 26 deletions

File tree

Directory.Packages.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<ItemGroup>
66
<PackageVersion Include="aweXpect" Version="2.30.0" />
77
<PackageVersion Include="aweXpect.Core" Version="2.27.0" />
8-
<PackageVersion Include="Mockolate" Version="1.4.0" />
8+
<PackageVersion Include="Mockolate" Version="1.4.1" />
99
</ItemGroup>
1010
<ItemGroup>
1111
<PackageVersion Include="Nullable" Version="1.3.1" />

Source/aweXpect.Mockolate/Web/ItExtensions.HttpContent.IsJsonContent.cs

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -90,37 +90,12 @@ public ItExtensions.IHttpContentHeaderParameter WithHeaders(
9090
params IEnumerable<(string Name, HttpHeaderValue Value)> headers)
9191
=> _parameter.WithHeaders(headers);
9292

93-
public ItExtensions.IHttpContentHeaderParameter WithHeaders(string headers)
94-
=> _parameter.WithHeaders(headers);
95-
96-
public ItExtensions.IHttpContentHeaderParameter WithHeaders(string name, HttpHeaderValue value)
97-
=> _parameter.WithHeaders(name, value);
98-
9993
public ItExtensions.IHttpContentParameter WithString(Func<string, bool> predicate)
10094
=> _parameter.WithString(predicate);
10195

102-
public ItExtensions.IStringContentBodyParameter WithString(string expected)
103-
=> _parameter.WithString(expected);
104-
105-
public ItExtensions.IStringContentBodyMatchingParameter WithStringMatching(string pattern)
106-
=> _parameter.WithStringMatching(pattern);
107-
108-
public ItExtensions.IHttpContentParameter WithBytes(byte[] bytes)
109-
=> _parameter.WithBytes(bytes);
110-
11196
public ItExtensions.IHttpContentParameter WithBytes(Func<byte[], bool> predicate)
11297
=> _parameter.WithBytes(predicate);
11398

114-
public ItExtensions.IFormDataContentParameter WithFormData(string key, HttpFormDataValue value)
115-
=> _parameter.WithFormData(key, value);
116-
117-
public ItExtensions.IFormDataContentParameter WithFormData(
118-
params IEnumerable<(string Key, HttpFormDataValue Value)> values)
119-
=> _parameter.WithFormData(values);
120-
121-
public ItExtensions.IFormDataContentParameter WithFormData(string values)
122-
=> _parameter.WithFormData(values);
123-
12499
public ItExtensions.IHttpContentParameter WithMediaType(string? mediaType)
125100
=> _parameter.WithMediaType(mediaType);
126101

Tests/aweXpect.Mockolate.Tests/Web/ItExtensionsTests.HttpContentTests.IsJsonContentTests.cs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,22 @@ public async Task ShouldSupportNestedObjects()
116116

117117
await That(result.StatusCode)
118118
.IsEqualTo(HttpStatusCode.OK);
119+
await That(httpClient.VerifyMock.Invoked
120+
.PostAsync(It.IsAny<Uri>(), It.IsHttpContent().WithJsonMatching([
121+
new
122+
{
123+
foo = 2,
124+
},
125+
new
126+
{
127+
foo = 3,
128+
},
129+
new
130+
{
131+
foo = 4,
132+
},
133+
])))
134+
.Once();
119135
}
120136

121137
[Theory]
@@ -179,6 +195,13 @@ public async Task WithBodyMatching_ShouldCompareAsJson()
179195

180196
await That(result.StatusCode)
181197
.IsEqualTo(HttpStatusCode.OK);
198+
await That(httpClient.VerifyMock.Invoked
199+
.PostAsync(It.IsAny<Uri>(), It.IsHttpContent().WithJsonMatching(new
200+
{
201+
foo = 1,
202+
bar = 2,
203+
})))
204+
.Once();
182205
}
183206

184207
[Theory]
@@ -250,6 +273,9 @@ public async Task MatchingValues_ShouldSucceed(string[] expected, string body)
250273

251274
await That(result.StatusCode)
252275
.IsEqualTo(HttpStatusCode.OK);
276+
await That(httpClient.VerifyMock.Invoked
277+
.PostAsync(It.IsAny<Uri>(), It.IsHttpContent().WithJsonMatching(expected)))
278+
.Once();
253279
}
254280

255281
[Theory]
@@ -318,6 +344,9 @@ public async Task WhenSubjectContainsAdditionalElements_ShouldSucceed()
318344

319345
await That(result.StatusCode)
320346
.IsEqualTo(HttpStatusCode.OK);
347+
await That(httpClient.VerifyMock.Invoked
348+
.PostAsync(It.IsAny<Uri>(), It.IsHttpContent().WithJsonMatching([1, 2,])))
349+
.Once();
321350
}
322351

323352
[Fact]
@@ -434,6 +463,9 @@ public async Task WhenExpectedIsEmpty_ShouldSucceed(string body)
434463

435464
await That(result.StatusCode)
436465
.IsEqualTo(HttpStatusCode.OK);
466+
await That(httpClient.VerifyMock.Invoked
467+
.PostAsync(It.IsAny<Uri>(), It.IsHttpContent().WithJsonMatching(new object())))
468+
.Once();
437469
}
438470

439471
[Fact]
@@ -474,6 +506,12 @@ public async Task WhenSubjectHasAdditionalProperties_ShouldSucceed()
474506

475507
await That(result.StatusCode)
476508
.IsEqualTo(HttpStatusCode.OK);
509+
await That(httpClient.VerifyMock.Invoked
510+
.PostAsync(It.IsAny<Uri>(), It.IsHttpContent().WithJsonMatching(new
511+
{
512+
bar = 2,
513+
})))
514+
.Once();
477515
}
478516

479517
[Fact]

0 commit comments

Comments
 (0)