Skip to content

Commit 2057305

Browse files
committed
Deprecate WithFilter on IHttpRequestMessagesCheck
1 parent 7f12de4 commit 2057305

File tree

3 files changed

+4
-12
lines changed

3 files changed

+4
-12
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
77
## [0.12] - unplanned
88
### Deprecated
99
- The methods `WithRequestHeader` and `WithContentHeader` are deprecated, please use `WithHeader` instead.
10+
- The `WithFilter` method is deprecated and will be made internal or be removed. If there is a specific assertion that is missing, please open an issue.
1011

1112
### Removed
1213
- .NET 6.0 target, since it is no longer supported

src/TestableHttpClient/IHttpRequestMessagesCheck.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ public interface IHttpRequestMessagesCheck
1616
/// <param name="requestFilter">The filter to filter requests with before asserting.</param>
1717
/// <param name="condition">The name of the condition, used in the exception message.</param>
1818
/// <returns>The <seealso cref="IHttpRequestMessagesCheck"/> for further assertions.</returns>
19+
[Obsolete("WithFilter will be made internal, since it should no longer be necesary to use.")]
1920
public IHttpRequestMessagesCheck WithFilter(Func<HttpRequestMessage, bool> requestFilter, string condition);
2021

2122
/// <summary>
@@ -25,6 +26,7 @@ public interface IHttpRequestMessagesCheck
2526
/// <param name="expectedNumberOfRequests">The expected number of requests.</param>
2627
/// <param name="condition">The name of the condition, used in the exception message.</param>
2728
/// <returns>The <seealso cref="IHttpRequestMessagesCheck"/> for further assertions.</returns>
29+
[Obsolete("WithFilter will be made internal, since it should no longer be necesary to use.")]
2830
public IHttpRequestMessagesCheck WithFilter(Func<HttpRequestMessage, bool> requestFilter, int expectedNumberOfRequests, string condition);
2931

3032
/// <summary>
@@ -34,6 +36,7 @@ public interface IHttpRequestMessagesCheck
3436
/// <param name="expectedNumberOfRequests">The expected number of requests, when null is passed "at least one" is presumed.</param>
3537
/// <param name="condition">The name of the condition, used in the exception message.</param>
3638
/// <returns>The <seealso cref="IHttpRequestMessagesCheck"/> for further assertions.</returns>
39+
[Obsolete("WithFilter will be made internal, since it should no longer be necesary to use.")]
3740
public IHttpRequestMessagesCheck WithFilter(Func<HttpRequestMessage, bool> requestFilter, int? expectedNumberOfRequests, string condition);
3841

3942
/// <summary>

test/TestableHttpClient.IntegrationTests/AssertingRequests.cs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -200,16 +200,4 @@ public async Task AssertJsonContent()
200200

201201
testHandler.ShouldHaveMadeRequests().WithJsonContent(new { });
202202
}
203-
204-
[Fact]
205-
public async Task CustomAssertions()
206-
{
207-
using TestableHttpMessageHandler testHandler = new();
208-
using HttpClient client = new(testHandler);
209-
210-
using StringContent content = new("", Encoding.UTF8, "application/json");
211-
_ = await client.PostAsync("https://httpbin.org/post", content, TestContext.Current.CancellationToken);
212-
213-
testHandler.ShouldHaveMadeRequests().WithFilter(x => x.Content is not null && x.Content.Headers.ContentType?.MediaType == "application/json", "");
214-
}
215203
}

0 commit comments

Comments
 (0)