From 2cea2e7f54e15232aa0942fbaffcbbdf0e1effce Mon Sep 17 00:00:00 2001 From: skwasjer <11424653+skwasjer@users.noreply.github.com> Date: Sun, 29 Sep 2024 23:45:07 +0200 Subject: [PATCH 1/8] fix!: remove obsolete interface IConcurrentReadOnlyCollection --- src/MockHttp/IInvokedHttpRequestCollection.cs | 6 ++---- .../Internal/Threading/ConcurrentCollection.cs | 2 +- .../Threading/IConcurrentReadOnlyCollection.cs | 10 ---------- ...icApiTests.Api_has_not_changed.NET_6.0.verified.txt | 7 +------ ...icApiTests.Api_has_not_changed.NET_8.0.verified.txt | 7 +------ ...pi_has_not_changed.NET_Framework_4.6.2.verified.txt | 7 +------ ...pi_has_not_changed.NET_Framework_4.7.2.verified.txt | 7 +------ ....Api_has_not_changed.NET_Framework_4.8.verified.txt | 7 +------ ...s.Api_has_not_changed.NET_Standard_2.1.verified.txt | 7 +------ 9 files changed, 9 insertions(+), 51 deletions(-) delete mode 100644 src/MockHttp/Threading/IConcurrentReadOnlyCollection.cs diff --git a/src/MockHttp/IInvokedHttpRequestCollection.cs b/src/MockHttp/IInvokedHttpRequestCollection.cs index 94d90063..72f82500 100644 --- a/src/MockHttp/IInvokedHttpRequestCollection.cs +++ b/src/MockHttp/IInvokedHttpRequestCollection.cs @@ -1,11 +1,9 @@ -using MockHttp.Threading; - -namespace MockHttp; +namespace MockHttp; /// /// Represents a collection of invoked HTTP requests. /// -public interface IInvokedHttpRequestCollection : IConcurrentReadOnlyCollection +public interface IInvokedHttpRequestCollection : IReadOnlyList { /// /// Clears the invoked requests collection. diff --git a/src/MockHttp/Internal/Threading/ConcurrentCollection.cs b/src/MockHttp/Internal/Threading/ConcurrentCollection.cs index 1534b5ba..65edbafd 100644 --- a/src/MockHttp/Internal/Threading/ConcurrentCollection.cs +++ b/src/MockHttp/Internal/Threading/ConcurrentCollection.cs @@ -3,7 +3,7 @@ namespace MockHttp.Threading; -internal class ConcurrentCollection : IConcurrentReadOnlyCollection +internal class ConcurrentCollection : IReadOnlyList { [DebuggerBrowsable(DebuggerBrowsableState.Never)] private readonly object _syncLock = new(); diff --git a/src/MockHttp/Threading/IConcurrentReadOnlyCollection.cs b/src/MockHttp/Threading/IConcurrentReadOnlyCollection.cs deleted file mode 100644 index 75ad3d60..00000000 --- a/src/MockHttp/Threading/IConcurrentReadOnlyCollection.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace MockHttp.Threading; - -/// -/// Represents a thread safe read-only collection of elements that can be accessed by index. -/// -// vNext(breaking: remove obsolete by implementing IReadOnlyList on IInvokedHttpRequestCollection. -[Obsolete("Will be removed in next version.")] -public interface IConcurrentReadOnlyCollection : IReadOnlyList -{ -} diff --git a/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_6.0.verified.txt b/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_6.0.verified.txt index 7b3e0ad1..1e5973cd 100644 --- a/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_6.0.verified.txt +++ b/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_6.0.verified.txt @@ -40,7 +40,7 @@ namespace MockHttp System.Collections.Generic.IReadOnlyCollection Matchers { get; } System.Net.Http.HttpRequestMessage Request { get; } } - public interface IInvokedHttpRequestCollection : MockHttp.Threading.IConcurrentReadOnlyCollection, System.Collections.Generic.IEnumerable, System.Collections.Generic.IReadOnlyCollection, System.Collections.Generic.IReadOnlyList, System.Collections.IEnumerable + public interface IInvokedHttpRequestCollection : System.Collections.Generic.IEnumerable, System.Collections.Generic.IReadOnlyCollection, System.Collections.Generic.IReadOnlyList, System.Collections.IEnumerable { void Clear(); } @@ -497,9 +497,4 @@ namespace MockHttp.Responses public bool TryGetService([System.Diagnostics.CodeAnalysis.NotNullWhen(true)] out TService? service) { } } public delegate System.Threading.Tasks.Task ResponseHandlerDelegate(MockHttp.Responses.MockHttpRequestContext requestContext, System.Net.Http.HttpResponseMessage responseMessage, System.Threading.CancellationToken cancellationToken); -} -namespace MockHttp.Threading -{ - [System.Obsolete("Will be removed in next version.")] - public interface IConcurrentReadOnlyCollection : System.Collections.Generic.IEnumerable, System.Collections.Generic.IReadOnlyCollection, System.Collections.Generic.IReadOnlyList, System.Collections.IEnumerable { } } \ No newline at end of file diff --git a/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_8.0.verified.txt b/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_8.0.verified.txt index 68ec098b..bc6ee63d 100644 --- a/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_8.0.verified.txt +++ b/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_8.0.verified.txt @@ -41,7 +41,7 @@ namespace MockHttp System.Collections.Generic.IReadOnlyCollection Matchers { get; } System.Net.Http.HttpRequestMessage Request { get; } } - public interface IInvokedHttpRequestCollection : MockHttp.Threading.IConcurrentReadOnlyCollection, System.Collections.Generic.IEnumerable, System.Collections.Generic.IReadOnlyCollection, System.Collections.Generic.IReadOnlyList, System.Collections.IEnumerable + public interface IInvokedHttpRequestCollection : System.Collections.Generic.IEnumerable, System.Collections.Generic.IReadOnlyCollection, System.Collections.Generic.IReadOnlyList, System.Collections.IEnumerable { void Clear(); } @@ -498,9 +498,4 @@ namespace MockHttp.Responses public bool TryGetService([System.Diagnostics.CodeAnalysis.NotNullWhen(true)] out TService? service) { } } public delegate System.Threading.Tasks.Task ResponseHandlerDelegate(MockHttp.Responses.MockHttpRequestContext requestContext, System.Net.Http.HttpResponseMessage responseMessage, System.Threading.CancellationToken cancellationToken); -} -namespace MockHttp.Threading -{ - [System.Obsolete("Will be removed in next version.")] - public interface IConcurrentReadOnlyCollection : System.Collections.Generic.IEnumerable, System.Collections.Generic.IReadOnlyCollection, System.Collections.Generic.IReadOnlyList, System.Collections.IEnumerable { } } \ No newline at end of file diff --git a/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_Framework_4.6.2.verified.txt b/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_Framework_4.6.2.verified.txt index 80865f84..ffdc6384 100644 --- a/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_Framework_4.6.2.verified.txt +++ b/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_Framework_4.6.2.verified.txt @@ -40,7 +40,7 @@ namespace MockHttp System.Collections.Generic.IReadOnlyCollection Matchers { get; } System.Net.Http.HttpRequestMessage Request { get; } } - public interface IInvokedHttpRequestCollection : MockHttp.Threading.IConcurrentReadOnlyCollection, System.Collections.Generic.IEnumerable, System.Collections.Generic.IReadOnlyCollection, System.Collections.Generic.IReadOnlyList, System.Collections.IEnumerable + public interface IInvokedHttpRequestCollection : System.Collections.Generic.IEnumerable, System.Collections.Generic.IReadOnlyCollection, System.Collections.Generic.IReadOnlyList, System.Collections.IEnumerable { void Clear(); } @@ -497,9 +497,4 @@ namespace MockHttp.Responses public bool TryGetService([System.Diagnostics.CodeAnalysis.NotNullWhen(true)] out TService? service) { } } public delegate System.Threading.Tasks.Task ResponseHandlerDelegate(MockHttp.Responses.MockHttpRequestContext requestContext, System.Net.Http.HttpResponseMessage responseMessage, System.Threading.CancellationToken cancellationToken); -} -namespace MockHttp.Threading -{ - [System.Obsolete("Will be removed in next version.")] - public interface IConcurrentReadOnlyCollection : System.Collections.Generic.IEnumerable, System.Collections.Generic.IReadOnlyCollection, System.Collections.Generic.IReadOnlyList, System.Collections.IEnumerable { } } \ No newline at end of file diff --git a/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_Framework_4.7.2.verified.txt b/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_Framework_4.7.2.verified.txt index d8ce0b97..bf6336d4 100644 --- a/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_Framework_4.7.2.verified.txt +++ b/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_Framework_4.7.2.verified.txt @@ -40,7 +40,7 @@ namespace MockHttp System.Collections.Generic.IReadOnlyCollection Matchers { get; } System.Net.Http.HttpRequestMessage Request { get; } } - public interface IInvokedHttpRequestCollection : MockHttp.Threading.IConcurrentReadOnlyCollection, System.Collections.Generic.IEnumerable, System.Collections.Generic.IReadOnlyCollection, System.Collections.Generic.IReadOnlyList, System.Collections.IEnumerable + public interface IInvokedHttpRequestCollection : System.Collections.Generic.IEnumerable, System.Collections.Generic.IReadOnlyCollection, System.Collections.Generic.IReadOnlyList, System.Collections.IEnumerable { void Clear(); } @@ -497,9 +497,4 @@ namespace MockHttp.Responses public bool TryGetService([System.Diagnostics.CodeAnalysis.NotNullWhen(true)] out TService? service) { } } public delegate System.Threading.Tasks.Task ResponseHandlerDelegate(MockHttp.Responses.MockHttpRequestContext requestContext, System.Net.Http.HttpResponseMessage responseMessage, System.Threading.CancellationToken cancellationToken); -} -namespace MockHttp.Threading -{ - [System.Obsolete("Will be removed in next version.")] - public interface IConcurrentReadOnlyCollection : System.Collections.Generic.IEnumerable, System.Collections.Generic.IReadOnlyCollection, System.Collections.Generic.IReadOnlyList, System.Collections.IEnumerable { } } \ No newline at end of file diff --git a/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_Framework_4.8.verified.txt b/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_Framework_4.8.verified.txt index 87630507..0ce1fbe3 100644 --- a/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_Framework_4.8.verified.txt +++ b/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_Framework_4.8.verified.txt @@ -40,7 +40,7 @@ namespace MockHttp System.Collections.Generic.IReadOnlyCollection Matchers { get; } System.Net.Http.HttpRequestMessage Request { get; } } - public interface IInvokedHttpRequestCollection : MockHttp.Threading.IConcurrentReadOnlyCollection, System.Collections.Generic.IEnumerable, System.Collections.Generic.IReadOnlyCollection, System.Collections.Generic.IReadOnlyList, System.Collections.IEnumerable + public interface IInvokedHttpRequestCollection : System.Collections.Generic.IEnumerable, System.Collections.Generic.IReadOnlyCollection, System.Collections.Generic.IReadOnlyList, System.Collections.IEnumerable { void Clear(); } @@ -497,9 +497,4 @@ namespace MockHttp.Responses public bool TryGetService([System.Diagnostics.CodeAnalysis.NotNullWhen(true)] out TService? service) { } } public delegate System.Threading.Tasks.Task ResponseHandlerDelegate(MockHttp.Responses.MockHttpRequestContext requestContext, System.Net.Http.HttpResponseMessage responseMessage, System.Threading.CancellationToken cancellationToken); -} -namespace MockHttp.Threading -{ - [System.Obsolete("Will be removed in next version.")] - public interface IConcurrentReadOnlyCollection : System.Collections.Generic.IEnumerable, System.Collections.Generic.IReadOnlyCollection, System.Collections.Generic.IReadOnlyList, System.Collections.IEnumerable { } } \ No newline at end of file diff --git a/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_Standard_2.1.verified.txt b/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_Standard_2.1.verified.txt index 407b85cf..5d7dd446 100644 --- a/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_Standard_2.1.verified.txt +++ b/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_Standard_2.1.verified.txt @@ -40,7 +40,7 @@ namespace MockHttp System.Collections.Generic.IReadOnlyCollection Matchers { get; } System.Net.Http.HttpRequestMessage Request { get; } } - public interface IInvokedHttpRequestCollection : MockHttp.Threading.IConcurrentReadOnlyCollection, System.Collections.Generic.IEnumerable, System.Collections.Generic.IReadOnlyCollection, System.Collections.Generic.IReadOnlyList, System.Collections.IEnumerable + public interface IInvokedHttpRequestCollection : System.Collections.Generic.IEnumerable, System.Collections.Generic.IReadOnlyCollection, System.Collections.Generic.IReadOnlyList, System.Collections.IEnumerable { void Clear(); } @@ -497,9 +497,4 @@ namespace MockHttp.Responses public bool TryGetService([System.Diagnostics.CodeAnalysis.NotNullWhen(true)] out TService? service) { } } public delegate System.Threading.Tasks.Task ResponseHandlerDelegate(MockHttp.Responses.MockHttpRequestContext requestContext, System.Net.Http.HttpResponseMessage responseMessage, System.Threading.CancellationToken cancellationToken); -} -namespace MockHttp.Threading -{ - [System.Obsolete("Will be removed in next version.")] - public interface IConcurrentReadOnlyCollection : System.Collections.Generic.IEnumerable, System.Collections.Generic.IReadOnlyCollection, System.Collections.Generic.IReadOnlyList, System.Collections.IEnumerable { } } \ No newline at end of file From eb4d65ea59e50705f5021b322d47148c9e82c8ae Mon Sep 17 00:00:00 2001 From: skwasjer <11424653+skwasjer@users.noreply.github.com> Date: Sun, 29 Sep 2024 23:48:12 +0200 Subject: [PATCH 2/8] fix(CA1716)!: do not use reserved language keyword 'Next' --- .../Extensions/ResponseBuilderExtensions.cs | 9 +++++++-- .../Response/Behaviors/HttpContentBehavior.cs | 9 +++++++-- .../Response/Behaviors/HttpHeaderBehavior.cs | 9 +++++++-- .../Response/Behaviors/NetworkLatencyBehavior.cs | 9 +++++++-- .../Response/Behaviors/StatusCodeBehavior.cs | 9 +++++++-- .../Internal/Response/Behaviors/TimeoutBehavior.cs | 7 ++++++- .../Response/Behaviors/TransferRateBehavior.cs | 9 +++++++-- .../Flow/Response/EnsureHttpContentBehavior.cs | 10 +++++----- src/MockHttp/Responses/IResponseBehavior.cs | 12 +++++++++--- ...ApiTests.Api_has_not_changed.NET_6.0.verified.txt | 2 +- ...ApiTests.Api_has_not_changed.NET_8.0.verified.txt | 2 +- ..._has_not_changed.NET_Framework_4.6.2.verified.txt | 2 +- ..._has_not_changed.NET_Framework_4.7.2.verified.txt | 2 +- ...pi_has_not_changed.NET_Framework_4.8.verified.txt | 2 +- ...Api_has_not_changed.NET_Standard_2.1.verified.txt | 2 +- 15 files changed, 68 insertions(+), 27 deletions(-) diff --git a/src/MockHttp.Json/Extensions/ResponseBuilderExtensions.cs b/src/MockHttp.Json/Extensions/ResponseBuilderExtensions.cs index 0d1bc38a..8dd1c7c6 100644 --- a/src/MockHttp.Json/Extensions/ResponseBuilderExtensions.cs +++ b/src/MockHttp.Json/Extensions/ResponseBuilderExtensions.cs @@ -71,7 +71,12 @@ internal JsonContentBehavior _adapter = adapter; } - public Task HandleAsync(MockHttpRequestContext requestContext, HttpResponseMessage responseMessage, ResponseHandlerDelegate next, CancellationToken cancellationToken) + public Task HandleAsync( + MockHttpRequestContext requestContext, + HttpResponseMessage responseMessage, + ResponseHandlerDelegate nextHandler, + CancellationToken cancellationToken + ) { IJsonAdapter jsonSerializerAdapter = _adapter ?? requestContext.GetAdapter(); object? value = _jsonContentFactory(); @@ -84,7 +89,7 @@ public Task HandleAsync(MockHttpRequestContext requestContext, HttpResponseMessa } }; - return next(requestContext, responseMessage, cancellationToken); + return nextHandler(requestContext, responseMessage, cancellationToken); } } } diff --git a/src/MockHttp/Internal/Response/Behaviors/HttpContentBehavior.cs b/src/MockHttp/Internal/Response/Behaviors/HttpContentBehavior.cs index e701590d..2802805d 100644 --- a/src/MockHttp/Internal/Response/Behaviors/HttpContentBehavior.cs +++ b/src/MockHttp/Internal/Response/Behaviors/HttpContentBehavior.cs @@ -12,9 +12,14 @@ public HttpContentBehavior(Func> httpConten _httpContentFactory = httpContentFactory ?? throw new ArgumentNullException(nameof(httpContentFactory)); } - public async Task HandleAsync(MockHttpRequestContext requestContext, HttpResponseMessage responseMessage, ResponseHandlerDelegate next, CancellationToken cancellationToken) + public async Task HandleAsync( + MockHttpRequestContext requestContext, + HttpResponseMessage responseMessage, + ResponseHandlerDelegate nextHandler, + CancellationToken cancellationToken + ) { responseMessage.Content = await _httpContentFactory(cancellationToken).ConfigureAwait(false); - await next(requestContext, responseMessage, cancellationToken).ConfigureAwait(false); + await nextHandler(requestContext, responseMessage, cancellationToken).ConfigureAwait(false); } } diff --git a/src/MockHttp/Internal/Response/Behaviors/HttpHeaderBehavior.cs b/src/MockHttp/Internal/Response/Behaviors/HttpHeaderBehavior.cs index 314e9bf0..d96c5124 100644 --- a/src/MockHttp/Internal/Response/Behaviors/HttpHeaderBehavior.cs +++ b/src/MockHttp/Internal/Response/Behaviors/HttpHeaderBehavior.cs @@ -37,7 +37,12 @@ public HttpHeaderBehavior(IEnumerable> _headers = headers?.ToList() ?? throw new ArgumentNullException(nameof(headers)); } - public Task HandleAsync(MockHttpRequestContext requestContext, HttpResponseMessage responseMessage, ResponseHandlerDelegate next, CancellationToken cancellationToken) + public Task HandleAsync( + MockHttpRequestContext requestContext, + HttpResponseMessage responseMessage, + ResponseHandlerDelegate nextHandler, + CancellationToken cancellationToken + ) { // ReSharper disable once UseDeconstruction foreach (KeyValuePair> header in _headers) @@ -45,7 +50,7 @@ public Task HandleAsync(MockHttpRequestContext requestContext, HttpResponseMessa Add(header, responseMessage); } - return next(requestContext, responseMessage, cancellationToken); + return nextHandler(requestContext, responseMessage, cancellationToken); } /// diff --git a/src/MockHttp/Internal/Response/Behaviors/NetworkLatencyBehavior.cs b/src/MockHttp/Internal/Response/Behaviors/NetworkLatencyBehavior.cs index 18eeeb71..ec86e427 100644 --- a/src/MockHttp/Internal/Response/Behaviors/NetworkLatencyBehavior.cs +++ b/src/MockHttp/Internal/Response/Behaviors/NetworkLatencyBehavior.cs @@ -12,8 +12,13 @@ public NetworkLatencyBehavior(NetworkLatency networkLatency) _networkLatency = networkLatency ?? throw new ArgumentNullException(nameof(networkLatency)); } - public Task HandleAsync(MockHttpRequestContext requestContext, HttpResponseMessage responseMessage, ResponseHandlerDelegate next, CancellationToken cancellationToken) + public Task HandleAsync( + MockHttpRequestContext requestContext, + HttpResponseMessage responseMessage, + ResponseHandlerDelegate nextHandler, + CancellationToken cancellationToken + ) { - return _networkLatency.SimulateAsync(() => next(requestContext, responseMessage, cancellationToken), cancellationToken); + return _networkLatency.SimulateAsync(() => nextHandler(requestContext, responseMessage, cancellationToken), cancellationToken); } } diff --git a/src/MockHttp/Internal/Response/Behaviors/StatusCodeBehavior.cs b/src/MockHttp/Internal/Response/Behaviors/StatusCodeBehavior.cs index a9a3c9c0..2e10c7df 100644 --- a/src/MockHttp/Internal/Response/Behaviors/StatusCodeBehavior.cs +++ b/src/MockHttp/Internal/Response/Behaviors/StatusCodeBehavior.cs @@ -20,7 +20,12 @@ public StatusCodeBehavior(HttpStatusCode statusCode, string? reasonPhrase) _reasonPhrase = reasonPhrase; } - public Task HandleAsync(MockHttpRequestContext requestContext, HttpResponseMessage responseMessage, ResponseHandlerDelegate next, CancellationToken cancellationToken) + public Task HandleAsync( + MockHttpRequestContext requestContext, + HttpResponseMessage responseMessage, + ResponseHandlerDelegate nextHandler, + CancellationToken cancellationToken + ) { responseMessage.StatusCode = _statusCode; if (_reasonPhrase is not null) @@ -28,6 +33,6 @@ public Task HandleAsync(MockHttpRequestContext requestContext, HttpResponseMessa responseMessage.ReasonPhrase = _reasonPhrase; } - return next(requestContext, responseMessage, cancellationToken); + return nextHandler(requestContext, responseMessage, cancellationToken); } } diff --git a/src/MockHttp/Internal/Response/Behaviors/TimeoutBehavior.cs b/src/MockHttp/Internal/Response/Behaviors/TimeoutBehavior.cs index ea934661..23d32e1b 100644 --- a/src/MockHttp/Internal/Response/Behaviors/TimeoutBehavior.cs +++ b/src/MockHttp/Internal/Response/Behaviors/TimeoutBehavior.cs @@ -19,7 +19,12 @@ public TimeoutBehavior(TimeSpan timeoutAfter) _timeoutAfter = timeoutAfter; } - public Task HandleAsync(MockHttpRequestContext requestContext, HttpResponseMessage responseMessage, ResponseHandlerDelegate next, CancellationToken cancellationToken) + public Task HandleAsync( + MockHttpRequestContext requestContext, + HttpResponseMessage responseMessage, + ResponseHandlerDelegate nextHandler, + CancellationToken cancellationToken + ) { // It is somewhat unintuitive to throw TaskCanceledException but this is what HttpClient does, // so we simulate same behavior. diff --git a/src/MockHttp/Internal/Response/Behaviors/TransferRateBehavior.cs b/src/MockHttp/Internal/Response/Behaviors/TransferRateBehavior.cs index cd6d830f..12b5eba7 100644 --- a/src/MockHttp/Internal/Response/Behaviors/TransferRateBehavior.cs +++ b/src/MockHttp/Internal/Response/Behaviors/TransferRateBehavior.cs @@ -18,9 +18,14 @@ public TransferRateBehavior(int bitRate) _bitRate = bitRate; } - public async Task HandleAsync(MockHttpRequestContext requestContext, HttpResponseMessage responseMessage, ResponseHandlerDelegate next, CancellationToken cancellationToken) + public async Task HandleAsync( + MockHttpRequestContext requestContext, + HttpResponseMessage responseMessage, + ResponseHandlerDelegate nextHandler, + CancellationToken cancellationToken + ) { - await next(requestContext, responseMessage, cancellationToken).ConfigureAwait(false); + await nextHandler(requestContext, responseMessage, cancellationToken).ConfigureAwait(false); responseMessage.Content = new RateLimitedHttpContent(responseMessage.Content, _bitRate); } diff --git a/src/MockHttp/Language/Flow/Response/EnsureHttpContentBehavior.cs b/src/MockHttp/Language/Flow/Response/EnsureHttpContentBehavior.cs index bd3e6bf6..86637394 100644 --- a/src/MockHttp/Language/Flow/Response/EnsureHttpContentBehavior.cs +++ b/src/MockHttp/Language/Flow/Response/EnsureHttpContentBehavior.cs @@ -6,15 +6,15 @@ namespace MockHttp.Language.Flow.Response; internal sealed class EnsureHttpContentBehavior : IResponseBehavior { - public Task HandleAsync - ( + public Task HandleAsync( MockHttpRequestContext requestContext, HttpResponseMessage responseMessage, - ResponseHandlerDelegate next, - CancellationToken cancellationToken) + ResponseHandlerDelegate nextHandler, + CancellationToken cancellationToken + ) { // ReSharper disable once NullCoalescingConditionIsAlwaysNotNullAccordingToAPIContract responseMessage.Content ??= new EmptyContent(); - return next(requestContext, responseMessage, cancellationToken); + return nextHandler(requestContext, responseMessage, cancellationToken); } } diff --git a/src/MockHttp/Responses/IResponseBehavior.cs b/src/MockHttp/Responses/IResponseBehavior.cs index 8b18be31..659c444c 100644 --- a/src/MockHttp/Responses/IResponseBehavior.cs +++ b/src/MockHttp/Responses/IResponseBehavior.cs @@ -12,12 +12,18 @@ public interface IResponseBehavior { /// - /// Executes the behavior. Call to execute the next behavior in the response pipeline and use its returned response message. + /// Executes the behavior. Call to execute the next behavior in the response pipeline and use its returned + /// response message. /// /// The current request context. /// The response message. - /// The next behavior. + /// The next handler. /// The cancellation token. /// An awaitable that upon completion returns the HTTP response message. - Task HandleAsync(MockHttpRequestContext requestContext, HttpResponseMessage responseMessage, ResponseHandlerDelegate next, CancellationToken cancellationToken); + Task HandleAsync( + MockHttpRequestContext requestContext, + HttpResponseMessage responseMessage, + ResponseHandlerDelegate nextHandler, + CancellationToken cancellationToken + ); } diff --git a/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_6.0.verified.txt b/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_6.0.verified.txt index 1e5973cd..dfca434f 100644 --- a/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_6.0.verified.txt +++ b/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_6.0.verified.txt @@ -483,7 +483,7 @@ namespace MockHttp.Responses { public interface IResponseBehavior { - System.Threading.Tasks.Task HandleAsync(MockHttp.Responses.MockHttpRequestContext requestContext, System.Net.Http.HttpResponseMessage responseMessage, MockHttp.Responses.ResponseHandlerDelegate next, System.Threading.CancellationToken cancellationToken); + System.Threading.Tasks.Task HandleAsync(MockHttp.Responses.MockHttpRequestContext requestContext, System.Net.Http.HttpResponseMessage responseMessage, MockHttp.Responses.ResponseHandlerDelegate nextHandler, System.Threading.CancellationToken cancellationToken); } public interface IResponseStrategy { diff --git a/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_8.0.verified.txt b/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_8.0.verified.txt index bc6ee63d..1130ba1a 100644 --- a/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_8.0.verified.txt +++ b/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_8.0.verified.txt @@ -484,7 +484,7 @@ namespace MockHttp.Responses { public interface IResponseBehavior { - System.Threading.Tasks.Task HandleAsync(MockHttp.Responses.MockHttpRequestContext requestContext, System.Net.Http.HttpResponseMessage responseMessage, MockHttp.Responses.ResponseHandlerDelegate next, System.Threading.CancellationToken cancellationToken); + System.Threading.Tasks.Task HandleAsync(MockHttp.Responses.MockHttpRequestContext requestContext, System.Net.Http.HttpResponseMessage responseMessage, MockHttp.Responses.ResponseHandlerDelegate nextHandler, System.Threading.CancellationToken cancellationToken); } public interface IResponseStrategy { diff --git a/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_Framework_4.6.2.verified.txt b/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_Framework_4.6.2.verified.txt index ffdc6384..6b0e8450 100644 --- a/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_Framework_4.6.2.verified.txt +++ b/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_Framework_4.6.2.verified.txt @@ -483,7 +483,7 @@ namespace MockHttp.Responses { public interface IResponseBehavior { - System.Threading.Tasks.Task HandleAsync(MockHttp.Responses.MockHttpRequestContext requestContext, System.Net.Http.HttpResponseMessage responseMessage, MockHttp.Responses.ResponseHandlerDelegate next, System.Threading.CancellationToken cancellationToken); + System.Threading.Tasks.Task HandleAsync(MockHttp.Responses.MockHttpRequestContext requestContext, System.Net.Http.HttpResponseMessage responseMessage, MockHttp.Responses.ResponseHandlerDelegate nextHandler, System.Threading.CancellationToken cancellationToken); } public interface IResponseStrategy { diff --git a/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_Framework_4.7.2.verified.txt b/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_Framework_4.7.2.verified.txt index bf6336d4..89964b22 100644 --- a/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_Framework_4.7.2.verified.txt +++ b/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_Framework_4.7.2.verified.txt @@ -483,7 +483,7 @@ namespace MockHttp.Responses { public interface IResponseBehavior { - System.Threading.Tasks.Task HandleAsync(MockHttp.Responses.MockHttpRequestContext requestContext, System.Net.Http.HttpResponseMessage responseMessage, MockHttp.Responses.ResponseHandlerDelegate next, System.Threading.CancellationToken cancellationToken); + System.Threading.Tasks.Task HandleAsync(MockHttp.Responses.MockHttpRequestContext requestContext, System.Net.Http.HttpResponseMessage responseMessage, MockHttp.Responses.ResponseHandlerDelegate nextHandler, System.Threading.CancellationToken cancellationToken); } public interface IResponseStrategy { diff --git a/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_Framework_4.8.verified.txt b/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_Framework_4.8.verified.txt index 0ce1fbe3..c42c768a 100644 --- a/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_Framework_4.8.verified.txt +++ b/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_Framework_4.8.verified.txt @@ -483,7 +483,7 @@ namespace MockHttp.Responses { public interface IResponseBehavior { - System.Threading.Tasks.Task HandleAsync(MockHttp.Responses.MockHttpRequestContext requestContext, System.Net.Http.HttpResponseMessage responseMessage, MockHttp.Responses.ResponseHandlerDelegate next, System.Threading.CancellationToken cancellationToken); + System.Threading.Tasks.Task HandleAsync(MockHttp.Responses.MockHttpRequestContext requestContext, System.Net.Http.HttpResponseMessage responseMessage, MockHttp.Responses.ResponseHandlerDelegate nextHandler, System.Threading.CancellationToken cancellationToken); } public interface IResponseStrategy { diff --git a/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_Standard_2.1.verified.txt b/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_Standard_2.1.verified.txt index 5d7dd446..b7d18e3c 100644 --- a/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_Standard_2.1.verified.txt +++ b/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_Standard_2.1.verified.txt @@ -483,7 +483,7 @@ namespace MockHttp.Responses { public interface IResponseBehavior { - System.Threading.Tasks.Task HandleAsync(MockHttp.Responses.MockHttpRequestContext requestContext, System.Net.Http.HttpResponseMessage responseMessage, MockHttp.Responses.ResponseHandlerDelegate next, System.Threading.CancellationToken cancellationToken); + System.Threading.Tasks.Task HandleAsync(MockHttp.Responses.MockHttpRequestContext requestContext, System.Net.Http.HttpResponseMessage responseMessage, MockHttp.Responses.ResponseHandlerDelegate nextHandler, System.Threading.CancellationToken cancellationToken); } public interface IResponseStrategy { From ed4488674bdc30a0a6df05ebab4ef3846848314f Mon Sep 17 00:00:00 2001 From: skwasjer <11424653+skwasjer@users.noreply.github.com> Date: Sun, 29 Sep 2024 23:50:04 +0200 Subject: [PATCH 3/8] fix(CA1711)!: delegate names should not end with Delegate. --- .../Extensions/ResponseBuilderExtensions.cs | 2 +- .../Internal/Response/Behaviors/HttpContentBehavior.cs | 2 +- .../Internal/Response/Behaviors/HttpHeaderBehavior.cs | 2 +- .../Response/Behaviors/NetworkLatencyBehavior.cs | 2 +- .../Internal/Response/Behaviors/StatusCodeBehavior.cs | 2 +- .../Internal/Response/Behaviors/TimeoutBehavior.cs | 2 +- .../Response/Behaviors/TransferRateBehavior.cs | 2 +- .../Flow/Response/EnsureHttpContentBehavior.cs | 2 +- src/MockHttp/Language/Flow/Response/ResponseBuilder.cs | 10 ++++++++-- src/MockHttp/Responses/IResponseBehavior.cs | 8 ++++++-- .../Response/Behaviors/TimeoutBehaviorTests.cs | 4 ++-- ...icApiTests.Api_has_not_changed.NET_6.0.verified.txt | 4 ++-- ...icApiTests.Api_has_not_changed.NET_8.0.verified.txt | 4 ++-- ...pi_has_not_changed.NET_Framework_4.6.2.verified.txt | 4 ++-- ...pi_has_not_changed.NET_Framework_4.7.2.verified.txt | 4 ++-- ....Api_has_not_changed.NET_Framework_4.8.verified.txt | 4 ++-- ...s.Api_has_not_changed.NET_Standard_2.1.verified.txt | 4 ++-- 17 files changed, 36 insertions(+), 26 deletions(-) diff --git a/src/MockHttp.Json/Extensions/ResponseBuilderExtensions.cs b/src/MockHttp.Json/Extensions/ResponseBuilderExtensions.cs index 8dd1c7c6..ab480883 100644 --- a/src/MockHttp.Json/Extensions/ResponseBuilderExtensions.cs +++ b/src/MockHttp.Json/Extensions/ResponseBuilderExtensions.cs @@ -74,7 +74,7 @@ internal JsonContentBehavior public Task HandleAsync( MockHttpRequestContext requestContext, HttpResponseMessage responseMessage, - ResponseHandlerDelegate nextHandler, + ResponseHandler nextHandler, CancellationToken cancellationToken ) { diff --git a/src/MockHttp/Internal/Response/Behaviors/HttpContentBehavior.cs b/src/MockHttp/Internal/Response/Behaviors/HttpContentBehavior.cs index 2802805d..96bcdb95 100644 --- a/src/MockHttp/Internal/Response/Behaviors/HttpContentBehavior.cs +++ b/src/MockHttp/Internal/Response/Behaviors/HttpContentBehavior.cs @@ -15,7 +15,7 @@ public HttpContentBehavior(Func> httpConten public async Task HandleAsync( MockHttpRequestContext requestContext, HttpResponseMessage responseMessage, - ResponseHandlerDelegate nextHandler, + ResponseHandler nextHandler, CancellationToken cancellationToken ) { diff --git a/src/MockHttp/Internal/Response/Behaviors/HttpHeaderBehavior.cs b/src/MockHttp/Internal/Response/Behaviors/HttpHeaderBehavior.cs index d96c5124..6b952dd1 100644 --- a/src/MockHttp/Internal/Response/Behaviors/HttpHeaderBehavior.cs +++ b/src/MockHttp/Internal/Response/Behaviors/HttpHeaderBehavior.cs @@ -40,7 +40,7 @@ public HttpHeaderBehavior(IEnumerable> public Task HandleAsync( MockHttpRequestContext requestContext, HttpResponseMessage responseMessage, - ResponseHandlerDelegate nextHandler, + ResponseHandler nextHandler, CancellationToken cancellationToken ) { diff --git a/src/MockHttp/Internal/Response/Behaviors/NetworkLatencyBehavior.cs b/src/MockHttp/Internal/Response/Behaviors/NetworkLatencyBehavior.cs index ec86e427..9ab511bf 100644 --- a/src/MockHttp/Internal/Response/Behaviors/NetworkLatencyBehavior.cs +++ b/src/MockHttp/Internal/Response/Behaviors/NetworkLatencyBehavior.cs @@ -15,7 +15,7 @@ public NetworkLatencyBehavior(NetworkLatency networkLatency) public Task HandleAsync( MockHttpRequestContext requestContext, HttpResponseMessage responseMessage, - ResponseHandlerDelegate nextHandler, + ResponseHandler nextHandler, CancellationToken cancellationToken ) { diff --git a/src/MockHttp/Internal/Response/Behaviors/StatusCodeBehavior.cs b/src/MockHttp/Internal/Response/Behaviors/StatusCodeBehavior.cs index 2e10c7df..a6ac5b4c 100644 --- a/src/MockHttp/Internal/Response/Behaviors/StatusCodeBehavior.cs +++ b/src/MockHttp/Internal/Response/Behaviors/StatusCodeBehavior.cs @@ -23,7 +23,7 @@ public StatusCodeBehavior(HttpStatusCode statusCode, string? reasonPhrase) public Task HandleAsync( MockHttpRequestContext requestContext, HttpResponseMessage responseMessage, - ResponseHandlerDelegate nextHandler, + ResponseHandler nextHandler, CancellationToken cancellationToken ) { diff --git a/src/MockHttp/Internal/Response/Behaviors/TimeoutBehavior.cs b/src/MockHttp/Internal/Response/Behaviors/TimeoutBehavior.cs index 23d32e1b..10b00f14 100644 --- a/src/MockHttp/Internal/Response/Behaviors/TimeoutBehavior.cs +++ b/src/MockHttp/Internal/Response/Behaviors/TimeoutBehavior.cs @@ -22,7 +22,7 @@ public TimeoutBehavior(TimeSpan timeoutAfter) public Task HandleAsync( MockHttpRequestContext requestContext, HttpResponseMessage responseMessage, - ResponseHandlerDelegate nextHandler, + ResponseHandler nextHandler, CancellationToken cancellationToken ) { diff --git a/src/MockHttp/Internal/Response/Behaviors/TransferRateBehavior.cs b/src/MockHttp/Internal/Response/Behaviors/TransferRateBehavior.cs index 12b5eba7..47869316 100644 --- a/src/MockHttp/Internal/Response/Behaviors/TransferRateBehavior.cs +++ b/src/MockHttp/Internal/Response/Behaviors/TransferRateBehavior.cs @@ -21,7 +21,7 @@ public TransferRateBehavior(int bitRate) public async Task HandleAsync( MockHttpRequestContext requestContext, HttpResponseMessage responseMessage, - ResponseHandlerDelegate nextHandler, + ResponseHandler nextHandler, CancellationToken cancellationToken ) { diff --git a/src/MockHttp/Language/Flow/Response/EnsureHttpContentBehavior.cs b/src/MockHttp/Language/Flow/Response/EnsureHttpContentBehavior.cs index 86637394..7fe2b76f 100644 --- a/src/MockHttp/Language/Flow/Response/EnsureHttpContentBehavior.cs +++ b/src/MockHttp/Language/Flow/Response/EnsureHttpContentBehavior.cs @@ -9,7 +9,7 @@ internal sealed class EnsureHttpContentBehavior public Task HandleAsync( MockHttpRequestContext requestContext, HttpResponseMessage responseMessage, - ResponseHandlerDelegate nextHandler, + ResponseHandler nextHandler, CancellationToken cancellationToken ) { diff --git a/src/MockHttp/Language/Flow/Response/ResponseBuilder.cs b/src/MockHttp/Language/Flow/Response/ResponseBuilder.cs index d38e27db..a7bfcc38 100644 --- a/src/MockHttp/Language/Flow/Response/ResponseBuilder.cs +++ b/src/MockHttp/Language/Flow/Response/ResponseBuilder.cs @@ -96,8 +96,14 @@ static Task Seed(MockHttpRequestContext requestContext, HttpResponseMessage resp }; await _invertedBehaviors - .Aggregate((ResponseHandlerDelegate)Seed, - (next, pipeline) => (context, message, ct) => pipeline.HandleAsync(context, message, next, ct) + .Aggregate( + (ResponseHandler)Seed, + (next, pipeline) => (context, message, ct) => pipeline.HandleAsync( + context, + message, + next, + ct + ) )(requestContext, response, cancellationToken) .ConfigureAwait(false); diff --git a/src/MockHttp/Responses/IResponseBehavior.cs b/src/MockHttp/Responses/IResponseBehavior.cs index 659c444c..024f712e 100644 --- a/src/MockHttp/Responses/IResponseBehavior.cs +++ b/src/MockHttp/Responses/IResponseBehavior.cs @@ -4,7 +4,11 @@ /// A delegate which when executed returns a configured HTTP response. /// /// -public delegate Task ResponseHandlerDelegate(MockHttpRequestContext requestContext, HttpResponseMessage responseMessage, CancellationToken cancellationToken); +public delegate Task ResponseHandler( + MockHttpRequestContext requestContext, + HttpResponseMessage responseMessage, + CancellationToken cancellationToken +); /// /// Describes a way to apply a response behavior in a response builder pipeline. @@ -23,7 +27,7 @@ public interface IResponseBehavior Task HandleAsync( MockHttpRequestContext requestContext, HttpResponseMessage responseMessage, - ResponseHandlerDelegate nextHandler, + ResponseHandler nextHandler, CancellationToken cancellationToken ); } diff --git a/test/MockHttp.Tests/Internal/Response/Behaviors/TimeoutBehaviorTests.cs b/test/MockHttp.Tests/Internal/Response/Behaviors/TimeoutBehaviorTests.cs index 0f88e407..05155565 100644 --- a/test/MockHttp.Tests/Internal/Response/Behaviors/TimeoutBehaviorTests.cs +++ b/test/MockHttp.Tests/Internal/Response/Behaviors/TimeoutBehaviorTests.cs @@ -16,7 +16,7 @@ public async Task Given_that_timeout_is_not_zero_when_sending_it_should_timeout_ var timeout = TimeSpan.FromMilliseconds(timeoutInMilliseconds); var sut = new TimeoutBehavior(timeout); var sw = new Stopwatch(); - ResponseHandlerDelegate nextStub = Substitute.For(); + ResponseHandler nextStub = Substitute.For(); // Act Func act = () => sut.HandleAsync(new MockHttpRequestContext(new HttpRequestMessage()), new HttpResponseMessage(), nextStub, CancellationToken.None); @@ -40,7 +40,7 @@ public async Task Given_that_cancellation_token_is_cancelled_when_sending_it_sho var timeout = TimeSpan.FromSeconds(60); var sut = new TimeoutBehavior(timeout); var ct = new CancellationToken(true); - ResponseHandlerDelegate nextStub = Substitute.For(); + ResponseHandler nextStub = Substitute.For(); // Act var sw = Stopwatch.StartNew(); diff --git a/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_6.0.verified.txt b/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_6.0.verified.txt index dfca434f..ee7304cf 100644 --- a/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_6.0.verified.txt +++ b/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_6.0.verified.txt @@ -483,7 +483,7 @@ namespace MockHttp.Responses { public interface IResponseBehavior { - System.Threading.Tasks.Task HandleAsync(MockHttp.Responses.MockHttpRequestContext requestContext, System.Net.Http.HttpResponseMessage responseMessage, MockHttp.Responses.ResponseHandlerDelegate nextHandler, System.Threading.CancellationToken cancellationToken); + System.Threading.Tasks.Task HandleAsync(MockHttp.Responses.MockHttpRequestContext requestContext, System.Net.Http.HttpResponseMessage responseMessage, MockHttp.Responses.ResponseHandler nextHandler, System.Threading.CancellationToken cancellationToken); } public interface IResponseStrategy { @@ -496,5 +496,5 @@ namespace MockHttp.Responses public System.Collections.Generic.IReadOnlyDictionary Services { get; } public bool TryGetService([System.Diagnostics.CodeAnalysis.NotNullWhen(true)] out TService? service) { } } - public delegate System.Threading.Tasks.Task ResponseHandlerDelegate(MockHttp.Responses.MockHttpRequestContext requestContext, System.Net.Http.HttpResponseMessage responseMessage, System.Threading.CancellationToken cancellationToken); + public delegate System.Threading.Tasks.Task ResponseHandler(MockHttp.Responses.MockHttpRequestContext requestContext, System.Net.Http.HttpResponseMessage responseMessage, System.Threading.CancellationToken cancellationToken); } \ No newline at end of file diff --git a/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_8.0.verified.txt b/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_8.0.verified.txt index 1130ba1a..cc18e3a5 100644 --- a/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_8.0.verified.txt +++ b/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_8.0.verified.txt @@ -484,7 +484,7 @@ namespace MockHttp.Responses { public interface IResponseBehavior { - System.Threading.Tasks.Task HandleAsync(MockHttp.Responses.MockHttpRequestContext requestContext, System.Net.Http.HttpResponseMessage responseMessage, MockHttp.Responses.ResponseHandlerDelegate nextHandler, System.Threading.CancellationToken cancellationToken); + System.Threading.Tasks.Task HandleAsync(MockHttp.Responses.MockHttpRequestContext requestContext, System.Net.Http.HttpResponseMessage responseMessage, MockHttp.Responses.ResponseHandler nextHandler, System.Threading.CancellationToken cancellationToken); } public interface IResponseStrategy { @@ -497,5 +497,5 @@ namespace MockHttp.Responses public System.Collections.Generic.IReadOnlyDictionary Services { get; } public bool TryGetService([System.Diagnostics.CodeAnalysis.NotNullWhen(true)] out TService? service) { } } - public delegate System.Threading.Tasks.Task ResponseHandlerDelegate(MockHttp.Responses.MockHttpRequestContext requestContext, System.Net.Http.HttpResponseMessage responseMessage, System.Threading.CancellationToken cancellationToken); + public delegate System.Threading.Tasks.Task ResponseHandler(MockHttp.Responses.MockHttpRequestContext requestContext, System.Net.Http.HttpResponseMessage responseMessage, System.Threading.CancellationToken cancellationToken); } \ No newline at end of file diff --git a/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_Framework_4.6.2.verified.txt b/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_Framework_4.6.2.verified.txt index 6b0e8450..8aef646d 100644 --- a/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_Framework_4.6.2.verified.txt +++ b/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_Framework_4.6.2.verified.txt @@ -483,7 +483,7 @@ namespace MockHttp.Responses { public interface IResponseBehavior { - System.Threading.Tasks.Task HandleAsync(MockHttp.Responses.MockHttpRequestContext requestContext, System.Net.Http.HttpResponseMessage responseMessage, MockHttp.Responses.ResponseHandlerDelegate nextHandler, System.Threading.CancellationToken cancellationToken); + System.Threading.Tasks.Task HandleAsync(MockHttp.Responses.MockHttpRequestContext requestContext, System.Net.Http.HttpResponseMessage responseMessage, MockHttp.Responses.ResponseHandler nextHandler, System.Threading.CancellationToken cancellationToken); } public interface IResponseStrategy { @@ -496,5 +496,5 @@ namespace MockHttp.Responses public System.Collections.Generic.IReadOnlyDictionary Services { get; } public bool TryGetService([System.Diagnostics.CodeAnalysis.NotNullWhen(true)] out TService? service) { } } - public delegate System.Threading.Tasks.Task ResponseHandlerDelegate(MockHttp.Responses.MockHttpRequestContext requestContext, System.Net.Http.HttpResponseMessage responseMessage, System.Threading.CancellationToken cancellationToken); + public delegate System.Threading.Tasks.Task ResponseHandler(MockHttp.Responses.MockHttpRequestContext requestContext, System.Net.Http.HttpResponseMessage responseMessage, System.Threading.CancellationToken cancellationToken); } \ No newline at end of file diff --git a/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_Framework_4.7.2.verified.txt b/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_Framework_4.7.2.verified.txt index 89964b22..7022059c 100644 --- a/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_Framework_4.7.2.verified.txt +++ b/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_Framework_4.7.2.verified.txt @@ -483,7 +483,7 @@ namespace MockHttp.Responses { public interface IResponseBehavior { - System.Threading.Tasks.Task HandleAsync(MockHttp.Responses.MockHttpRequestContext requestContext, System.Net.Http.HttpResponseMessage responseMessage, MockHttp.Responses.ResponseHandlerDelegate nextHandler, System.Threading.CancellationToken cancellationToken); + System.Threading.Tasks.Task HandleAsync(MockHttp.Responses.MockHttpRequestContext requestContext, System.Net.Http.HttpResponseMessage responseMessage, MockHttp.Responses.ResponseHandler nextHandler, System.Threading.CancellationToken cancellationToken); } public interface IResponseStrategy { @@ -496,5 +496,5 @@ namespace MockHttp.Responses public System.Collections.Generic.IReadOnlyDictionary Services { get; } public bool TryGetService([System.Diagnostics.CodeAnalysis.NotNullWhen(true)] out TService? service) { } } - public delegate System.Threading.Tasks.Task ResponseHandlerDelegate(MockHttp.Responses.MockHttpRequestContext requestContext, System.Net.Http.HttpResponseMessage responseMessage, System.Threading.CancellationToken cancellationToken); + public delegate System.Threading.Tasks.Task ResponseHandler(MockHttp.Responses.MockHttpRequestContext requestContext, System.Net.Http.HttpResponseMessage responseMessage, System.Threading.CancellationToken cancellationToken); } \ No newline at end of file diff --git a/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_Framework_4.8.verified.txt b/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_Framework_4.8.verified.txt index c42c768a..d690f117 100644 --- a/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_Framework_4.8.verified.txt +++ b/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_Framework_4.8.verified.txt @@ -483,7 +483,7 @@ namespace MockHttp.Responses { public interface IResponseBehavior { - System.Threading.Tasks.Task HandleAsync(MockHttp.Responses.MockHttpRequestContext requestContext, System.Net.Http.HttpResponseMessage responseMessage, MockHttp.Responses.ResponseHandlerDelegate nextHandler, System.Threading.CancellationToken cancellationToken); + System.Threading.Tasks.Task HandleAsync(MockHttp.Responses.MockHttpRequestContext requestContext, System.Net.Http.HttpResponseMessage responseMessage, MockHttp.Responses.ResponseHandler nextHandler, System.Threading.CancellationToken cancellationToken); } public interface IResponseStrategy { @@ -496,5 +496,5 @@ namespace MockHttp.Responses public System.Collections.Generic.IReadOnlyDictionary Services { get; } public bool TryGetService([System.Diagnostics.CodeAnalysis.NotNullWhen(true)] out TService? service) { } } - public delegate System.Threading.Tasks.Task ResponseHandlerDelegate(MockHttp.Responses.MockHttpRequestContext requestContext, System.Net.Http.HttpResponseMessage responseMessage, System.Threading.CancellationToken cancellationToken); + public delegate System.Threading.Tasks.Task ResponseHandler(MockHttp.Responses.MockHttpRequestContext requestContext, System.Net.Http.HttpResponseMessage responseMessage, System.Threading.CancellationToken cancellationToken); } \ No newline at end of file diff --git a/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_Standard_2.1.verified.txt b/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_Standard_2.1.verified.txt index b7d18e3c..cd079334 100644 --- a/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_Standard_2.1.verified.txt +++ b/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_Standard_2.1.verified.txt @@ -483,7 +483,7 @@ namespace MockHttp.Responses { public interface IResponseBehavior { - System.Threading.Tasks.Task HandleAsync(MockHttp.Responses.MockHttpRequestContext requestContext, System.Net.Http.HttpResponseMessage responseMessage, MockHttp.Responses.ResponseHandlerDelegate nextHandler, System.Threading.CancellationToken cancellationToken); + System.Threading.Tasks.Task HandleAsync(MockHttp.Responses.MockHttpRequestContext requestContext, System.Net.Http.HttpResponseMessage responseMessage, MockHttp.Responses.ResponseHandler nextHandler, System.Threading.CancellationToken cancellationToken); } public interface IResponseStrategy { @@ -496,5 +496,5 @@ namespace MockHttp.Responses public System.Collections.Generic.IReadOnlyDictionary Services { get; } public bool TryGetService([System.Diagnostics.CodeAnalysis.NotNullWhen(true)] out TService? service) { } } - public delegate System.Threading.Tasks.Task ResponseHandlerDelegate(MockHttp.Responses.MockHttpRequestContext requestContext, System.Net.Http.HttpResponseMessage responseMessage, System.Threading.CancellationToken cancellationToken); + public delegate System.Threading.Tasks.Task ResponseHandler(MockHttp.Responses.MockHttpRequestContext requestContext, System.Net.Http.HttpResponseMessage responseMessage, System.Threading.CancellationToken cancellationToken); } \ No newline at end of file From 28440ccffb2ab891677a7ace636f1e1ddbebdaca Mon Sep 17 00:00:00 2001 From: skwasjer <11424653+skwasjer@users.noreply.github.com> Date: Sun, 29 Sep 2024 23:57:56 +0200 Subject: [PATCH 4/8] chore!: remove obsolete MockHttpServer overloads --- src/MockHttp.Server/MockHttpServer.cs | 54 ++++--------------- src/MockHttp.Server/Resources.Designer.cs | 9 ---- src/MockHttp.Server/Resources.resx | 3 -- .../MockHttpServerTests.cs | 35 +++--------- ...s.Api_has_not_changed.NET_6.0.verified.txt | 6 --- ...s.Api_has_not_changed.NET_8.0.verified.txt | 6 --- ..._has_not_changed.NET_Core_3.1.verified.txt | 6 --- 7 files changed, 17 insertions(+), 102 deletions(-) diff --git a/src/MockHttp.Server/MockHttpServer.cs b/src/MockHttp.Server/MockHttpServer.cs index 81d2fc02..c2659424 100644 --- a/src/MockHttp.Server/MockHttpServer.cs +++ b/src/MockHttp.Server/MockHttpServer.cs @@ -32,18 +32,8 @@ public sealed class MockHttpServer private IWebHost? _host; /// - /// Initializes a new instance of the using specified and configures it to listen on specified . - /// - /// The mock http handler. - /// The host URL the mock HTTP server will listen on. - [Obsolete("Use the overload accepting an System.Uri.")] - public MockHttpServer(MockHttpHandler mockHttpHandler, string hostUrl) - : this(mockHttpHandler, GetHostUrl(hostUrl)) - { - } - - /// - /// Initializes a new instance of the using specified and configures it to listen on specified . + /// Initializes a new instance of the using specified and configures it to + /// listen on specified . /// /// The mock http handler. /// The host URI the mock HTTP server will listen on. @@ -53,25 +43,19 @@ public MockHttpServer(MockHttpHandler mockHttpHandler, Uri hostUri) } /// - /// Initializes a new instance of the using specified and configures it to listen on specified . - /// - /// The mock http handler. - /// The logger factory to use to log pipeline requests to. - /// The host URL the mock HTTP server will listen on. - [Obsolete("Use the overload accepting an System.Uri.")] - public MockHttpServer(MockHttpHandler mockHttpHandler, ILoggerFactory? loggerFactory, string hostUrl) - : this(mockHttpHandler, loggerFactory, GetHostUrl(hostUrl)) - { - } - - /// - /// Initializes a new instance of the using specified and configures it to listen on specified . + /// Initializes a new instance of the using specified and configures it to + /// listen on specified . /// /// The mock http handler. /// The logger factory to use to log pipeline requests to. /// The host URI the mock HTTP server will listen on. public MockHttpServer(MockHttpHandler mockHttpHandler, ILoggerFactory? loggerFactory, Uri hostUri) { + if (hostUri is null) + { + throw new ArgumentNullException(nameof(hostUri)); + } + Handler = mockHttpHandler ?? throw new ArgumentNullException(nameof(mockHttpHandler)); _webHostBuilder = CreateWebHostBuilder(loggerFactory); _hostUri = new Uri(hostUri, "/"); // Ensure base URL. @@ -102,14 +86,6 @@ public async ValueTask DisposeAsync() /// public MockHttpHandler Handler { get; } - /// - /// Gets the host URL the mock HTTP server will listen on. - /// - [Obsolete("Use the HostUri instead.")] -#pragma warning disable CA1056 // URI-like properties should not be strings - public string HostUrl => HostUri.ToString().TrimEnd('/'); -#pragma warning restore CA1056 // URI-like properties should not be strings - /// /// Gets the host URI the mock HTTP server will listen on. /// @@ -237,18 +213,6 @@ internal void Configure(Action configureAppBuilder) _configureAppBuilder = configureAppBuilder; } - private static Uri GetHostUrl(string hostUrl) - { - if (hostUrl is null) - { - throw new ArgumentNullException(nameof(hostUrl)); - } - - return Uri.TryCreate(hostUrl, UriKind.Absolute, out Uri? uri) - ? uri - : throw new ArgumentException(Resources.Error_HostUrlIsNotValid, nameof(hostUrl)); - } - private void AddMockHttpServerHeader(IApplicationBuilder applicationBuilder) { applicationBuilder.Use(async (context, next) => diff --git a/src/MockHttp.Server/Resources.Designer.cs b/src/MockHttp.Server/Resources.Designer.cs index f0f46d20..eab82ed5 100644 --- a/src/MockHttp.Server/Resources.Designer.cs +++ b/src/MockHttp.Server/Resources.Designer.cs @@ -78,15 +78,6 @@ internal static string Debug_RequestHandled { } } - /// - /// Looks up a localized string similar to Specify a host URL.. - /// - internal static string Error_HostUrlIsNotValid { - get { - return ResourceManager.GetString("Error_HostUrlIsNotValid", resourceCulture); - } - } - /// /// Looks up a localized string similar to MockHttpServer failed to handle request. Please verify your mock setup is correct.. /// diff --git a/src/MockHttp.Server/Resources.resx b/src/MockHttp.Server/Resources.resx index e9716da8..ff404fd8 100644 --- a/src/MockHttp.Server/Resources.resx +++ b/src/MockHttp.Server/Resources.resx @@ -129,9 +129,6 @@ MockHttpServer received request. - - Specify a host URL. - HTTP response feature missing. diff --git a/test/MockHttp.Server.Tests/MockHttpServerTests.cs b/test/MockHttp.Server.Tests/MockHttpServerTests.cs index 77538956..2d155c6f 100644 --- a/test/MockHttp.Server.Tests/MockHttpServerTests.cs +++ b/test/MockHttp.Server.Tests/MockHttpServerTests.cs @@ -169,7 +169,7 @@ public async Task When_using_other_API_like_webRequest_it_should_respond_correct // Act #pragma warning disable CS0618 #pragma warning disable SYSLIB0014 // Type or member is obsolete - justification: testing other API's - var request = WebRequest.Create($"{_fixture.Server.HostUrl}/web-request"); + var request = WebRequest.Create($"{_fixture.Server.HostUri}web-request"); #pragma warning restore SYSLIB0014 // Type or member is obsolete #pragma warning restore CS0618 request.Method = "POST"; @@ -177,7 +177,7 @@ public async Task When_using_other_API_like_webRequest_it_should_respond_correct request.ContentType = MediaTypes.PlainText; await using (Stream requestStream = await request.GetRequestStreamAsync()) { - requestStream.Write(Encoding.ASCII.GetBytes("request-content")); + await requestStream.WriteAsync(Encoding.ASCII.GetBytes("request-content")); } // Assert @@ -286,50 +286,31 @@ public async Task When_creating_and_starting_server_with_null_logger_it_should_n } [Fact] - [Obsolete("Removed in next major version.")] public void When_creating_server_with_null_host_it_should_throw() { - string? hostUrl = null; + Uri? hostUri = null; // Act -#pragma warning disable CS8604 - Func act = () => new MockHttpServer(new MockHttpHandler(), hostUrl); -#pragma warning restore CS8604 + Func act = () => new MockHttpServer(new MockHttpHandler(), hostUri!); // Assert - act.Should().Throw().WithParameterName(nameof(hostUrl)); + act.Should().Throw().WithParameterName(nameof(hostUri)); } [Fact] - [Obsolete("Removed in next major version.")] - public void When_creating_server_with_invalid_host_it_should_throw() - { - const string hostUrl = "relative/uri/is/invalid"; - - // Act - // ReSharper disable once ExpressionIsAlwaysNull - Func act = () => new MockHttpServer(new MockHttpHandler(), hostUrl); - - // Assert - act.Should().Throw().WithParameterName(nameof(hostUrl)); - } - - [Fact] - [Obsolete("Removed in next major version.")] public async Task When_creating_server_with_absolute_uri_it_should_not_throw_and_take_host_from_url() { - var hostUrl = new Uri("https://relative:789/uri/is/invalid"); + var hostUri = new Uri("https://relative:789/uri/is/invalid"); const string expectedHostUrl = "https://relative:789"; // Act - // ReSharper disable once ExpressionIsAlwaysNull - Func act = () => new MockHttpServer(new MockHttpHandler(), hostUrl); + Func act = () => new MockHttpServer(new MockHttpHandler(), hostUri); // Assert MockHttpServer server = act.Should().NotThrow().Which; await using (server) { - act.Should().NotThrow().Which.HostUrl.Should().Be(expectedHostUrl); + act.Should().NotThrow().Which.HostUri.Should().Be(expectedHostUrl); } } diff --git a/test/MockHttp.Server.Tests/PublicApiTests.Api_has_not_changed.NET_6.0.verified.txt b/test/MockHttp.Server.Tests/PublicApiTests.Api_has_not_changed.NET_6.0.verified.txt index 940f517d..143aa9ce 100644 --- a/test/MockHttp.Server.Tests/PublicApiTests.Api_has_not_changed.NET_6.0.verified.txt +++ b/test/MockHttp.Server.Tests/PublicApiTests.Api_has_not_changed.NET_6.0.verified.txt @@ -5,16 +5,10 @@ namespace MockHttp { public sealed class MockHttpServer : System.IAsyncDisposable, System.IDisposable { - [System.Obsolete("Use the overload accepting an System.Uri.")] - public MockHttpServer(MockHttp.MockHttpHandler mockHttpHandler, string hostUrl) { } public MockHttpServer(MockHttp.MockHttpHandler mockHttpHandler, System.Uri hostUri) { } - [System.Obsolete("Use the overload accepting an System.Uri.")] - public MockHttpServer(MockHttp.MockHttpHandler mockHttpHandler, Microsoft.Extensions.Logging.ILoggerFactory? loggerFactory, string hostUrl) { } public MockHttpServer(MockHttp.MockHttpHandler mockHttpHandler, Microsoft.Extensions.Logging.ILoggerFactory? loggerFactory, System.Uri hostUri) { } public MockHttp.MockHttpHandler Handler { get; } public System.Uri HostUri { get; } - [System.Obsolete("Use the HostUri instead.")] - public string HostUrl { get; } public bool IsStarted { get; } public System.Net.Http.HttpClient CreateClient() { } public void Dispose() { } diff --git a/test/MockHttp.Server.Tests/PublicApiTests.Api_has_not_changed.NET_8.0.verified.txt b/test/MockHttp.Server.Tests/PublicApiTests.Api_has_not_changed.NET_8.0.verified.txt index 20731476..d8533301 100644 --- a/test/MockHttp.Server.Tests/PublicApiTests.Api_has_not_changed.NET_8.0.verified.txt +++ b/test/MockHttp.Server.Tests/PublicApiTests.Api_has_not_changed.NET_8.0.verified.txt @@ -5,16 +5,10 @@ namespace MockHttp { public sealed class MockHttpServer : System.IAsyncDisposable, System.IDisposable { - [System.Obsolete("Use the overload accepting an System.Uri.")] - public MockHttpServer(MockHttp.MockHttpHandler mockHttpHandler, string hostUrl) { } public MockHttpServer(MockHttp.MockHttpHandler mockHttpHandler, System.Uri hostUri) { } - [System.Obsolete("Use the overload accepting an System.Uri.")] - public MockHttpServer(MockHttp.MockHttpHandler mockHttpHandler, Microsoft.Extensions.Logging.ILoggerFactory? loggerFactory, string hostUrl) { } public MockHttpServer(MockHttp.MockHttpHandler mockHttpHandler, Microsoft.Extensions.Logging.ILoggerFactory? loggerFactory, System.Uri hostUri) { } public MockHttp.MockHttpHandler Handler { get; } public System.Uri HostUri { get; } - [System.Obsolete("Use the HostUri instead.")] - public string HostUrl { get; } public bool IsStarted { get; } public System.Net.Http.HttpClient CreateClient() { } public void Dispose() { } diff --git a/test/MockHttp.Server.Tests/PublicApiTests.Api_has_not_changed.NET_Core_3.1.verified.txt b/test/MockHttp.Server.Tests/PublicApiTests.Api_has_not_changed.NET_Core_3.1.verified.txt index 41f0a258..22117bcc 100644 --- a/test/MockHttp.Server.Tests/PublicApiTests.Api_has_not_changed.NET_Core_3.1.verified.txt +++ b/test/MockHttp.Server.Tests/PublicApiTests.Api_has_not_changed.NET_Core_3.1.verified.txt @@ -5,16 +5,10 @@ namespace MockHttp { public sealed class MockHttpServer : System.IAsyncDisposable, System.IDisposable { - [System.Obsolete("Use the overload accepting an System.Uri.")] - public MockHttpServer(MockHttp.MockHttpHandler mockHttpHandler, string hostUrl) { } public MockHttpServer(MockHttp.MockHttpHandler mockHttpHandler, System.Uri hostUri) { } - [System.Obsolete("Use the overload accepting an System.Uri.")] - public MockHttpServer(MockHttp.MockHttpHandler mockHttpHandler, Microsoft.Extensions.Logging.ILoggerFactory? loggerFactory, string hostUrl) { } public MockHttpServer(MockHttp.MockHttpHandler mockHttpHandler, Microsoft.Extensions.Logging.ILoggerFactory? loggerFactory, System.Uri hostUri) { } public MockHttp.MockHttpHandler Handler { get; } public System.Uri HostUri { get; } - [System.Obsolete("Use the HostUri instead.")] - public string HostUrl { get; } public bool IsStarted { get; } public System.Net.Http.HttpClient CreateClient() { } public void Dispose() { } From dd3f7051bc03695c5a7f7384493c86ebd2bc665d Mon Sep 17 00:00:00 2001 From: skwasjer <11424653+skwasjer@users.noreply.github.com> Date: Mon, 30 Sep 2024 00:13:32 +0200 Subject: [PATCH 5/8] chore!: remove obsolete RequestUriMatcher --- src/MockHttp/Matchers/RequestUriMatcher.cs | 98 ---------------- .../Matchers/RequestUriMatcherTests.cs | 110 ------------------ ...s.Api_has_not_changed.NET_6.0.verified.txt | 8 -- ...s.Api_has_not_changed.NET_8.0.verified.txt | 8 -- ...t_changed.NET_Framework_4.6.2.verified.txt | 8 -- ...t_changed.NET_Framework_4.7.2.verified.txt | 8 -- ...not_changed.NET_Framework_4.8.verified.txt | 8 -- ..._not_changed.NET_Standard_2.1.verified.txt | 8 -- 8 files changed, 256 deletions(-) delete mode 100644 src/MockHttp/Matchers/RequestUriMatcher.cs delete mode 100644 test/MockHttp.Tests/Matchers/RequestUriMatcherTests.cs diff --git a/src/MockHttp/Matchers/RequestUriMatcher.cs b/src/MockHttp/Matchers/RequestUriMatcher.cs deleted file mode 100644 index 38510a71..00000000 --- a/src/MockHttp/Matchers/RequestUriMatcher.cs +++ /dev/null @@ -1,98 +0,0 @@ -using System.Diagnostics; -using MockHttp.Http; -using MockHttp.Patterns; -using MockHttp.Responses; -using static MockHttp.Http.UriExtensions; - -namespace MockHttp.Matchers; - -/// -/// Matches a request by the request URI. -/// -[Obsolete($"Replaced with {nameof(UriMatcher)}. Will be removed in next major release.")] -public class RequestUriMatcher : HttpRequestMatcher -{ - [DebuggerBrowsable(DebuggerBrowsableState.Never)] - private readonly Uri _requestUri = default!; - [DebuggerBrowsable(DebuggerBrowsableState.Never)] - private readonly string _formattedUri; - [DebuggerBrowsable(DebuggerBrowsableState.Never)] - private readonly WildcardPattern? _uriPatternMatcher; - - /// - /// Initializes a new instance of the class using specified . - /// - /// The request URI. - public RequestUriMatcher(Uri uri) - { - _requestUri = uri.EnsureIsRooted(); - _formattedUri = _requestUri.ToString(); - } - - /// - /// Initializes a new instance of the class using specified . - /// - /// The request URI or a URI wildcard. - /// to allow wildcards, or if exact matching. - public RequestUriMatcher(string uriString, bool allowWildcards = true) - { - _formattedUri = uriString ?? throw new ArgumentNullException(nameof(uriString)); - - if (allowWildcards -#if NETSTANDARD2_0 || NETFRAMEWORK - && uriString.Contains("*") -#else - && uriString.Contains('*', StringComparison.InvariantCultureIgnoreCase) -#endif - ) - { - _uriPatternMatcher = WildcardPattern.Create(uriString); - } - else - { - // If no wildcards, then must be actual uri. - _requestUri = new Uri(uriString, DotNetRelativeOrAbsolute).EnsureIsRooted(); - _formattedUri = _requestUri.ToString(); - } - } - - /// - public override bool IsMatch(MockHttpRequestContext requestContext) - { - if (requestContext is null) - { - throw new ArgumentNullException(nameof(requestContext)); - } - - Uri? requestUri = requestContext.Request.RequestUri; - if (requestUri is null) - { - return false; - } - - if (_uriPatternMatcher is null) - { - return IsAbsoluteUriMatch(requestUri) || IsRelativeUriMatch(requestUri); - } - - return _uriPatternMatcher.Value.IsMatch(requestUri.ToString()); - } - - private bool IsAbsoluteUriMatch(Uri uri) - { - return _requestUri.IsAbsoluteUri && uri.Equals(_requestUri); - } - - private bool IsRelativeUriMatch(Uri uri) - { - return !_requestUri.IsAbsoluteUri - && uri.IsBaseOf(_requestUri) - && uri.ToString().EndsWith(_requestUri.ToString(), StringComparison.Ordinal); - } - - /// - public override string ToString() - { - return $"RequestUri: '{_formattedUri}'"; - } -} diff --git a/test/MockHttp.Tests/Matchers/RequestUriMatcherTests.cs b/test/MockHttp.Tests/Matchers/RequestUriMatcherTests.cs deleted file mode 100644 index 10fc86df..00000000 --- a/test/MockHttp.Tests/Matchers/RequestUriMatcherTests.cs +++ /dev/null @@ -1,110 +0,0 @@ -using MockHttp.Responses; - -namespace MockHttp.Matchers; - -[Obsolete($"Replaced with {nameof(UriMatcher)}. Will be removed in next major release.")] -public class RequestUriMatcherTests -{ - [Theory] - [InlineData("", UriKind.Relative, "http://127.0.0.1/", true)] - [InlineData("relative.htm", UriKind.Relative, "http://127.0.0.1/relative.htm", true)] - [InlineData("/folder/relative.htm", UriKind.Relative, "http://127.0.0.1/relative.htm", false)] - [InlineData("relative.htm", UriKind.Relative, "http://127.0.0.1/folder/relative.htm", false)] - [InlineData("folder/relative.htm", UriKind.Relative, "http://127.0.0.1/folder/relative.htm", true)] - [InlineData("/folder/relative.htm", UriKind.Relative, "http://127.0.0.1/folder/relative.htm", true)] - [InlineData("http://127.0.0.1/absolute.htm", UriKind.Absolute, "http://127.0.0.1/absolute.htm", true)] - [InlineData("http://127.0.0.1/absolute.htm", UriKind.Absolute, "http://127.0.0.1/folder/absolute.htm", false)] - public void Given_uri_when_matching_should_match(string matchUri, UriKind uriKind, string requestUri, bool isMatch) - { - var request = new HttpRequestMessage { RequestUri = new Uri(requestUri, UriKind.Absolute) }; - var sut = new RequestUriMatcher(new Uri(matchUri, uriKind)); - - // Act & assert - sut.IsMatch(new MockHttpRequestContext(request)).Should().Be(isMatch); - } - - [Theory] - [InlineData("relative.htm", true, "http://127.0.0.1/relative.htm", true)] - [InlineData("/folder/relative.htm", true, "http://127.0.0.1/relative.htm", false)] - [InlineData("relative.htm", true, "http://127.0.0.1/folder/relative.htm", false)] - [InlineData("folder/relative.htm", true, "http://127.0.0.1/folder/relative.htm", true)] - [InlineData("/folder/relative.htm", true, "http://127.0.0.1/folder/relative.htm", true)] - [InlineData("http://127.0.0.1/absolute.htm", true, "http://127.0.0.1/absolute.htm", true)] - [InlineData("http://127.0.0.1/absolute.htm", true, "http://127.0.0.1/folder/absolute.htm", false)] - [InlineData("*.htm", true, "http://127.0.0.1/relative.htm", true)] - [InlineData("*/relative.htm", true, "http://127.0.0.1/relative.htm", true)] - [InlineData("/*/relative.htm", true, "http://127.0.0.1/folder/relative.htm", false)] - [InlineData("/*/relative.htm", true, "http://127.0.0.1/relative.htm", false)] - [InlineData("/folder/*.htm", true, "http://127.0.0.1/folder/relative.htm", false)] - [InlineData("*/folder/*.htm", true, "http://127.0.0.1/folder/relative.htm", true)] - [InlineData("/folder/*.htm", true, "http://127.0.0.1/relative.htm", false)] - [InlineData("/*/*/relative.*", true, "http://127.0.0.1/folder1/folder2/relative.htm", false)] - [InlineData("*/folder1/*/relative.*", true, "http://127.0.0.1/folder1/folder2/relative.htm", true)] - [InlineData("/*/*/relative.*", true, "http://127.0.0.1/folder1/relative.htm", false)] - [InlineData("http://127.0.0.1/*.htm", true, "http://127.0.0.1/absolute.htm", true)] - [InlineData("http://127.0.0.1/*.htm", true, "http://127.0.0.1/folder/absolute.htm", true)] - public void Given_uriString_when_matching_should_match(string uriString, bool hasWildcard, string requestUri, bool isMatch) - { - var request = new HttpRequestMessage { RequestUri = new Uri(requestUri, UriKind.Absolute) }; - var sut = new RequestUriMatcher(uriString, hasWildcard); - - // Act & assert - sut.IsMatch(new MockHttpRequestContext(request)).Should().Be(isMatch); - } - - [Fact] - public void Given_null_uri_when_creating_matcher_should_throw() - { - Uri? uri = null; - - // Act - Func act = () => new RequestUriMatcher(uri!); - - // Assert - act.Should() - .Throw() - .WithParameterName(nameof(uri)); - } - - [Fact] - public void Given_null_uriString_when_creating_matcher_should_throw() - { - string? uriString = null; - - // Act - Func act = () => new RequestUriMatcher(uriString!, false); - - // Assert - act.Should() - .Throw() - .WithParameterName(nameof(uriString)); - } - - [Fact] - public void When_formatting_should_return_human_readable_representation() - { - const string expectedText = "RequestUri: '*/controller/*'"; - var sut = new RequestUriMatcher("*/controller/*"); - - // Act - string displayText = sut.ToString(); - - // Assert - displayText.Should().Be(expectedText); - } - - [Fact] - public void Given_null_context_when_matching_it_should_throw() - { - var sut = new RequestUriMatcher("*/controller/*"); - MockHttpRequestContext? requestContext = null; - - // Act - Action act = () => sut.IsMatch(requestContext!); - - // Assert - act.Should() - .Throw() - .WithParameterName(nameof(requestContext)); - } -} diff --git a/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_6.0.verified.txt b/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_6.0.verified.txt index ee7304cf..ba81c45b 100644 --- a/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_6.0.verified.txt +++ b/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_6.0.verified.txt @@ -458,14 +458,6 @@ namespace MockHttp.Matchers public override bool IsMatch(MockHttp.Responses.MockHttpRequestContext requestContext) { } public override string ToString() { } } - [System.Obsolete("Replaced with UriMatcher. Will be removed in next major release.")] - public class RequestUriMatcher : MockHttp.Matchers.HttpRequestMatcher - { - public RequestUriMatcher(System.Uri uri) { } - public RequestUriMatcher(string uriString, bool allowWildcards = true) { } - public override bool IsMatch(MockHttp.Responses.MockHttpRequestContext requestContext) { } - public override string ToString() { } - } public abstract class ValueMatcher : MockHttp.Matchers.HttpRequestMatcher { protected ValueMatcher(T value) { } diff --git a/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_8.0.verified.txt b/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_8.0.verified.txt index cc18e3a5..40434e4f 100644 --- a/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_8.0.verified.txt +++ b/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_8.0.verified.txt @@ -459,14 +459,6 @@ namespace MockHttp.Matchers public override bool IsMatch(MockHttp.Responses.MockHttpRequestContext requestContext) { } public override string ToString() { } } - [System.Obsolete("Replaced with UriMatcher. Will be removed in next major release.")] - public class RequestUriMatcher : MockHttp.Matchers.HttpRequestMatcher - { - public RequestUriMatcher(System.Uri uri) { } - public RequestUriMatcher(string uriString, bool allowWildcards = true) { } - public override bool IsMatch(MockHttp.Responses.MockHttpRequestContext requestContext) { } - public override string ToString() { } - } public abstract class ValueMatcher : MockHttp.Matchers.HttpRequestMatcher { protected ValueMatcher(T value) { } diff --git a/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_Framework_4.6.2.verified.txt b/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_Framework_4.6.2.verified.txt index 8aef646d..65c6943a 100644 --- a/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_Framework_4.6.2.verified.txt +++ b/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_Framework_4.6.2.verified.txt @@ -458,14 +458,6 @@ namespace MockHttp.Matchers public override bool IsMatch(MockHttp.Responses.MockHttpRequestContext requestContext) { } public override string ToString() { } } - [System.Obsolete("Replaced with UriMatcher. Will be removed in next major release.")] - public class RequestUriMatcher : MockHttp.Matchers.HttpRequestMatcher - { - public RequestUriMatcher(System.Uri uri) { } - public RequestUriMatcher(string uriString, bool allowWildcards = true) { } - public override bool IsMatch(MockHttp.Responses.MockHttpRequestContext requestContext) { } - public override string ToString() { } - } public abstract class ValueMatcher : MockHttp.Matchers.HttpRequestMatcher { protected ValueMatcher(T value) { } diff --git a/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_Framework_4.7.2.verified.txt b/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_Framework_4.7.2.verified.txt index 7022059c..b9075a11 100644 --- a/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_Framework_4.7.2.verified.txt +++ b/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_Framework_4.7.2.verified.txt @@ -458,14 +458,6 @@ namespace MockHttp.Matchers public override bool IsMatch(MockHttp.Responses.MockHttpRequestContext requestContext) { } public override string ToString() { } } - [System.Obsolete("Replaced with UriMatcher. Will be removed in next major release.")] - public class RequestUriMatcher : MockHttp.Matchers.HttpRequestMatcher - { - public RequestUriMatcher(System.Uri uri) { } - public RequestUriMatcher(string uriString, bool allowWildcards = true) { } - public override bool IsMatch(MockHttp.Responses.MockHttpRequestContext requestContext) { } - public override string ToString() { } - } public abstract class ValueMatcher : MockHttp.Matchers.HttpRequestMatcher { protected ValueMatcher(T value) { } diff --git a/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_Framework_4.8.verified.txt b/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_Framework_4.8.verified.txt index d690f117..0ece8d50 100644 --- a/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_Framework_4.8.verified.txt +++ b/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_Framework_4.8.verified.txt @@ -458,14 +458,6 @@ namespace MockHttp.Matchers public override bool IsMatch(MockHttp.Responses.MockHttpRequestContext requestContext) { } public override string ToString() { } } - [System.Obsolete("Replaced with UriMatcher. Will be removed in next major release.")] - public class RequestUriMatcher : MockHttp.Matchers.HttpRequestMatcher - { - public RequestUriMatcher(System.Uri uri) { } - public RequestUriMatcher(string uriString, bool allowWildcards = true) { } - public override bool IsMatch(MockHttp.Responses.MockHttpRequestContext requestContext) { } - public override string ToString() { } - } public abstract class ValueMatcher : MockHttp.Matchers.HttpRequestMatcher { protected ValueMatcher(T value) { } diff --git a/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_Standard_2.1.verified.txt b/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_Standard_2.1.verified.txt index cd079334..5c3ddf01 100644 --- a/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_Standard_2.1.verified.txt +++ b/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_Standard_2.1.verified.txt @@ -458,14 +458,6 @@ namespace MockHttp.Matchers public override bool IsMatch(MockHttp.Responses.MockHttpRequestContext requestContext) { } public override string ToString() { } } - [System.Obsolete("Replaced with UriMatcher. Will be removed in next major release.")] - public class RequestUriMatcher : MockHttp.Matchers.HttpRequestMatcher - { - public RequestUriMatcher(System.Uri uri) { } - public RequestUriMatcher(string uriString, bool allowWildcards = true) { } - public override bool IsMatch(MockHttp.Responses.MockHttpRequestContext requestContext) { } - public override string ToString() { } - } public abstract class ValueMatcher : MockHttp.Matchers.HttpRequestMatcher { protected ValueMatcher(T value) { } From aeac3f9771ced838ab17eb9e1bfb4d13d44e29f5 Mon Sep 17 00:00:00 2001 From: skwasjer <11424653+skwasjer@users.noreply.github.com> Date: Mon, 30 Sep 2024 01:37:32 +0200 Subject: [PATCH 6/8] test: allow mocking of internals --- src/MockHttp/Properties/InternalsVisibleTo.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/MockHttp/Properties/InternalsVisibleTo.cs b/src/MockHttp/Properties/InternalsVisibleTo.cs index 9dccda5d..9097bd3d 100644 --- a/src/MockHttp/Properties/InternalsVisibleTo.cs +++ b/src/MockHttp/Properties/InternalsVisibleTo.cs @@ -1,4 +1,5 @@ using System.Runtime.CompilerServices; +[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")] [assembly: InternalsVisibleTo("MockHttp.Tests")] [assembly: InternalsVisibleTo("MockHttp.Testing")] From 10cc1716aa6168962ad970a6328ea87814b8f2ee Mon Sep 17 00:00:00 2001 From: skwasjer <11424653+skwasjer@users.noreply.github.com> Date: Mon, 30 Sep 2024 00:22:35 +0200 Subject: [PATCH 7/8] chore!: change visibility fo all matcher implementations to internal --- src/MockHttp/Matchers/AnyMatcher.cs | 2 +- src/MockHttp/Matchers/ContentMatcher.cs | 2 +- src/MockHttp/Matchers/ExpressionMatcher.cs | 2 +- src/MockHttp/Matchers/FormDataMatcher.cs | 6 +- src/MockHttp/Matchers/HttpHeadersMatcher.cs | 2 +- src/MockHttp/Matchers/HttpMethodMatcher.cs | 2 +- src/MockHttp/Matchers/HttpRequestMatcher.cs | 2 +- .../Matchers/MediaTypeHeaderMatcher.cs | 2 +- src/MockHttp/Matchers/NotMatcher.cs | 2 +- .../Matchers/PartialContentMatcher.cs | 2 +- src/MockHttp/Matchers/QueryStringMatcher.cs | 2 +- src/MockHttp/Matchers/UriMatcher.cs | 2 +- src/MockHttp/Matchers/ValueMatcher.cs | 2 +- src/MockHttp/Matchers/VersionMatcher.cs | 2 +- ...s.Api_has_not_changed.NET_6.0.verified.txt | 94 ------------------- ...s.Api_has_not_changed.NET_8.0.verified.txt | 94 ------------------- ...t_changed.NET_Framework_4.6.2.verified.txt | 94 ------------------- ...t_changed.NET_Framework_4.7.2.verified.txt | 94 ------------------- ...not_changed.NET_Framework_4.8.verified.txt | 94 ------------------- ..._not_changed.NET_Standard_2.1.verified.txt | 94 ------------------- 20 files changed, 16 insertions(+), 580 deletions(-) diff --git a/src/MockHttp/Matchers/AnyMatcher.cs b/src/MockHttp/Matchers/AnyMatcher.cs index 5018af87..22d0a0c9 100644 --- a/src/MockHttp/Matchers/AnyMatcher.cs +++ b/src/MockHttp/Matchers/AnyMatcher.cs @@ -7,7 +7,7 @@ namespace MockHttp.Matchers; /// /// Matches a request by verifying it against a list of constraints, for which at least one has to match the request. /// -public class AnyMatcher : IAsyncHttpRequestMatcher +internal sealed class AnyMatcher : IAsyncHttpRequestMatcher { /// /// Initializes a new instance of the class using specified list of . diff --git a/src/MockHttp/Matchers/ContentMatcher.cs b/src/MockHttp/Matchers/ContentMatcher.cs index e42e576e..5221216b 100644 --- a/src/MockHttp/Matchers/ContentMatcher.cs +++ b/src/MockHttp/Matchers/ContentMatcher.cs @@ -8,7 +8,7 @@ namespace MockHttp.Matchers; /// /// Matches a request by the request content. /// -public class ContentMatcher : IAsyncHttpRequestMatcher +internal class ContentMatcher : IAsyncHttpRequestMatcher { private const int MaxBytesDisplayed = 10; diff --git a/src/MockHttp/Matchers/ExpressionMatcher.cs b/src/MockHttp/Matchers/ExpressionMatcher.cs index da354ad2..46308945 100644 --- a/src/MockHttp/Matchers/ExpressionMatcher.cs +++ b/src/MockHttp/Matchers/ExpressionMatcher.cs @@ -6,7 +6,7 @@ namespace MockHttp.Matchers; /// /// Matches a request using a custom expression. /// -public class ExpressionMatcher : HttpRequestMatcher +internal sealed class ExpressionMatcher : HttpRequestMatcher { private readonly string _funcDisplay; private readonly Func _func; diff --git a/src/MockHttp/Matchers/FormDataMatcher.cs b/src/MockHttp/Matchers/FormDataMatcher.cs index e8044072..cc631bcd 100644 --- a/src/MockHttp/Matchers/FormDataMatcher.cs +++ b/src/MockHttp/Matchers/FormDataMatcher.cs @@ -7,7 +7,7 @@ namespace MockHttp.Matchers; /// /// Matches a request by the posted form data. /// -public class FormDataMatcher : IAsyncHttpRequestMatcher +internal sealed class FormDataMatcher : IAsyncHttpRequestMatcher { internal const string MultipartFormDataMediaType = "multipart/form-data"; @@ -43,7 +43,7 @@ public FormDataMatcher(string urlEncodedFormData) } /// - public virtual Task IsMatchAsync(MockHttpRequestContext requestContext) + public Task IsMatchAsync(MockHttpRequestContext requestContext) { if (requestContext is null) { @@ -85,7 +85,7 @@ private static bool HasOneOf(IEnumerable left, IEnumerable right } /// - public virtual bool IsExclusive => _matchQs.Count == 0; + public bool IsExclusive => _matchQs.Count == 0; /// public override string ToString() diff --git a/src/MockHttp/Matchers/HttpHeadersMatcher.cs b/src/MockHttp/Matchers/HttpHeadersMatcher.cs index 918abfc9..adf718de 100644 --- a/src/MockHttp/Matchers/HttpHeadersMatcher.cs +++ b/src/MockHttp/Matchers/HttpHeadersMatcher.cs @@ -8,7 +8,7 @@ namespace MockHttp.Matchers; /// /// Matches a request by the request headers. /// -public class HttpHeadersMatcher : ValueMatcher +internal sealed class HttpHeadersMatcher : ValueMatcher { private readonly HttpHeaderEqualityComparer _equalityComparer; diff --git a/src/MockHttp/Matchers/HttpMethodMatcher.cs b/src/MockHttp/Matchers/HttpMethodMatcher.cs index a12bd167..39299ebf 100644 --- a/src/MockHttp/Matchers/HttpMethodMatcher.cs +++ b/src/MockHttp/Matchers/HttpMethodMatcher.cs @@ -5,7 +5,7 @@ namespace MockHttp.Matchers; /// /// Matches a request by HTTP method. /// -public class HttpMethodMatcher : ValueMatcher +internal sealed class HttpMethodMatcher : ValueMatcher { /// /// Initializes a new instance of the class using specified . diff --git a/src/MockHttp/Matchers/HttpRequestMatcher.cs b/src/MockHttp/Matchers/HttpRequestMatcher.cs index 2dc753d8..bcc45e42 100644 --- a/src/MockHttp/Matchers/HttpRequestMatcher.cs +++ b/src/MockHttp/Matchers/HttpRequestMatcher.cs @@ -5,7 +5,7 @@ namespace MockHttp.Matchers; /// /// Represents a condition for matching a . /// -public abstract class HttpRequestMatcher : IAsyncHttpRequestMatcher +internal abstract class HttpRequestMatcher : IAsyncHttpRequestMatcher { /// /// Initializes a new instance of the class. diff --git a/src/MockHttp/Matchers/MediaTypeHeaderMatcher.cs b/src/MockHttp/Matchers/MediaTypeHeaderMatcher.cs index 8f3ca0f9..12e39066 100644 --- a/src/MockHttp/Matchers/MediaTypeHeaderMatcher.cs +++ b/src/MockHttp/Matchers/MediaTypeHeaderMatcher.cs @@ -6,7 +6,7 @@ namespace MockHttp.Matchers; /// /// Matches a request by the media type header. /// -public class MediaTypeHeaderMatcher : ValueMatcher +internal sealed class MediaTypeHeaderMatcher : ValueMatcher { /// /// Initializes a new instance of the class. diff --git a/src/MockHttp/Matchers/NotMatcher.cs b/src/MockHttp/Matchers/NotMatcher.cs index 246d78ed..e2ba96d3 100644 --- a/src/MockHttp/Matchers/NotMatcher.cs +++ b/src/MockHttp/Matchers/NotMatcher.cs @@ -5,7 +5,7 @@ namespace MockHttp.Matchers; /// /// Matcher that inverts the final result of matching a set of inner matchers. /// -internal class NotMatcher : IAsyncHttpRequestMatcher +internal sealed class NotMatcher : IAsyncHttpRequestMatcher { private readonly IAsyncHttpRequestMatcher _matcher; diff --git a/src/MockHttp/Matchers/PartialContentMatcher.cs b/src/MockHttp/Matchers/PartialContentMatcher.cs index 9604c01b..e5b991aa 100644 --- a/src/MockHttp/Matchers/PartialContentMatcher.cs +++ b/src/MockHttp/Matchers/PartialContentMatcher.cs @@ -6,7 +6,7 @@ namespace MockHttp.Matchers; /// /// Matches a request by partially matching the request content. /// -public class PartialContentMatcher : ContentMatcher +internal sealed class PartialContentMatcher : ContentMatcher { /// /// Initializes a new instance of the class using specified . diff --git a/src/MockHttp/Matchers/QueryStringMatcher.cs b/src/MockHttp/Matchers/QueryStringMatcher.cs index 8b9a6b24..c99fc6ed 100644 --- a/src/MockHttp/Matchers/QueryStringMatcher.cs +++ b/src/MockHttp/Matchers/QueryStringMatcher.cs @@ -7,7 +7,7 @@ namespace MockHttp.Matchers; /// /// Matches a request by the request URI query string. /// -public class QueryStringMatcher : HttpRequestMatcher +internal sealed class QueryStringMatcher : HttpRequestMatcher { [DebuggerBrowsable(DebuggerBrowsableState.Never)] private readonly QueryString _matchQs; diff --git a/src/MockHttp/Matchers/UriMatcher.cs b/src/MockHttp/Matchers/UriMatcher.cs index 4716672d..e4c06fd5 100644 --- a/src/MockHttp/Matchers/UriMatcher.cs +++ b/src/MockHttp/Matchers/UriMatcher.cs @@ -8,7 +8,7 @@ namespace MockHttp.Matchers; /// /// Matches a request by the URI. /// -internal class UriMatcher : HttpRequestMatcher +internal sealed class UriMatcher : HttpRequestMatcher { private readonly string _name; private readonly Pattern _pattern; diff --git a/src/MockHttp/Matchers/ValueMatcher.cs b/src/MockHttp/Matchers/ValueMatcher.cs index 4fded867..c513fc55 100644 --- a/src/MockHttp/Matchers/ValueMatcher.cs +++ b/src/MockHttp/Matchers/ValueMatcher.cs @@ -4,7 +4,7 @@ /// Base class that matches a request by a value. /// /// The type of the value to match. -public abstract class ValueMatcher : HttpRequestMatcher +internal abstract class ValueMatcher : HttpRequestMatcher { /// /// Initializes a new instance of the class using specified . diff --git a/src/MockHttp/Matchers/VersionMatcher.cs b/src/MockHttp/Matchers/VersionMatcher.cs index 9fa76018..d424c657 100644 --- a/src/MockHttp/Matchers/VersionMatcher.cs +++ b/src/MockHttp/Matchers/VersionMatcher.cs @@ -5,7 +5,7 @@ namespace MockHttp.Matchers; /// /// Matches a request by the HTTP message version. /// -public class VersionMatcher : ValueMatcher +internal sealed class VersionMatcher : ValueMatcher { /// /// Initializes a new instance of the class using specified . diff --git a/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_6.0.verified.txt b/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_6.0.verified.txt index ba81c45b..c7d37fb5 100644 --- a/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_6.0.verified.txt +++ b/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_6.0.verified.txt @@ -371,105 +371,11 @@ namespace MockHttp.Language.Response } namespace MockHttp.Matchers { - public class AnyMatcher : MockHttp.Matchers.IAsyncHttpRequestMatcher - { - public AnyMatcher(System.Collections.Generic.IReadOnlyCollection matchers) { } - public bool IsExclusive { get; } - public System.Collections.Generic.IReadOnlyCollection Matchers { get; } - public System.Threading.Tasks.Task IsMatchAsync(MockHttp.Responses.MockHttpRequestContext requestContext) { } - public override string ToString() { } - } - public class ContentMatcher : MockHttp.Matchers.IAsyncHttpRequestMatcher - { - public ContentMatcher() { } - public ContentMatcher(byte[] content) { } - public ContentMatcher(string content, System.Text.Encoding? encoding) { } - protected System.Collections.Generic.IReadOnlyList ByteContent { get; } - public virtual bool IsExclusive { get; } - protected virtual bool IsMatch(byte[] requestContent) { } - public System.Threading.Tasks.Task IsMatchAsync(MockHttp.Responses.MockHttpRequestContext requestContext) { } - public override string ToString() { } - } - public class ExpressionMatcher : MockHttp.Matchers.HttpRequestMatcher - { - public ExpressionMatcher(System.Linq.Expressions.Expression> expression) { } - public override bool IsMatch(MockHttp.Responses.MockHttpRequestContext requestContext) { } - public override string ToString() { } - } - public class FormDataMatcher : MockHttp.Matchers.IAsyncHttpRequestMatcher - { - public FormDataMatcher(System.Collections.Generic.IEnumerable>> formData) { } - public FormDataMatcher(string urlEncodedFormData) { } - public virtual bool IsExclusive { get; } - public virtual System.Threading.Tasks.Task IsMatchAsync(MockHttp.Responses.MockHttpRequestContext requestContext) { } - public override string ToString() { } - } - public class HttpHeadersMatcher : MockHttp.Matchers.ValueMatcher - { - public HttpHeadersMatcher(System.Collections.Generic.IEnumerable>> headers) { } - public HttpHeadersMatcher(System.Collections.Generic.IEnumerable> headers) { } - public HttpHeadersMatcher(string name) { } - public HttpHeadersMatcher(string name, System.Collections.Generic.IEnumerable values) { } - public HttpHeadersMatcher(string name, string value, bool allowWildcards = false) { } - public override bool IsExclusive { get; } - public override bool IsMatch(MockHttp.Responses.MockHttpRequestContext requestContext) { } - public override string ToString() { } - } - public class HttpMethodMatcher : MockHttp.Matchers.ValueMatcher - { - public HttpMethodMatcher(System.Net.Http.HttpMethod method) { } - public override bool IsExclusive { get; } - public override bool IsMatch(MockHttp.Responses.MockHttpRequestContext requestContext) { } - public override string ToString() { } - } - public abstract class HttpRequestMatcher : MockHttp.Matchers.IAsyncHttpRequestMatcher - { - protected HttpRequestMatcher() { } - public virtual bool IsExclusive { get; } - public abstract bool IsMatch(MockHttp.Responses.MockHttpRequestContext requestContext); - public System.Threading.Tasks.Task IsMatchAsync(MockHttp.Responses.MockHttpRequestContext requestContext) { } - public abstract override string ToString() { } - } public interface IAsyncHttpRequestMatcher { bool IsExclusive { get; } System.Threading.Tasks.Task IsMatchAsync(MockHttp.Responses.MockHttpRequestContext requestContext); } - public class MediaTypeHeaderMatcher : MockHttp.Matchers.ValueMatcher - { - public MediaTypeHeaderMatcher(System.Net.Http.Headers.MediaTypeHeaderValue headerValue) { } - public override bool IsExclusive { get; } - public override bool IsMatch(MockHttp.Responses.MockHttpRequestContext requestContext) { } - public override string ToString() { } - } - public class PartialContentMatcher : MockHttp.Matchers.ContentMatcher - { - public PartialContentMatcher(byte[] content) { } - public PartialContentMatcher(string content, System.Text.Encoding? encoding) { } - public override bool IsExclusive { get; } - protected override bool IsMatch(byte[] requestContent) { } - public override string ToString() { } - } - public class QueryStringMatcher : MockHttp.Matchers.HttpRequestMatcher - { - public QueryStringMatcher(System.Collections.Generic.IEnumerable>> parameters) { } - public QueryStringMatcher(string queryString) { } - public override bool IsExclusive { get; } - public override bool IsMatch(MockHttp.Responses.MockHttpRequestContext requestContext) { } - public override string ToString() { } - } - public abstract class ValueMatcher : MockHttp.Matchers.HttpRequestMatcher - { - protected ValueMatcher(T value) { } - protected T Value { get; } - } - public class VersionMatcher : MockHttp.Matchers.ValueMatcher - { - public VersionMatcher(System.Version version) { } - public override bool IsExclusive { get; } - public override bool IsMatch(MockHttp.Responses.MockHttpRequestContext requestContext) { } - public override string ToString() { } - } } namespace MockHttp.Responses { diff --git a/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_8.0.verified.txt b/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_8.0.verified.txt index 40434e4f..ef71af40 100644 --- a/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_8.0.verified.txt +++ b/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_8.0.verified.txt @@ -372,105 +372,11 @@ namespace MockHttp.Language.Response } namespace MockHttp.Matchers { - public class AnyMatcher : MockHttp.Matchers.IAsyncHttpRequestMatcher - { - public AnyMatcher(System.Collections.Generic.IReadOnlyCollection matchers) { } - public bool IsExclusive { get; } - public System.Collections.Generic.IReadOnlyCollection Matchers { get; } - public System.Threading.Tasks.Task IsMatchAsync(MockHttp.Responses.MockHttpRequestContext requestContext) { } - public override string ToString() { } - } - public class ContentMatcher : MockHttp.Matchers.IAsyncHttpRequestMatcher - { - public ContentMatcher() { } - public ContentMatcher(byte[] content) { } - public ContentMatcher(string content, System.Text.Encoding? encoding) { } - protected System.Collections.Generic.IReadOnlyList ByteContent { get; } - public virtual bool IsExclusive { get; } - protected virtual bool IsMatch(byte[] requestContent) { } - public System.Threading.Tasks.Task IsMatchAsync(MockHttp.Responses.MockHttpRequestContext requestContext) { } - public override string ToString() { } - } - public class ExpressionMatcher : MockHttp.Matchers.HttpRequestMatcher - { - public ExpressionMatcher(System.Linq.Expressions.Expression> expression) { } - public override bool IsMatch(MockHttp.Responses.MockHttpRequestContext requestContext) { } - public override string ToString() { } - } - public class FormDataMatcher : MockHttp.Matchers.IAsyncHttpRequestMatcher - { - public FormDataMatcher(System.Collections.Generic.IEnumerable>> formData) { } - public FormDataMatcher(string urlEncodedFormData) { } - public virtual bool IsExclusive { get; } - public virtual System.Threading.Tasks.Task IsMatchAsync(MockHttp.Responses.MockHttpRequestContext requestContext) { } - public override string ToString() { } - } - public class HttpHeadersMatcher : MockHttp.Matchers.ValueMatcher - { - public HttpHeadersMatcher(System.Collections.Generic.IEnumerable>> headers) { } - public HttpHeadersMatcher(System.Collections.Generic.IEnumerable> headers) { } - public HttpHeadersMatcher(string name) { } - public HttpHeadersMatcher(string name, System.Collections.Generic.IEnumerable values) { } - public HttpHeadersMatcher(string name, string value, bool allowWildcards = false) { } - public override bool IsExclusive { get; } - public override bool IsMatch(MockHttp.Responses.MockHttpRequestContext requestContext) { } - public override string ToString() { } - } - public class HttpMethodMatcher : MockHttp.Matchers.ValueMatcher - { - public HttpMethodMatcher(System.Net.Http.HttpMethod method) { } - public override bool IsExclusive { get; } - public override bool IsMatch(MockHttp.Responses.MockHttpRequestContext requestContext) { } - public override string ToString() { } - } - public abstract class HttpRequestMatcher : MockHttp.Matchers.IAsyncHttpRequestMatcher - { - protected HttpRequestMatcher() { } - public virtual bool IsExclusive { get; } - public abstract bool IsMatch(MockHttp.Responses.MockHttpRequestContext requestContext); - public System.Threading.Tasks.Task IsMatchAsync(MockHttp.Responses.MockHttpRequestContext requestContext) { } - public abstract override string ToString() { } - } public interface IAsyncHttpRequestMatcher { bool IsExclusive { get; } System.Threading.Tasks.Task IsMatchAsync(MockHttp.Responses.MockHttpRequestContext requestContext); } - public class MediaTypeHeaderMatcher : MockHttp.Matchers.ValueMatcher - { - public MediaTypeHeaderMatcher(System.Net.Http.Headers.MediaTypeHeaderValue headerValue) { } - public override bool IsExclusive { get; } - public override bool IsMatch(MockHttp.Responses.MockHttpRequestContext requestContext) { } - public override string ToString() { } - } - public class PartialContentMatcher : MockHttp.Matchers.ContentMatcher - { - public PartialContentMatcher(byte[] content) { } - public PartialContentMatcher(string content, System.Text.Encoding? encoding) { } - public override bool IsExclusive { get; } - protected override bool IsMatch(byte[] requestContent) { } - public override string ToString() { } - } - public class QueryStringMatcher : MockHttp.Matchers.HttpRequestMatcher - { - public QueryStringMatcher(System.Collections.Generic.IEnumerable>> parameters) { } - public QueryStringMatcher(string queryString) { } - public override bool IsExclusive { get; } - public override bool IsMatch(MockHttp.Responses.MockHttpRequestContext requestContext) { } - public override string ToString() { } - } - public abstract class ValueMatcher : MockHttp.Matchers.HttpRequestMatcher - { - protected ValueMatcher(T value) { } - protected T Value { get; } - } - public class VersionMatcher : MockHttp.Matchers.ValueMatcher - { - public VersionMatcher(System.Version version) { } - public override bool IsExclusive { get; } - public override bool IsMatch(MockHttp.Responses.MockHttpRequestContext requestContext) { } - public override string ToString() { } - } } namespace MockHttp.Responses { diff --git a/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_Framework_4.6.2.verified.txt b/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_Framework_4.6.2.verified.txt index 65c6943a..c8ce6115 100644 --- a/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_Framework_4.6.2.verified.txt +++ b/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_Framework_4.6.2.verified.txt @@ -371,105 +371,11 @@ namespace MockHttp.Language.Response } namespace MockHttp.Matchers { - public class AnyMatcher : MockHttp.Matchers.IAsyncHttpRequestMatcher - { - public AnyMatcher(System.Collections.Generic.IReadOnlyCollection matchers) { } - public bool IsExclusive { get; } - public System.Collections.Generic.IReadOnlyCollection Matchers { get; } - public System.Threading.Tasks.Task IsMatchAsync(MockHttp.Responses.MockHttpRequestContext requestContext) { } - public override string ToString() { } - } - public class ContentMatcher : MockHttp.Matchers.IAsyncHttpRequestMatcher - { - public ContentMatcher() { } - public ContentMatcher(byte[] content) { } - public ContentMatcher(string content, System.Text.Encoding? encoding) { } - protected System.Collections.Generic.IReadOnlyList ByteContent { get; } - public virtual bool IsExclusive { get; } - protected virtual bool IsMatch(byte[] requestContent) { } - public System.Threading.Tasks.Task IsMatchAsync(MockHttp.Responses.MockHttpRequestContext requestContext) { } - public override string ToString() { } - } - public class ExpressionMatcher : MockHttp.Matchers.HttpRequestMatcher - { - public ExpressionMatcher(System.Linq.Expressions.Expression> expression) { } - public override bool IsMatch(MockHttp.Responses.MockHttpRequestContext requestContext) { } - public override string ToString() { } - } - public class FormDataMatcher : MockHttp.Matchers.IAsyncHttpRequestMatcher - { - public FormDataMatcher(System.Collections.Generic.IEnumerable>> formData) { } - public FormDataMatcher(string urlEncodedFormData) { } - public virtual bool IsExclusive { get; } - public virtual System.Threading.Tasks.Task IsMatchAsync(MockHttp.Responses.MockHttpRequestContext requestContext) { } - public override string ToString() { } - } - public class HttpHeadersMatcher : MockHttp.Matchers.ValueMatcher - { - public HttpHeadersMatcher(System.Collections.Generic.IEnumerable>> headers) { } - public HttpHeadersMatcher(System.Collections.Generic.IEnumerable> headers) { } - public HttpHeadersMatcher(string name) { } - public HttpHeadersMatcher(string name, System.Collections.Generic.IEnumerable values) { } - public HttpHeadersMatcher(string name, string value, bool allowWildcards = false) { } - public override bool IsExclusive { get; } - public override bool IsMatch(MockHttp.Responses.MockHttpRequestContext requestContext) { } - public override string ToString() { } - } - public class HttpMethodMatcher : MockHttp.Matchers.ValueMatcher - { - public HttpMethodMatcher(System.Net.Http.HttpMethod method) { } - public override bool IsExclusive { get; } - public override bool IsMatch(MockHttp.Responses.MockHttpRequestContext requestContext) { } - public override string ToString() { } - } - public abstract class HttpRequestMatcher : MockHttp.Matchers.IAsyncHttpRequestMatcher - { - protected HttpRequestMatcher() { } - public virtual bool IsExclusive { get; } - public abstract bool IsMatch(MockHttp.Responses.MockHttpRequestContext requestContext); - public System.Threading.Tasks.Task IsMatchAsync(MockHttp.Responses.MockHttpRequestContext requestContext) { } - public abstract override string ToString() { } - } public interface IAsyncHttpRequestMatcher { bool IsExclusive { get; } System.Threading.Tasks.Task IsMatchAsync(MockHttp.Responses.MockHttpRequestContext requestContext); } - public class MediaTypeHeaderMatcher : MockHttp.Matchers.ValueMatcher - { - public MediaTypeHeaderMatcher(System.Net.Http.Headers.MediaTypeHeaderValue headerValue) { } - public override bool IsExclusive { get; } - public override bool IsMatch(MockHttp.Responses.MockHttpRequestContext requestContext) { } - public override string ToString() { } - } - public class PartialContentMatcher : MockHttp.Matchers.ContentMatcher - { - public PartialContentMatcher(byte[] content) { } - public PartialContentMatcher(string content, System.Text.Encoding? encoding) { } - public override bool IsExclusive { get; } - protected override bool IsMatch(byte[] requestContent) { } - public override string ToString() { } - } - public class QueryStringMatcher : MockHttp.Matchers.HttpRequestMatcher - { - public QueryStringMatcher(System.Collections.Generic.IEnumerable>> parameters) { } - public QueryStringMatcher(string queryString) { } - public override bool IsExclusive { get; } - public override bool IsMatch(MockHttp.Responses.MockHttpRequestContext requestContext) { } - public override string ToString() { } - } - public abstract class ValueMatcher : MockHttp.Matchers.HttpRequestMatcher - { - protected ValueMatcher(T value) { } - protected T Value { get; } - } - public class VersionMatcher : MockHttp.Matchers.ValueMatcher - { - public VersionMatcher(System.Version version) { } - public override bool IsExclusive { get; } - public override bool IsMatch(MockHttp.Responses.MockHttpRequestContext requestContext) { } - public override string ToString() { } - } } namespace MockHttp.Responses { diff --git a/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_Framework_4.7.2.verified.txt b/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_Framework_4.7.2.verified.txt index b9075a11..df18bb55 100644 --- a/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_Framework_4.7.2.verified.txt +++ b/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_Framework_4.7.2.verified.txt @@ -371,105 +371,11 @@ namespace MockHttp.Language.Response } namespace MockHttp.Matchers { - public class AnyMatcher : MockHttp.Matchers.IAsyncHttpRequestMatcher - { - public AnyMatcher(System.Collections.Generic.IReadOnlyCollection matchers) { } - public bool IsExclusive { get; } - public System.Collections.Generic.IReadOnlyCollection Matchers { get; } - public System.Threading.Tasks.Task IsMatchAsync(MockHttp.Responses.MockHttpRequestContext requestContext) { } - public override string ToString() { } - } - public class ContentMatcher : MockHttp.Matchers.IAsyncHttpRequestMatcher - { - public ContentMatcher() { } - public ContentMatcher(byte[] content) { } - public ContentMatcher(string content, System.Text.Encoding? encoding) { } - protected System.Collections.Generic.IReadOnlyList ByteContent { get; } - public virtual bool IsExclusive { get; } - protected virtual bool IsMatch(byte[] requestContent) { } - public System.Threading.Tasks.Task IsMatchAsync(MockHttp.Responses.MockHttpRequestContext requestContext) { } - public override string ToString() { } - } - public class ExpressionMatcher : MockHttp.Matchers.HttpRequestMatcher - { - public ExpressionMatcher(System.Linq.Expressions.Expression> expression) { } - public override bool IsMatch(MockHttp.Responses.MockHttpRequestContext requestContext) { } - public override string ToString() { } - } - public class FormDataMatcher : MockHttp.Matchers.IAsyncHttpRequestMatcher - { - public FormDataMatcher(System.Collections.Generic.IEnumerable>> formData) { } - public FormDataMatcher(string urlEncodedFormData) { } - public virtual bool IsExclusive { get; } - public virtual System.Threading.Tasks.Task IsMatchAsync(MockHttp.Responses.MockHttpRequestContext requestContext) { } - public override string ToString() { } - } - public class HttpHeadersMatcher : MockHttp.Matchers.ValueMatcher - { - public HttpHeadersMatcher(System.Collections.Generic.IEnumerable>> headers) { } - public HttpHeadersMatcher(System.Collections.Generic.IEnumerable> headers) { } - public HttpHeadersMatcher(string name) { } - public HttpHeadersMatcher(string name, System.Collections.Generic.IEnumerable values) { } - public HttpHeadersMatcher(string name, string value, bool allowWildcards = false) { } - public override bool IsExclusive { get; } - public override bool IsMatch(MockHttp.Responses.MockHttpRequestContext requestContext) { } - public override string ToString() { } - } - public class HttpMethodMatcher : MockHttp.Matchers.ValueMatcher - { - public HttpMethodMatcher(System.Net.Http.HttpMethod method) { } - public override bool IsExclusive { get; } - public override bool IsMatch(MockHttp.Responses.MockHttpRequestContext requestContext) { } - public override string ToString() { } - } - public abstract class HttpRequestMatcher : MockHttp.Matchers.IAsyncHttpRequestMatcher - { - protected HttpRequestMatcher() { } - public virtual bool IsExclusive { get; } - public abstract bool IsMatch(MockHttp.Responses.MockHttpRequestContext requestContext); - public System.Threading.Tasks.Task IsMatchAsync(MockHttp.Responses.MockHttpRequestContext requestContext) { } - public abstract override string ToString() { } - } public interface IAsyncHttpRequestMatcher { bool IsExclusive { get; } System.Threading.Tasks.Task IsMatchAsync(MockHttp.Responses.MockHttpRequestContext requestContext); } - public class MediaTypeHeaderMatcher : MockHttp.Matchers.ValueMatcher - { - public MediaTypeHeaderMatcher(System.Net.Http.Headers.MediaTypeHeaderValue headerValue) { } - public override bool IsExclusive { get; } - public override bool IsMatch(MockHttp.Responses.MockHttpRequestContext requestContext) { } - public override string ToString() { } - } - public class PartialContentMatcher : MockHttp.Matchers.ContentMatcher - { - public PartialContentMatcher(byte[] content) { } - public PartialContentMatcher(string content, System.Text.Encoding? encoding) { } - public override bool IsExclusive { get; } - protected override bool IsMatch(byte[] requestContent) { } - public override string ToString() { } - } - public class QueryStringMatcher : MockHttp.Matchers.HttpRequestMatcher - { - public QueryStringMatcher(System.Collections.Generic.IEnumerable>> parameters) { } - public QueryStringMatcher(string queryString) { } - public override bool IsExclusive { get; } - public override bool IsMatch(MockHttp.Responses.MockHttpRequestContext requestContext) { } - public override string ToString() { } - } - public abstract class ValueMatcher : MockHttp.Matchers.HttpRequestMatcher - { - protected ValueMatcher(T value) { } - protected T Value { get; } - } - public class VersionMatcher : MockHttp.Matchers.ValueMatcher - { - public VersionMatcher(System.Version version) { } - public override bool IsExclusive { get; } - public override bool IsMatch(MockHttp.Responses.MockHttpRequestContext requestContext) { } - public override string ToString() { } - } } namespace MockHttp.Responses { diff --git a/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_Framework_4.8.verified.txt b/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_Framework_4.8.verified.txt index 0ece8d50..0ba5dc47 100644 --- a/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_Framework_4.8.verified.txt +++ b/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_Framework_4.8.verified.txt @@ -371,105 +371,11 @@ namespace MockHttp.Language.Response } namespace MockHttp.Matchers { - public class AnyMatcher : MockHttp.Matchers.IAsyncHttpRequestMatcher - { - public AnyMatcher(System.Collections.Generic.IReadOnlyCollection matchers) { } - public bool IsExclusive { get; } - public System.Collections.Generic.IReadOnlyCollection Matchers { get; } - public System.Threading.Tasks.Task IsMatchAsync(MockHttp.Responses.MockHttpRequestContext requestContext) { } - public override string ToString() { } - } - public class ContentMatcher : MockHttp.Matchers.IAsyncHttpRequestMatcher - { - public ContentMatcher() { } - public ContentMatcher(byte[] content) { } - public ContentMatcher(string content, System.Text.Encoding? encoding) { } - protected System.Collections.Generic.IReadOnlyList ByteContent { get; } - public virtual bool IsExclusive { get; } - protected virtual bool IsMatch(byte[] requestContent) { } - public System.Threading.Tasks.Task IsMatchAsync(MockHttp.Responses.MockHttpRequestContext requestContext) { } - public override string ToString() { } - } - public class ExpressionMatcher : MockHttp.Matchers.HttpRequestMatcher - { - public ExpressionMatcher(System.Linq.Expressions.Expression> expression) { } - public override bool IsMatch(MockHttp.Responses.MockHttpRequestContext requestContext) { } - public override string ToString() { } - } - public class FormDataMatcher : MockHttp.Matchers.IAsyncHttpRequestMatcher - { - public FormDataMatcher(System.Collections.Generic.IEnumerable>> formData) { } - public FormDataMatcher(string urlEncodedFormData) { } - public virtual bool IsExclusive { get; } - public virtual System.Threading.Tasks.Task IsMatchAsync(MockHttp.Responses.MockHttpRequestContext requestContext) { } - public override string ToString() { } - } - public class HttpHeadersMatcher : MockHttp.Matchers.ValueMatcher - { - public HttpHeadersMatcher(System.Collections.Generic.IEnumerable>> headers) { } - public HttpHeadersMatcher(System.Collections.Generic.IEnumerable> headers) { } - public HttpHeadersMatcher(string name) { } - public HttpHeadersMatcher(string name, System.Collections.Generic.IEnumerable values) { } - public HttpHeadersMatcher(string name, string value, bool allowWildcards = false) { } - public override bool IsExclusive { get; } - public override bool IsMatch(MockHttp.Responses.MockHttpRequestContext requestContext) { } - public override string ToString() { } - } - public class HttpMethodMatcher : MockHttp.Matchers.ValueMatcher - { - public HttpMethodMatcher(System.Net.Http.HttpMethod method) { } - public override bool IsExclusive { get; } - public override bool IsMatch(MockHttp.Responses.MockHttpRequestContext requestContext) { } - public override string ToString() { } - } - public abstract class HttpRequestMatcher : MockHttp.Matchers.IAsyncHttpRequestMatcher - { - protected HttpRequestMatcher() { } - public virtual bool IsExclusive { get; } - public abstract bool IsMatch(MockHttp.Responses.MockHttpRequestContext requestContext); - public System.Threading.Tasks.Task IsMatchAsync(MockHttp.Responses.MockHttpRequestContext requestContext) { } - public abstract override string ToString() { } - } public interface IAsyncHttpRequestMatcher { bool IsExclusive { get; } System.Threading.Tasks.Task IsMatchAsync(MockHttp.Responses.MockHttpRequestContext requestContext); } - public class MediaTypeHeaderMatcher : MockHttp.Matchers.ValueMatcher - { - public MediaTypeHeaderMatcher(System.Net.Http.Headers.MediaTypeHeaderValue headerValue) { } - public override bool IsExclusive { get; } - public override bool IsMatch(MockHttp.Responses.MockHttpRequestContext requestContext) { } - public override string ToString() { } - } - public class PartialContentMatcher : MockHttp.Matchers.ContentMatcher - { - public PartialContentMatcher(byte[] content) { } - public PartialContentMatcher(string content, System.Text.Encoding? encoding) { } - public override bool IsExclusive { get; } - protected override bool IsMatch(byte[] requestContent) { } - public override string ToString() { } - } - public class QueryStringMatcher : MockHttp.Matchers.HttpRequestMatcher - { - public QueryStringMatcher(System.Collections.Generic.IEnumerable>> parameters) { } - public QueryStringMatcher(string queryString) { } - public override bool IsExclusive { get; } - public override bool IsMatch(MockHttp.Responses.MockHttpRequestContext requestContext) { } - public override string ToString() { } - } - public abstract class ValueMatcher : MockHttp.Matchers.HttpRequestMatcher - { - protected ValueMatcher(T value) { } - protected T Value { get; } - } - public class VersionMatcher : MockHttp.Matchers.ValueMatcher - { - public VersionMatcher(System.Version version) { } - public override bool IsExclusive { get; } - public override bool IsMatch(MockHttp.Responses.MockHttpRequestContext requestContext) { } - public override string ToString() { } - } } namespace MockHttp.Responses { diff --git a/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_Standard_2.1.verified.txt b/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_Standard_2.1.verified.txt index 5c3ddf01..9bd23c80 100644 --- a/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_Standard_2.1.verified.txt +++ b/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_Standard_2.1.verified.txt @@ -371,105 +371,11 @@ namespace MockHttp.Language.Response } namespace MockHttp.Matchers { - public class AnyMatcher : MockHttp.Matchers.IAsyncHttpRequestMatcher - { - public AnyMatcher(System.Collections.Generic.IReadOnlyCollection matchers) { } - public bool IsExclusive { get; } - public System.Collections.Generic.IReadOnlyCollection Matchers { get; } - public System.Threading.Tasks.Task IsMatchAsync(MockHttp.Responses.MockHttpRequestContext requestContext) { } - public override string ToString() { } - } - public class ContentMatcher : MockHttp.Matchers.IAsyncHttpRequestMatcher - { - public ContentMatcher() { } - public ContentMatcher(byte[] content) { } - public ContentMatcher(string content, System.Text.Encoding? encoding) { } - protected System.Collections.Generic.IReadOnlyList ByteContent { get; } - public virtual bool IsExclusive { get; } - protected virtual bool IsMatch(byte[] requestContent) { } - public System.Threading.Tasks.Task IsMatchAsync(MockHttp.Responses.MockHttpRequestContext requestContext) { } - public override string ToString() { } - } - public class ExpressionMatcher : MockHttp.Matchers.HttpRequestMatcher - { - public ExpressionMatcher(System.Linq.Expressions.Expression> expression) { } - public override bool IsMatch(MockHttp.Responses.MockHttpRequestContext requestContext) { } - public override string ToString() { } - } - public class FormDataMatcher : MockHttp.Matchers.IAsyncHttpRequestMatcher - { - public FormDataMatcher(System.Collections.Generic.IEnumerable>> formData) { } - public FormDataMatcher(string urlEncodedFormData) { } - public virtual bool IsExclusive { get; } - public virtual System.Threading.Tasks.Task IsMatchAsync(MockHttp.Responses.MockHttpRequestContext requestContext) { } - public override string ToString() { } - } - public class HttpHeadersMatcher : MockHttp.Matchers.ValueMatcher - { - public HttpHeadersMatcher(System.Collections.Generic.IEnumerable>> headers) { } - public HttpHeadersMatcher(System.Collections.Generic.IEnumerable> headers) { } - public HttpHeadersMatcher(string name) { } - public HttpHeadersMatcher(string name, System.Collections.Generic.IEnumerable values) { } - public HttpHeadersMatcher(string name, string value, bool allowWildcards = false) { } - public override bool IsExclusive { get; } - public override bool IsMatch(MockHttp.Responses.MockHttpRequestContext requestContext) { } - public override string ToString() { } - } - public class HttpMethodMatcher : MockHttp.Matchers.ValueMatcher - { - public HttpMethodMatcher(System.Net.Http.HttpMethod method) { } - public override bool IsExclusive { get; } - public override bool IsMatch(MockHttp.Responses.MockHttpRequestContext requestContext) { } - public override string ToString() { } - } - public abstract class HttpRequestMatcher : MockHttp.Matchers.IAsyncHttpRequestMatcher - { - protected HttpRequestMatcher() { } - public virtual bool IsExclusive { get; } - public abstract bool IsMatch(MockHttp.Responses.MockHttpRequestContext requestContext); - public System.Threading.Tasks.Task IsMatchAsync(MockHttp.Responses.MockHttpRequestContext requestContext) { } - public abstract override string ToString() { } - } public interface IAsyncHttpRequestMatcher { bool IsExclusive { get; } System.Threading.Tasks.Task IsMatchAsync(MockHttp.Responses.MockHttpRequestContext requestContext); } - public class MediaTypeHeaderMatcher : MockHttp.Matchers.ValueMatcher - { - public MediaTypeHeaderMatcher(System.Net.Http.Headers.MediaTypeHeaderValue headerValue) { } - public override bool IsExclusive { get; } - public override bool IsMatch(MockHttp.Responses.MockHttpRequestContext requestContext) { } - public override string ToString() { } - } - public class PartialContentMatcher : MockHttp.Matchers.ContentMatcher - { - public PartialContentMatcher(byte[] content) { } - public PartialContentMatcher(string content, System.Text.Encoding? encoding) { } - public override bool IsExclusive { get; } - protected override bool IsMatch(byte[] requestContent) { } - public override string ToString() { } - } - public class QueryStringMatcher : MockHttp.Matchers.HttpRequestMatcher - { - public QueryStringMatcher(System.Collections.Generic.IEnumerable>> parameters) { } - public QueryStringMatcher(string queryString) { } - public override bool IsExclusive { get; } - public override bool IsMatch(MockHttp.Responses.MockHttpRequestContext requestContext) { } - public override string ToString() { } - } - public abstract class ValueMatcher : MockHttp.Matchers.HttpRequestMatcher - { - protected ValueMatcher(T value) { } - protected T Value { get; } - } - public class VersionMatcher : MockHttp.Matchers.ValueMatcher - { - public VersionMatcher(System.Version version) { } - public override bool IsExclusive { get; } - public override bool IsMatch(MockHttp.Responses.MockHttpRequestContext requestContext) { } - public override string ToString() { } - } } namespace MockHttp.Responses { From 968fcff432957020c20412367ee69c1f29fa2cd0 Mon Sep 17 00:00:00 2001 From: skwasjer <11424653+skwasjer@users.noreply.github.com> Date: Mon, 30 Sep 2024 00:33:37 +0200 Subject: [PATCH 8/8] chore!: rename namespace MockHttp.Responses to MockHttp.Response --- .../MockHttpRequestContextExtensions.cs | 2 +- .../Extensions/ResponseBuilderExtensions.cs | 2 +- src/MockHttp.Json/JsonContentMatcher.cs | 2 +- src/MockHttp/Extensions/IRespondsExtensions.cs | 1 - .../Extensions/HttpRequestMatcherExtensions.cs | 2 +- src/MockHttp/Internal/HttpCall.cs | 2 +- src/MockHttp/Internal/HttpCallSequence.cs | 2 +- .../Response/Behaviors/HttpContentBehavior.cs | 4 +--- .../Response/Behaviors/HttpHeaderBehavior.cs | 1 - .../Behaviors/NetworkLatencyBehavior.cs | 4 +--- .../Response/Behaviors/StatusCodeBehavior.cs | 1 - .../Response/Behaviors/TimeoutBehavior.cs | 1 - .../Response/Behaviors/TransferRateBehavior.cs | 1 - .../Internal/Response/ExceptionStrategy.cs | 4 +--- .../Internal/Response/ResponseFuncStrategy.cs | 4 +--- .../Flow/Response/EnsureHttpContentBehavior.cs | 2 +- .../Language/Flow/Response/ResponseBuilder.cs | 2 +- src/MockHttp/Language/Flow/SetupPhrase.cs | 1 - src/MockHttp/Language/IResponds.cs | 2 +- .../Language/Response/IWithResponse.cs | 2 +- src/MockHttp/Matchers/AnyMatcher.cs | 2 +- src/MockHttp/Matchers/ContentMatcher.cs | 2 +- src/MockHttp/Matchers/ExpressionMatcher.cs | 2 +- src/MockHttp/Matchers/FormDataMatcher.cs | 2 +- src/MockHttp/Matchers/HttpHeadersMatcher.cs | 2 +- src/MockHttp/Matchers/HttpMethodMatcher.cs | 2 +- src/MockHttp/Matchers/HttpRequestMatcher.cs | 2 +- .../Matchers/IAsyncHttpRequestMatcher.cs | 2 +- .../Matchers/MediaTypeHeaderMatcher.cs | 2 +- src/MockHttp/Matchers/NotMatcher.cs | 2 +- src/MockHttp/Matchers/QueryStringMatcher.cs | 2 +- src/MockHttp/Matchers/UriMatcher.cs | 2 +- src/MockHttp/Matchers/VersionMatcher.cs | 2 +- src/MockHttp/MockHttpHandler.cs | 2 +- .../IResponseBehavior.cs | 2 +- .../IResponseStrategy.cs | 2 +- .../MockHttpRequestContext.cs | 2 +- .../MockHttpRequestContextExtensionsTests.cs | 2 +- .../JsonContentMatcherTests.cs | 2 +- .../Extensions/IRespondsExtensionsTests.cs | 2 +- .../RequestMatchingExtensionsTests.cs | 2 +- test/MockHttp.Tests/Internal/HttpCallTests.cs | 1 - .../Response/Behaviors/TimeoutBehaviorTests.cs | 1 - .../Response/ExceptionStrategyTests.cs | 4 +--- .../Response/ResponseFuncStrategyTests.cs | 4 +--- .../MockHttp.Tests/Matchers/AnyMatcherTests.cs | 2 +- test/MockHttp.Tests/Matchers/BoolMatcher.cs | 2 +- .../Matchers/ContentMatcherTests.cs | 2 +- .../Matchers/ExpressionMatcherTests.cs | 2 +- .../Matchers/FakeToStringTestMatcher.cs | 2 +- .../Matchers/FormDataMatcherTests.cs | 2 +- .../Matchers/HttpHeadersMatcherTests.cs | 2 +- .../Matchers/HttpMethodMatcherTests.cs | 2 +- .../Matchers/HttpRequestMatcherTests.cs | 2 +- .../Matchers/MediaTypeHeaderMatcherTests.cs | 2 +- .../MockHttp.Tests/Matchers/NotMatcherTests.cs | 2 +- .../Matchers/PartialContentMatcherTests.cs | 2 +- .../Matchers/QueryStringMatcherTests.cs | 2 +- .../Matchers/VersionMatcherTests.cs | 2 +- ...ts.Api_has_not_changed.NET_6.0.verified.txt | 18 +++++++++--------- ...ts.Api_has_not_changed.NET_8.0.verified.txt | 18 +++++++++--------- ...ot_changed.NET_Framework_4.6.2.verified.txt | 18 +++++++++--------- ...ot_changed.NET_Framework_4.7.2.verified.txt | 18 +++++++++--------- ..._not_changed.NET_Framework_4.8.verified.txt | 18 +++++++++--------- ...s_not_changed.NET_Standard_2.1.verified.txt | 18 +++++++++--------- 65 files changed, 105 insertions(+), 125 deletions(-) rename src/MockHttp/{Responses => Response}/IResponseBehavior.cs (97%) rename src/MockHttp/{Responses => Response}/IResponseStrategy.cs (94%) rename src/MockHttp/{Responses => Response}/MockHttpRequestContext.cs (98%) diff --git a/src/MockHttp.Json/Extensions/MockHttpRequestContextExtensions.cs b/src/MockHttp.Json/Extensions/MockHttpRequestContextExtensions.cs index d4be3f7b..d6b8f7a5 100644 --- a/src/MockHttp.Json/Extensions/MockHttpRequestContextExtensions.cs +++ b/src/MockHttp.Json/Extensions/MockHttpRequestContextExtensions.cs @@ -1,4 +1,4 @@ -using MockHttp.Responses; +using MockHttp.Response; // ReSharper disable once CheckNamespace : BREAKING - change namespace with next release. (remove Extensions) namespace MockHttp.Json.Extensions; diff --git a/src/MockHttp.Json/Extensions/ResponseBuilderExtensions.cs b/src/MockHttp.Json/Extensions/ResponseBuilderExtensions.cs index ab480883..7f7970f4 100644 --- a/src/MockHttp.Json/Extensions/ResponseBuilderExtensions.cs +++ b/src/MockHttp.Json/Extensions/ResponseBuilderExtensions.cs @@ -4,7 +4,7 @@ using MockHttp.Json.Extensions; using MockHttp.Language.Flow.Response; using MockHttp.Language.Response; -using MockHttp.Responses; +using MockHttp.Response; namespace MockHttp.Json; diff --git a/src/MockHttp.Json/JsonContentMatcher.cs b/src/MockHttp.Json/JsonContentMatcher.cs index 5450fb18..714bd375 100644 --- a/src/MockHttp.Json/JsonContentMatcher.cs +++ b/src/MockHttp.Json/JsonContentMatcher.cs @@ -1,7 +1,7 @@ using MockHttp.Json.Extensions; using MockHttp.Json.SystemTextJson; using MockHttp.Matchers; -using MockHttp.Responses; +using MockHttp.Response; namespace MockHttp.Json; diff --git a/src/MockHttp/Extensions/IRespondsExtensions.cs b/src/MockHttp/Extensions/IRespondsExtensions.cs index dd2ec52b..df6d35a0 100644 --- a/src/MockHttp/Extensions/IRespondsExtensions.cs +++ b/src/MockHttp/Extensions/IRespondsExtensions.cs @@ -2,7 +2,6 @@ using MockHttp.Language.Flow; using MockHttp.Language.Flow.Response; using MockHttp.Response; -using MockHttp.Responses; namespace MockHttp; diff --git a/src/MockHttp/Internal/Extensions/HttpRequestMatcherExtensions.cs b/src/MockHttp/Internal/Extensions/HttpRequestMatcherExtensions.cs index 399752c5..b67e1df1 100644 --- a/src/MockHttp/Internal/Extensions/HttpRequestMatcherExtensions.cs +++ b/src/MockHttp/Internal/Extensions/HttpRequestMatcherExtensions.cs @@ -1,5 +1,5 @@ using MockHttp.Matchers; -using MockHttp.Responses; +using MockHttp.Response; namespace MockHttp.Extensions; diff --git a/src/MockHttp/Internal/HttpCall.cs b/src/MockHttp/Internal/HttpCall.cs index bbce3cbe..4c603028 100644 --- a/src/MockHttp/Internal/HttpCall.cs +++ b/src/MockHttp/Internal/HttpCall.cs @@ -1,7 +1,7 @@ using System.Collections.ObjectModel; using System.Text; using MockHttp.Matchers; -using MockHttp.Responses; +using MockHttp.Response; namespace MockHttp; diff --git a/src/MockHttp/Internal/HttpCallSequence.cs b/src/MockHttp/Internal/HttpCallSequence.cs index d5002485..9a203977 100644 --- a/src/MockHttp/Internal/HttpCallSequence.cs +++ b/src/MockHttp/Internal/HttpCallSequence.cs @@ -1,4 +1,4 @@ -using MockHttp.Responses; +using MockHttp.Response; namespace MockHttp; diff --git a/src/MockHttp/Internal/Response/Behaviors/HttpContentBehavior.cs b/src/MockHttp/Internal/Response/Behaviors/HttpContentBehavior.cs index 96bcdb95..3da32b84 100644 --- a/src/MockHttp/Internal/Response/Behaviors/HttpContentBehavior.cs +++ b/src/MockHttp/Internal/Response/Behaviors/HttpContentBehavior.cs @@ -1,6 +1,4 @@ -using MockHttp.Responses; - -namespace MockHttp.Response.Behaviors; +namespace MockHttp.Response.Behaviors; internal sealed class HttpContentBehavior : IResponseBehavior diff --git a/src/MockHttp/Internal/Response/Behaviors/HttpHeaderBehavior.cs b/src/MockHttp/Internal/Response/Behaviors/HttpHeaderBehavior.cs index 6b952dd1..cb33596a 100644 --- a/src/MockHttp/Internal/Response/Behaviors/HttpHeaderBehavior.cs +++ b/src/MockHttp/Internal/Response/Behaviors/HttpHeaderBehavior.cs @@ -1,5 +1,4 @@ using MockHttp.Http; -using MockHttp.Responses; namespace MockHttp.Response.Behaviors; diff --git a/src/MockHttp/Internal/Response/Behaviors/NetworkLatencyBehavior.cs b/src/MockHttp/Internal/Response/Behaviors/NetworkLatencyBehavior.cs index 9ab511bf..8a382f5e 100644 --- a/src/MockHttp/Internal/Response/Behaviors/NetworkLatencyBehavior.cs +++ b/src/MockHttp/Internal/Response/Behaviors/NetworkLatencyBehavior.cs @@ -1,6 +1,4 @@ -using MockHttp.Responses; - -namespace MockHttp.Response.Behaviors; +namespace MockHttp.Response.Behaviors; internal sealed class NetworkLatencyBehavior : IResponseBehavior diff --git a/src/MockHttp/Internal/Response/Behaviors/StatusCodeBehavior.cs b/src/MockHttp/Internal/Response/Behaviors/StatusCodeBehavior.cs index a6ac5b4c..04c02d95 100644 --- a/src/MockHttp/Internal/Response/Behaviors/StatusCodeBehavior.cs +++ b/src/MockHttp/Internal/Response/Behaviors/StatusCodeBehavior.cs @@ -1,5 +1,4 @@ using System.Net; -using MockHttp.Responses; namespace MockHttp.Response.Behaviors; diff --git a/src/MockHttp/Internal/Response/Behaviors/TimeoutBehavior.cs b/src/MockHttp/Internal/Response/Behaviors/TimeoutBehavior.cs index 10b00f14..83fed725 100644 --- a/src/MockHttp/Internal/Response/Behaviors/TimeoutBehavior.cs +++ b/src/MockHttp/Internal/Response/Behaviors/TimeoutBehavior.cs @@ -1,5 +1,4 @@ using System.Runtime.InteropServices; -using MockHttp.Responses; using MockHttp.Threading; namespace MockHttp.Response.Behaviors; diff --git a/src/MockHttp/Internal/Response/Behaviors/TransferRateBehavior.cs b/src/MockHttp/Internal/Response/Behaviors/TransferRateBehavior.cs index 47869316..b821534e 100644 --- a/src/MockHttp/Internal/Response/Behaviors/TransferRateBehavior.cs +++ b/src/MockHttp/Internal/Response/Behaviors/TransferRateBehavior.cs @@ -1,6 +1,5 @@ using System.Net; using MockHttp.IO; -using MockHttp.Responses; namespace MockHttp.Response.Behaviors; diff --git a/src/MockHttp/Internal/Response/ExceptionStrategy.cs b/src/MockHttp/Internal/Response/ExceptionStrategy.cs index 41e1a66f..a4e9c795 100644 --- a/src/MockHttp/Internal/Response/ExceptionStrategy.cs +++ b/src/MockHttp/Internal/Response/ExceptionStrategy.cs @@ -1,6 +1,4 @@ -using MockHttp.Responses; - -namespace MockHttp.Response; +namespace MockHttp.Response; internal sealed class ExceptionStrategy : IResponseStrategy { diff --git a/src/MockHttp/Internal/Response/ResponseFuncStrategy.cs b/src/MockHttp/Internal/Response/ResponseFuncStrategy.cs index 07bf1418..3d07c3bd 100644 --- a/src/MockHttp/Internal/Response/ResponseFuncStrategy.cs +++ b/src/MockHttp/Internal/Response/ResponseFuncStrategy.cs @@ -1,6 +1,4 @@ -using MockHttp.Responses; - -namespace MockHttp.Response; +namespace MockHttp.Response; internal sealed class ResponseFuncStrategy : IResponseStrategy { diff --git a/src/MockHttp/Language/Flow/Response/EnsureHttpContentBehavior.cs b/src/MockHttp/Language/Flow/Response/EnsureHttpContentBehavior.cs index 7fe2b76f..402d8c51 100644 --- a/src/MockHttp/Language/Flow/Response/EnsureHttpContentBehavior.cs +++ b/src/MockHttp/Language/Flow/Response/EnsureHttpContentBehavior.cs @@ -1,5 +1,5 @@ using MockHttp.Http; -using MockHttp.Responses; +using MockHttp.Response; namespace MockHttp.Language.Flow.Response; diff --git a/src/MockHttp/Language/Flow/Response/ResponseBuilder.cs b/src/MockHttp/Language/Flow/Response/ResponseBuilder.cs index a7bfcc38..183a75a9 100644 --- a/src/MockHttp/Language/Flow/Response/ResponseBuilder.cs +++ b/src/MockHttp/Language/Flow/Response/ResponseBuilder.cs @@ -3,8 +3,8 @@ using System.Net.Http.Headers; using MockHttp.Extensions; using MockHttp.Http; +using MockHttp.Response; using MockHttp.Response.Behaviors; -using MockHttp.Responses; namespace MockHttp.Language.Flow.Response; diff --git a/src/MockHttp/Language/Flow/SetupPhrase.cs b/src/MockHttp/Language/Flow/SetupPhrase.cs index dce15751..ba8b966e 100644 --- a/src/MockHttp/Language/Flow/SetupPhrase.cs +++ b/src/MockHttp/Language/Flow/SetupPhrase.cs @@ -1,6 +1,5 @@ using System.ComponentModel; using MockHttp.Response; -using MockHttp.Responses; namespace MockHttp.Language.Flow; diff --git a/src/MockHttp/Language/IResponds.cs b/src/MockHttp/Language/IResponds.cs index 0bc5a4fb..04e414ae 100644 --- a/src/MockHttp/Language/IResponds.cs +++ b/src/MockHttp/Language/IResponds.cs @@ -1,6 +1,6 @@ using System.ComponentModel; using MockHttp.Language.Flow; -using MockHttp.Responses; +using MockHttp.Response; namespace MockHttp.Language; diff --git a/src/MockHttp/Language/Response/IWithResponse.cs b/src/MockHttp/Language/Response/IWithResponse.cs index 50b487f5..9370b988 100644 --- a/src/MockHttp/Language/Response/IWithResponse.cs +++ b/src/MockHttp/Language/Response/IWithResponse.cs @@ -1,5 +1,5 @@ using System.ComponentModel; -using MockHttp.Responses; +using MockHttp.Response; namespace MockHttp.Language.Response; diff --git a/src/MockHttp/Matchers/AnyMatcher.cs b/src/MockHttp/Matchers/AnyMatcher.cs index 22d0a0c9..092b874b 100644 --- a/src/MockHttp/Matchers/AnyMatcher.cs +++ b/src/MockHttp/Matchers/AnyMatcher.cs @@ -1,6 +1,6 @@ using System.Text; using MockHttp.Extensions; -using MockHttp.Responses; +using MockHttp.Response; namespace MockHttp.Matchers; diff --git a/src/MockHttp/Matchers/ContentMatcher.cs b/src/MockHttp/Matchers/ContentMatcher.cs index 5221216b..9b895f2a 100644 --- a/src/MockHttp/Matchers/ContentMatcher.cs +++ b/src/MockHttp/Matchers/ContentMatcher.cs @@ -1,7 +1,7 @@ using System.Diagnostics; using System.Globalization; using System.Text; -using MockHttp.Responses; +using MockHttp.Response; namespace MockHttp.Matchers; diff --git a/src/MockHttp/Matchers/ExpressionMatcher.cs b/src/MockHttp/Matchers/ExpressionMatcher.cs index 46308945..06b7bc3a 100644 --- a/src/MockHttp/Matchers/ExpressionMatcher.cs +++ b/src/MockHttp/Matchers/ExpressionMatcher.cs @@ -1,5 +1,5 @@ using System.Linq.Expressions; -using MockHttp.Responses; +using MockHttp.Response; namespace MockHttp.Matchers; diff --git a/src/MockHttp/Matchers/FormDataMatcher.cs b/src/MockHttp/Matchers/FormDataMatcher.cs index cc631bcd..e54a494d 100644 --- a/src/MockHttp/Matchers/FormDataMatcher.cs +++ b/src/MockHttp/Matchers/FormDataMatcher.cs @@ -1,6 +1,6 @@ using System.Diagnostics; using MockHttp.Http; -using MockHttp.Responses; +using MockHttp.Response; namespace MockHttp.Matchers; diff --git a/src/MockHttp/Matchers/HttpHeadersMatcher.cs b/src/MockHttp/Matchers/HttpHeadersMatcher.cs index adf718de..a2fdbe12 100644 --- a/src/MockHttp/Matchers/HttpHeadersMatcher.cs +++ b/src/MockHttp/Matchers/HttpHeadersMatcher.cs @@ -1,7 +1,7 @@ using System.Net.Http.Headers; using MockHttp.Http; using MockHttp.Patterns; -using MockHttp.Responses; +using MockHttp.Response; namespace MockHttp.Matchers; diff --git a/src/MockHttp/Matchers/HttpMethodMatcher.cs b/src/MockHttp/Matchers/HttpMethodMatcher.cs index 39299ebf..cf2b9662 100644 --- a/src/MockHttp/Matchers/HttpMethodMatcher.cs +++ b/src/MockHttp/Matchers/HttpMethodMatcher.cs @@ -1,4 +1,4 @@ -using MockHttp.Responses; +using MockHttp.Response; namespace MockHttp.Matchers; diff --git a/src/MockHttp/Matchers/HttpRequestMatcher.cs b/src/MockHttp/Matchers/HttpRequestMatcher.cs index bcc45e42..1e3532cd 100644 --- a/src/MockHttp/Matchers/HttpRequestMatcher.cs +++ b/src/MockHttp/Matchers/HttpRequestMatcher.cs @@ -1,4 +1,4 @@ -using MockHttp.Responses; +using MockHttp.Response; namespace MockHttp.Matchers; diff --git a/src/MockHttp/Matchers/IAsyncHttpRequestMatcher.cs b/src/MockHttp/Matchers/IAsyncHttpRequestMatcher.cs index fa1d2a3e..d4d6f3f0 100644 --- a/src/MockHttp/Matchers/IAsyncHttpRequestMatcher.cs +++ b/src/MockHttp/Matchers/IAsyncHttpRequestMatcher.cs @@ -1,4 +1,4 @@ -using MockHttp.Responses; +using MockHttp.Response; namespace MockHttp.Matchers; diff --git a/src/MockHttp/Matchers/MediaTypeHeaderMatcher.cs b/src/MockHttp/Matchers/MediaTypeHeaderMatcher.cs index 12e39066..4e9dc540 100644 --- a/src/MockHttp/Matchers/MediaTypeHeaderMatcher.cs +++ b/src/MockHttp/Matchers/MediaTypeHeaderMatcher.cs @@ -1,5 +1,5 @@ using System.Net.Http.Headers; -using MockHttp.Responses; +using MockHttp.Response; namespace MockHttp.Matchers; diff --git a/src/MockHttp/Matchers/NotMatcher.cs b/src/MockHttp/Matchers/NotMatcher.cs index e2ba96d3..3674b191 100644 --- a/src/MockHttp/Matchers/NotMatcher.cs +++ b/src/MockHttp/Matchers/NotMatcher.cs @@ -1,4 +1,4 @@ -using MockHttp.Responses; +using MockHttp.Response; namespace MockHttp.Matchers; diff --git a/src/MockHttp/Matchers/QueryStringMatcher.cs b/src/MockHttp/Matchers/QueryStringMatcher.cs index c99fc6ed..8bf3482d 100644 --- a/src/MockHttp/Matchers/QueryStringMatcher.cs +++ b/src/MockHttp/Matchers/QueryStringMatcher.cs @@ -1,6 +1,6 @@ using System.Diagnostics; using MockHttp.Http; -using MockHttp.Responses; +using MockHttp.Response; namespace MockHttp.Matchers; diff --git a/src/MockHttp/Matchers/UriMatcher.cs b/src/MockHttp/Matchers/UriMatcher.cs index e4c06fd5..d621bcf1 100644 --- a/src/MockHttp/Matchers/UriMatcher.cs +++ b/src/MockHttp/Matchers/UriMatcher.cs @@ -1,7 +1,7 @@ using System.Linq.Expressions; using System.Runtime.CompilerServices; using MockHttp.Patterns; -using MockHttp.Responses; +using MockHttp.Response; namespace MockHttp.Matchers; diff --git a/src/MockHttp/Matchers/VersionMatcher.cs b/src/MockHttp/Matchers/VersionMatcher.cs index d424c657..7e4f5cbd 100644 --- a/src/MockHttp/Matchers/VersionMatcher.cs +++ b/src/MockHttp/Matchers/VersionMatcher.cs @@ -1,4 +1,4 @@ -using MockHttp.Responses; +using MockHttp.Response; namespace MockHttp.Matchers; diff --git a/src/MockHttp/MockHttpHandler.cs b/src/MockHttp/MockHttpHandler.cs index 9c4a64ac..8ff19e3f 100644 --- a/src/MockHttp/MockHttpHandler.cs +++ b/src/MockHttp/MockHttpHandler.cs @@ -5,7 +5,7 @@ using MockHttp.Language; using MockHttp.Language.Flow; using MockHttp.Matchers; -using MockHttp.Responses; +using MockHttp.Response; using MockHttp.Threading; namespace MockHttp; diff --git a/src/MockHttp/Responses/IResponseBehavior.cs b/src/MockHttp/Response/IResponseBehavior.cs similarity index 97% rename from src/MockHttp/Responses/IResponseBehavior.cs rename to src/MockHttp/Response/IResponseBehavior.cs index 024f712e..13c749b6 100644 --- a/src/MockHttp/Responses/IResponseBehavior.cs +++ b/src/MockHttp/Response/IResponseBehavior.cs @@ -1,4 +1,4 @@ -namespace MockHttp.Responses; +namespace MockHttp.Response; /// /// A delegate which when executed returns a configured HTTP response. diff --git a/src/MockHttp/Responses/IResponseStrategy.cs b/src/MockHttp/Response/IResponseStrategy.cs similarity index 94% rename from src/MockHttp/Responses/IResponseStrategy.cs rename to src/MockHttp/Response/IResponseStrategy.cs index 54f502a5..97decbe5 100644 --- a/src/MockHttp/Responses/IResponseStrategy.cs +++ b/src/MockHttp/Response/IResponseStrategy.cs @@ -1,4 +1,4 @@ -namespace MockHttp.Responses; +namespace MockHttp.Response; /// /// Represents a strategy that produces a mocked response. diff --git a/src/MockHttp/Responses/MockHttpRequestContext.cs b/src/MockHttp/Response/MockHttpRequestContext.cs similarity index 98% rename from src/MockHttp/Responses/MockHttpRequestContext.cs rename to src/MockHttp/Response/MockHttpRequestContext.cs index 6e6f586e..8c7530da 100644 --- a/src/MockHttp/Responses/MockHttpRequestContext.cs +++ b/src/MockHttp/Response/MockHttpRequestContext.cs @@ -1,7 +1,7 @@ using System.Collections.ObjectModel; using System.Diagnostics.CodeAnalysis; -namespace MockHttp.Responses; +namespace MockHttp.Response; /// /// Represents the mocked request context. diff --git a/test/MockHttp.Json.Tests/Extensions/MockHttpRequestContextExtensionsTests.cs b/test/MockHttp.Json.Tests/Extensions/MockHttpRequestContextExtensionsTests.cs index 8d1f0f01..1a48ae8b 100644 --- a/test/MockHttp.Json.Tests/Extensions/MockHttpRequestContextExtensionsTests.cs +++ b/test/MockHttp.Json.Tests/Extensions/MockHttpRequestContextExtensionsTests.cs @@ -1,5 +1,5 @@ using MockHttp.Json.SystemTextJson; -using MockHttp.Responses; +using MockHttp.Response; namespace MockHttp.Json.Extensions; diff --git a/test/MockHttp.Json.Tests/JsonContentMatcherTests.cs b/test/MockHttp.Json.Tests/JsonContentMatcherTests.cs index 25fb1c7f..75a157a1 100644 --- a/test/MockHttp.Json.Tests/JsonContentMatcherTests.cs +++ b/test/MockHttp.Json.Tests/JsonContentMatcherTests.cs @@ -1,4 +1,4 @@ -using MockHttp.Responses; +using MockHttp.Response; namespace MockHttp.Json; diff --git a/test/MockHttp.Tests/Extensions/IRespondsExtensionsTests.cs b/test/MockHttp.Tests/Extensions/IRespondsExtensionsTests.cs index 12c51bc2..35f9868b 100644 --- a/test/MockHttp.Tests/Extensions/IRespondsExtensionsTests.cs +++ b/test/MockHttp.Tests/Extensions/IRespondsExtensionsTests.cs @@ -3,7 +3,7 @@ using MockHttp.FluentAssertions; using MockHttp.Language; using MockHttp.Language.Flow; -using MockHttp.Responses; +using MockHttp.Response; namespace MockHttp; diff --git a/test/MockHttp.Tests/Extensions/RequestMatchingExtensionsTests.cs b/test/MockHttp.Tests/Extensions/RequestMatchingExtensionsTests.cs index 62c679bb..dfc03f79 100644 --- a/test/MockHttp.Tests/Extensions/RequestMatchingExtensionsTests.cs +++ b/test/MockHttp.Tests/Extensions/RequestMatchingExtensionsTests.cs @@ -6,7 +6,7 @@ using MockHttp.Extensions; using MockHttp.Http; using MockHttp.Matchers; -using MockHttp.Responses; +using MockHttp.Response; using static MockHttp.Http.UriExtensions; namespace MockHttp; diff --git a/test/MockHttp.Tests/Internal/HttpCallTests.cs b/test/MockHttp.Tests/Internal/HttpCallTests.cs index 0717bfe5..eff109fa 100644 --- a/test/MockHttp.Tests/Internal/HttpCallTests.cs +++ b/test/MockHttp.Tests/Internal/HttpCallTests.cs @@ -1,5 +1,4 @@ using MockHttp.Response; -using MockHttp.Responses; namespace MockHttp; diff --git a/test/MockHttp.Tests/Internal/Response/Behaviors/TimeoutBehaviorTests.cs b/test/MockHttp.Tests/Internal/Response/Behaviors/TimeoutBehaviorTests.cs index 05155565..a98ec6dc 100644 --- a/test/MockHttp.Tests/Internal/Response/Behaviors/TimeoutBehaviorTests.cs +++ b/test/MockHttp.Tests/Internal/Response/Behaviors/TimeoutBehaviorTests.cs @@ -1,5 +1,4 @@ using System.Diagnostics; -using MockHttp.Responses; namespace MockHttp.Response.Behaviors; diff --git a/test/MockHttp.Tests/Internal/Response/ExceptionStrategyTests.cs b/test/MockHttp.Tests/Internal/Response/ExceptionStrategyTests.cs index 15026db4..9bfd1a03 100644 --- a/test/MockHttp.Tests/Internal/Response/ExceptionStrategyTests.cs +++ b/test/MockHttp.Tests/Internal/Response/ExceptionStrategyTests.cs @@ -1,6 +1,4 @@ -using MockHttp.Responses; - -namespace MockHttp.Response; +namespace MockHttp.Response; public class ExceptionStrategyTests { diff --git a/test/MockHttp.Tests/Internal/Response/ResponseFuncStrategyTests.cs b/test/MockHttp.Tests/Internal/Response/ResponseFuncStrategyTests.cs index 5e51aff6..4a7e1581 100644 --- a/test/MockHttp.Tests/Internal/Response/ResponseFuncStrategyTests.cs +++ b/test/MockHttp.Tests/Internal/Response/ResponseFuncStrategyTests.cs @@ -1,6 +1,4 @@ -using MockHttp.Responses; - -namespace MockHttp.Response; +namespace MockHttp.Response; public class ResponseFuncStrategyTests { diff --git a/test/MockHttp.Tests/Matchers/AnyMatcherTests.cs b/test/MockHttp.Tests/Matchers/AnyMatcherTests.cs index 2615588b..56ed0cbb 100644 --- a/test/MockHttp.Tests/Matchers/AnyMatcherTests.cs +++ b/test/MockHttp.Tests/Matchers/AnyMatcherTests.cs @@ -1,4 +1,4 @@ -using MockHttp.Responses; +using MockHttp.Response; namespace MockHttp.Matchers; diff --git a/test/MockHttp.Tests/Matchers/BoolMatcher.cs b/test/MockHttp.Tests/Matchers/BoolMatcher.cs index 7ff182da..4b57c5dc 100644 --- a/test/MockHttp.Tests/Matchers/BoolMatcher.cs +++ b/test/MockHttp.Tests/Matchers/BoolMatcher.cs @@ -1,4 +1,4 @@ -using MockHttp.Responses; +using MockHttp.Response; namespace MockHttp.Matchers; diff --git a/test/MockHttp.Tests/Matchers/ContentMatcherTests.cs b/test/MockHttp.Tests/Matchers/ContentMatcherTests.cs index 1e16afb6..74ed129a 100644 --- a/test/MockHttp.Tests/Matchers/ContentMatcherTests.cs +++ b/test/MockHttp.Tests/Matchers/ContentMatcherTests.cs @@ -1,5 +1,5 @@ using System.Text; -using MockHttp.Responses; +using MockHttp.Response; namespace MockHttp.Matchers; diff --git a/test/MockHttp.Tests/Matchers/ExpressionMatcherTests.cs b/test/MockHttp.Tests/Matchers/ExpressionMatcherTests.cs index b497e0d2..5aef2b28 100644 --- a/test/MockHttp.Tests/Matchers/ExpressionMatcherTests.cs +++ b/test/MockHttp.Tests/Matchers/ExpressionMatcherTests.cs @@ -1,5 +1,5 @@ using System.Linq.Expressions; -using MockHttp.Responses; +using MockHttp.Response; namespace MockHttp.Matchers; diff --git a/test/MockHttp.Tests/Matchers/FakeToStringTestMatcher.cs b/test/MockHttp.Tests/Matchers/FakeToStringTestMatcher.cs index 0a4660e5..e994b461 100644 --- a/test/MockHttp.Tests/Matchers/FakeToStringTestMatcher.cs +++ b/test/MockHttp.Tests/Matchers/FakeToStringTestMatcher.cs @@ -1,4 +1,4 @@ -using MockHttp.Responses; +using MockHttp.Response; namespace MockHttp.Matchers; diff --git a/test/MockHttp.Tests/Matchers/FormDataMatcherTests.cs b/test/MockHttp.Tests/Matchers/FormDataMatcherTests.cs index 8844b36b..a88a4651 100644 --- a/test/MockHttp.Tests/Matchers/FormDataMatcherTests.cs +++ b/test/MockHttp.Tests/Matchers/FormDataMatcherTests.cs @@ -1,7 +1,7 @@ using System.Net.Http.Headers; using System.Text; using MockHttp.Http; -using MockHttp.Responses; +using MockHttp.Response; namespace MockHttp.Matchers; diff --git a/test/MockHttp.Tests/Matchers/HttpHeadersMatcherTests.cs b/test/MockHttp.Tests/Matchers/HttpHeadersMatcherTests.cs index a2dd4688..608bce4b 100644 --- a/test/MockHttp.Tests/Matchers/HttpHeadersMatcherTests.cs +++ b/test/MockHttp.Tests/Matchers/HttpHeadersMatcherTests.cs @@ -1,7 +1,7 @@ using System.Globalization; using System.Net.Http.Headers; using MockHttp.Http; -using MockHttp.Responses; +using MockHttp.Response; namespace MockHttp.Matchers; diff --git a/test/MockHttp.Tests/Matchers/HttpMethodMatcherTests.cs b/test/MockHttp.Tests/Matchers/HttpMethodMatcherTests.cs index e1fdcb8d..3f7ef798 100644 --- a/test/MockHttp.Tests/Matchers/HttpMethodMatcherTests.cs +++ b/test/MockHttp.Tests/Matchers/HttpMethodMatcherTests.cs @@ -1,4 +1,4 @@ -using MockHttp.Responses; +using MockHttp.Response; namespace MockHttp.Matchers; diff --git a/test/MockHttp.Tests/Matchers/HttpRequestMatcherTests.cs b/test/MockHttp.Tests/Matchers/HttpRequestMatcherTests.cs index d464ddd1..08609907 100644 --- a/test/MockHttp.Tests/Matchers/HttpRequestMatcherTests.cs +++ b/test/MockHttp.Tests/Matchers/HttpRequestMatcherTests.cs @@ -1,4 +1,4 @@ -using MockHttp.Responses; +using MockHttp.Response; namespace MockHttp.Matchers; diff --git a/test/MockHttp.Tests/Matchers/MediaTypeHeaderMatcherTests.cs b/test/MockHttp.Tests/Matchers/MediaTypeHeaderMatcherTests.cs index 0d0f66d3..dd5d8409 100644 --- a/test/MockHttp.Tests/Matchers/MediaTypeHeaderMatcherTests.cs +++ b/test/MockHttp.Tests/Matchers/MediaTypeHeaderMatcherTests.cs @@ -1,6 +1,6 @@ using System.Net.Http.Headers; using MockHttp.Http; -using MockHttp.Responses; +using MockHttp.Response; namespace MockHttp.Matchers; diff --git a/test/MockHttp.Tests/Matchers/NotMatcherTests.cs b/test/MockHttp.Tests/Matchers/NotMatcherTests.cs index 342130f7..9cf2fa9d 100644 --- a/test/MockHttp.Tests/Matchers/NotMatcherTests.cs +++ b/test/MockHttp.Tests/Matchers/NotMatcherTests.cs @@ -1,4 +1,4 @@ -using MockHttp.Responses; +using MockHttp.Response; namespace MockHttp.Matchers; diff --git a/test/MockHttp.Tests/Matchers/PartialContentMatcherTests.cs b/test/MockHttp.Tests/Matchers/PartialContentMatcherTests.cs index f743a7b8..23bf38a5 100644 --- a/test/MockHttp.Tests/Matchers/PartialContentMatcherTests.cs +++ b/test/MockHttp.Tests/Matchers/PartialContentMatcherTests.cs @@ -1,5 +1,5 @@ using System.Text; -using MockHttp.Responses; +using MockHttp.Response; namespace MockHttp.Matchers; diff --git a/test/MockHttp.Tests/Matchers/QueryStringMatcherTests.cs b/test/MockHttp.Tests/Matchers/QueryStringMatcherTests.cs index 2cdc6a1a..9e8fd917 100644 --- a/test/MockHttp.Tests/Matchers/QueryStringMatcherTests.cs +++ b/test/MockHttp.Tests/Matchers/QueryStringMatcherTests.cs @@ -1,4 +1,4 @@ -using MockHttp.Responses; +using MockHttp.Response; namespace MockHttp.Matchers; diff --git a/test/MockHttp.Tests/Matchers/VersionMatcherTests.cs b/test/MockHttp.Tests/Matchers/VersionMatcherTests.cs index dc3c94b6..aaee48fa 100644 --- a/test/MockHttp.Tests/Matchers/VersionMatcherTests.cs +++ b/test/MockHttp.Tests/Matchers/VersionMatcherTests.cs @@ -1,4 +1,4 @@ -using MockHttp.Responses; +using MockHttp.Response; namespace MockHttp.Matchers; diff --git a/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_6.0.verified.txt b/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_6.0.verified.txt index c7d37fb5..8408ea9a 100644 --- a/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_6.0.verified.txt +++ b/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_6.0.verified.txt @@ -53,9 +53,9 @@ namespace MockHttp { public static TResult Respond(this MockHttp.Language.IResponds responds, System.Action with) where TResult : MockHttp.Language.Flow.IResponseResult { } - public static TResult Respond(this MockHttp.Language.IResponds responds, System.Action with) + public static TResult Respond(this MockHttp.Language.IResponds responds, System.Action with) where TResult : MockHttp.Language.Flow.IResponseResult { } - public static TResult Respond(this MockHttp.Language.IResponds responds, System.Action with) + public static TResult Respond(this MockHttp.Language.IResponds responds, System.Action with) where TResult : MockHttp.Language.Flow.IResponseResult { } public static TResult Respond(this MockHttp.Language.IResponds responds, System.Func response) where TResult : MockHttp.Language.Flow.IResponseResult { } @@ -331,7 +331,7 @@ namespace MockHttp.Language public interface IResponds : MockHttp.IFluentInterface where out TResult : MockHttp.Language.Flow.IResponseResult { - TResult RespondUsing(MockHttp.Responses.IResponseStrategy responseStrategy); + TResult RespondUsing(MockHttp.Response.IResponseStrategy responseStrategy); } public interface IThrows : MockHttp.IFluentInterface where out TResult : MockHttp.Language.Flow.IThrowsResult @@ -362,7 +362,7 @@ namespace MockHttp.Language.Response } public interface IWithResponse : MockHttp.IFluentInterface { - System.Collections.Generic.IList Behaviors { get; } + System.Collections.Generic.IList Behaviors { get; } } public interface IWithStatusCode : MockHttp.IFluentInterface, MockHttp.Language.Response.IWithContent, MockHttp.Language.Response.IWithResponse { @@ -374,18 +374,18 @@ namespace MockHttp.Matchers public interface IAsyncHttpRequestMatcher { bool IsExclusive { get; } - System.Threading.Tasks.Task IsMatchAsync(MockHttp.Responses.MockHttpRequestContext requestContext); + System.Threading.Tasks.Task IsMatchAsync(MockHttp.Response.MockHttpRequestContext requestContext); } } -namespace MockHttp.Responses +namespace MockHttp.Response { public interface IResponseBehavior { - System.Threading.Tasks.Task HandleAsync(MockHttp.Responses.MockHttpRequestContext requestContext, System.Net.Http.HttpResponseMessage responseMessage, MockHttp.Responses.ResponseHandler nextHandler, System.Threading.CancellationToken cancellationToken); + System.Threading.Tasks.Task HandleAsync(MockHttp.Response.MockHttpRequestContext requestContext, System.Net.Http.HttpResponseMessage responseMessage, MockHttp.Response.ResponseHandler nextHandler, System.Threading.CancellationToken cancellationToken); } public interface IResponseStrategy { - System.Threading.Tasks.Task ProduceResponseAsync(MockHttp.Responses.MockHttpRequestContext requestContext, System.Threading.CancellationToken cancellationToken); + System.Threading.Tasks.Task ProduceResponseAsync(MockHttp.Response.MockHttpRequestContext requestContext, System.Threading.CancellationToken cancellationToken); } public class MockHttpRequestContext { @@ -394,5 +394,5 @@ namespace MockHttp.Responses public System.Collections.Generic.IReadOnlyDictionary Services { get; } public bool TryGetService([System.Diagnostics.CodeAnalysis.NotNullWhen(true)] out TService? service) { } } - public delegate System.Threading.Tasks.Task ResponseHandler(MockHttp.Responses.MockHttpRequestContext requestContext, System.Net.Http.HttpResponseMessage responseMessage, System.Threading.CancellationToken cancellationToken); + public delegate System.Threading.Tasks.Task ResponseHandler(MockHttp.Response.MockHttpRequestContext requestContext, System.Net.Http.HttpResponseMessage responseMessage, System.Threading.CancellationToken cancellationToken); } \ No newline at end of file diff --git a/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_8.0.verified.txt b/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_8.0.verified.txt index ef71af40..3fb41422 100644 --- a/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_8.0.verified.txt +++ b/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_8.0.verified.txt @@ -54,9 +54,9 @@ namespace MockHttp { public static TResult Respond(this MockHttp.Language.IResponds responds, System.Action with) where TResult : MockHttp.Language.Flow.IResponseResult { } - public static TResult Respond(this MockHttp.Language.IResponds responds, System.Action with) + public static TResult Respond(this MockHttp.Language.IResponds responds, System.Action with) where TResult : MockHttp.Language.Flow.IResponseResult { } - public static TResult Respond(this MockHttp.Language.IResponds responds, System.Action with) + public static TResult Respond(this MockHttp.Language.IResponds responds, System.Action with) where TResult : MockHttp.Language.Flow.IResponseResult { } public static TResult Respond(this MockHttp.Language.IResponds responds, System.Func response) where TResult : MockHttp.Language.Flow.IResponseResult { } @@ -332,7 +332,7 @@ namespace MockHttp.Language public interface IResponds : MockHttp.IFluentInterface where out TResult : MockHttp.Language.Flow.IResponseResult { - TResult RespondUsing(MockHttp.Responses.IResponseStrategy responseStrategy); + TResult RespondUsing(MockHttp.Response.IResponseStrategy responseStrategy); } public interface IThrows : MockHttp.IFluentInterface where out TResult : MockHttp.Language.Flow.IThrowsResult @@ -363,7 +363,7 @@ namespace MockHttp.Language.Response } public interface IWithResponse : MockHttp.IFluentInterface { - System.Collections.Generic.IList Behaviors { get; } + System.Collections.Generic.IList Behaviors { get; } } public interface IWithStatusCode : MockHttp.IFluentInterface, MockHttp.Language.Response.IWithContent, MockHttp.Language.Response.IWithResponse { @@ -375,18 +375,18 @@ namespace MockHttp.Matchers public interface IAsyncHttpRequestMatcher { bool IsExclusive { get; } - System.Threading.Tasks.Task IsMatchAsync(MockHttp.Responses.MockHttpRequestContext requestContext); + System.Threading.Tasks.Task IsMatchAsync(MockHttp.Response.MockHttpRequestContext requestContext); } } -namespace MockHttp.Responses +namespace MockHttp.Response { public interface IResponseBehavior { - System.Threading.Tasks.Task HandleAsync(MockHttp.Responses.MockHttpRequestContext requestContext, System.Net.Http.HttpResponseMessage responseMessage, MockHttp.Responses.ResponseHandler nextHandler, System.Threading.CancellationToken cancellationToken); + System.Threading.Tasks.Task HandleAsync(MockHttp.Response.MockHttpRequestContext requestContext, System.Net.Http.HttpResponseMessage responseMessage, MockHttp.Response.ResponseHandler nextHandler, System.Threading.CancellationToken cancellationToken); } public interface IResponseStrategy { - System.Threading.Tasks.Task ProduceResponseAsync(MockHttp.Responses.MockHttpRequestContext requestContext, System.Threading.CancellationToken cancellationToken); + System.Threading.Tasks.Task ProduceResponseAsync(MockHttp.Response.MockHttpRequestContext requestContext, System.Threading.CancellationToken cancellationToken); } public class MockHttpRequestContext { @@ -395,5 +395,5 @@ namespace MockHttp.Responses public System.Collections.Generic.IReadOnlyDictionary Services { get; } public bool TryGetService([System.Diagnostics.CodeAnalysis.NotNullWhen(true)] out TService? service) { } } - public delegate System.Threading.Tasks.Task ResponseHandler(MockHttp.Responses.MockHttpRequestContext requestContext, System.Net.Http.HttpResponseMessage responseMessage, System.Threading.CancellationToken cancellationToken); + public delegate System.Threading.Tasks.Task ResponseHandler(MockHttp.Response.MockHttpRequestContext requestContext, System.Net.Http.HttpResponseMessage responseMessage, System.Threading.CancellationToken cancellationToken); } \ No newline at end of file diff --git a/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_Framework_4.6.2.verified.txt b/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_Framework_4.6.2.verified.txt index c8ce6115..5aa08e99 100644 --- a/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_Framework_4.6.2.verified.txt +++ b/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_Framework_4.6.2.verified.txt @@ -53,9 +53,9 @@ namespace MockHttp { public static TResult Respond(this MockHttp.Language.IResponds responds, System.Action with) where TResult : MockHttp.Language.Flow.IResponseResult { } - public static TResult Respond(this MockHttp.Language.IResponds responds, System.Action with) + public static TResult Respond(this MockHttp.Language.IResponds responds, System.Action with) where TResult : MockHttp.Language.Flow.IResponseResult { } - public static TResult Respond(this MockHttp.Language.IResponds responds, System.Action with) + public static TResult Respond(this MockHttp.Language.IResponds responds, System.Action with) where TResult : MockHttp.Language.Flow.IResponseResult { } public static TResult Respond(this MockHttp.Language.IResponds responds, System.Func response) where TResult : MockHttp.Language.Flow.IResponseResult { } @@ -331,7 +331,7 @@ namespace MockHttp.Language public interface IResponds : MockHttp.IFluentInterface where out TResult : MockHttp.Language.Flow.IResponseResult { - TResult RespondUsing(MockHttp.Responses.IResponseStrategy responseStrategy); + TResult RespondUsing(MockHttp.Response.IResponseStrategy responseStrategy); } public interface IThrows : MockHttp.IFluentInterface where out TResult : MockHttp.Language.Flow.IThrowsResult @@ -362,7 +362,7 @@ namespace MockHttp.Language.Response } public interface IWithResponse : MockHttp.IFluentInterface { - System.Collections.Generic.IList Behaviors { get; } + System.Collections.Generic.IList Behaviors { get; } } public interface IWithStatusCode : MockHttp.IFluentInterface, MockHttp.Language.Response.IWithContent, MockHttp.Language.Response.IWithResponse { @@ -374,18 +374,18 @@ namespace MockHttp.Matchers public interface IAsyncHttpRequestMatcher { bool IsExclusive { get; } - System.Threading.Tasks.Task IsMatchAsync(MockHttp.Responses.MockHttpRequestContext requestContext); + System.Threading.Tasks.Task IsMatchAsync(MockHttp.Response.MockHttpRequestContext requestContext); } } -namespace MockHttp.Responses +namespace MockHttp.Response { public interface IResponseBehavior { - System.Threading.Tasks.Task HandleAsync(MockHttp.Responses.MockHttpRequestContext requestContext, System.Net.Http.HttpResponseMessage responseMessage, MockHttp.Responses.ResponseHandler nextHandler, System.Threading.CancellationToken cancellationToken); + System.Threading.Tasks.Task HandleAsync(MockHttp.Response.MockHttpRequestContext requestContext, System.Net.Http.HttpResponseMessage responseMessage, MockHttp.Response.ResponseHandler nextHandler, System.Threading.CancellationToken cancellationToken); } public interface IResponseStrategy { - System.Threading.Tasks.Task ProduceResponseAsync(MockHttp.Responses.MockHttpRequestContext requestContext, System.Threading.CancellationToken cancellationToken); + System.Threading.Tasks.Task ProduceResponseAsync(MockHttp.Response.MockHttpRequestContext requestContext, System.Threading.CancellationToken cancellationToken); } public class MockHttpRequestContext { @@ -394,5 +394,5 @@ namespace MockHttp.Responses public System.Collections.Generic.IReadOnlyDictionary Services { get; } public bool TryGetService([System.Diagnostics.CodeAnalysis.NotNullWhen(true)] out TService? service) { } } - public delegate System.Threading.Tasks.Task ResponseHandler(MockHttp.Responses.MockHttpRequestContext requestContext, System.Net.Http.HttpResponseMessage responseMessage, System.Threading.CancellationToken cancellationToken); + public delegate System.Threading.Tasks.Task ResponseHandler(MockHttp.Response.MockHttpRequestContext requestContext, System.Net.Http.HttpResponseMessage responseMessage, System.Threading.CancellationToken cancellationToken); } \ No newline at end of file diff --git a/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_Framework_4.7.2.verified.txt b/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_Framework_4.7.2.verified.txt index df18bb55..f37ad0c4 100644 --- a/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_Framework_4.7.2.verified.txt +++ b/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_Framework_4.7.2.verified.txt @@ -53,9 +53,9 @@ namespace MockHttp { public static TResult Respond(this MockHttp.Language.IResponds responds, System.Action with) where TResult : MockHttp.Language.Flow.IResponseResult { } - public static TResult Respond(this MockHttp.Language.IResponds responds, System.Action with) + public static TResult Respond(this MockHttp.Language.IResponds responds, System.Action with) where TResult : MockHttp.Language.Flow.IResponseResult { } - public static TResult Respond(this MockHttp.Language.IResponds responds, System.Action with) + public static TResult Respond(this MockHttp.Language.IResponds responds, System.Action with) where TResult : MockHttp.Language.Flow.IResponseResult { } public static TResult Respond(this MockHttp.Language.IResponds responds, System.Func response) where TResult : MockHttp.Language.Flow.IResponseResult { } @@ -331,7 +331,7 @@ namespace MockHttp.Language public interface IResponds : MockHttp.IFluentInterface where out TResult : MockHttp.Language.Flow.IResponseResult { - TResult RespondUsing(MockHttp.Responses.IResponseStrategy responseStrategy); + TResult RespondUsing(MockHttp.Response.IResponseStrategy responseStrategy); } public interface IThrows : MockHttp.IFluentInterface where out TResult : MockHttp.Language.Flow.IThrowsResult @@ -362,7 +362,7 @@ namespace MockHttp.Language.Response } public interface IWithResponse : MockHttp.IFluentInterface { - System.Collections.Generic.IList Behaviors { get; } + System.Collections.Generic.IList Behaviors { get; } } public interface IWithStatusCode : MockHttp.IFluentInterface, MockHttp.Language.Response.IWithContent, MockHttp.Language.Response.IWithResponse { @@ -374,18 +374,18 @@ namespace MockHttp.Matchers public interface IAsyncHttpRequestMatcher { bool IsExclusive { get; } - System.Threading.Tasks.Task IsMatchAsync(MockHttp.Responses.MockHttpRequestContext requestContext); + System.Threading.Tasks.Task IsMatchAsync(MockHttp.Response.MockHttpRequestContext requestContext); } } -namespace MockHttp.Responses +namespace MockHttp.Response { public interface IResponseBehavior { - System.Threading.Tasks.Task HandleAsync(MockHttp.Responses.MockHttpRequestContext requestContext, System.Net.Http.HttpResponseMessage responseMessage, MockHttp.Responses.ResponseHandler nextHandler, System.Threading.CancellationToken cancellationToken); + System.Threading.Tasks.Task HandleAsync(MockHttp.Response.MockHttpRequestContext requestContext, System.Net.Http.HttpResponseMessage responseMessage, MockHttp.Response.ResponseHandler nextHandler, System.Threading.CancellationToken cancellationToken); } public interface IResponseStrategy { - System.Threading.Tasks.Task ProduceResponseAsync(MockHttp.Responses.MockHttpRequestContext requestContext, System.Threading.CancellationToken cancellationToken); + System.Threading.Tasks.Task ProduceResponseAsync(MockHttp.Response.MockHttpRequestContext requestContext, System.Threading.CancellationToken cancellationToken); } public class MockHttpRequestContext { @@ -394,5 +394,5 @@ namespace MockHttp.Responses public System.Collections.Generic.IReadOnlyDictionary Services { get; } public bool TryGetService([System.Diagnostics.CodeAnalysis.NotNullWhen(true)] out TService? service) { } } - public delegate System.Threading.Tasks.Task ResponseHandler(MockHttp.Responses.MockHttpRequestContext requestContext, System.Net.Http.HttpResponseMessage responseMessage, System.Threading.CancellationToken cancellationToken); + public delegate System.Threading.Tasks.Task ResponseHandler(MockHttp.Response.MockHttpRequestContext requestContext, System.Net.Http.HttpResponseMessage responseMessage, System.Threading.CancellationToken cancellationToken); } \ No newline at end of file diff --git a/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_Framework_4.8.verified.txt b/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_Framework_4.8.verified.txt index 0ba5dc47..8a9c96ae 100644 --- a/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_Framework_4.8.verified.txt +++ b/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_Framework_4.8.verified.txt @@ -53,9 +53,9 @@ namespace MockHttp { public static TResult Respond(this MockHttp.Language.IResponds responds, System.Action with) where TResult : MockHttp.Language.Flow.IResponseResult { } - public static TResult Respond(this MockHttp.Language.IResponds responds, System.Action with) + public static TResult Respond(this MockHttp.Language.IResponds responds, System.Action with) where TResult : MockHttp.Language.Flow.IResponseResult { } - public static TResult Respond(this MockHttp.Language.IResponds responds, System.Action with) + public static TResult Respond(this MockHttp.Language.IResponds responds, System.Action with) where TResult : MockHttp.Language.Flow.IResponseResult { } public static TResult Respond(this MockHttp.Language.IResponds responds, System.Func response) where TResult : MockHttp.Language.Flow.IResponseResult { } @@ -331,7 +331,7 @@ namespace MockHttp.Language public interface IResponds : MockHttp.IFluentInterface where out TResult : MockHttp.Language.Flow.IResponseResult { - TResult RespondUsing(MockHttp.Responses.IResponseStrategy responseStrategy); + TResult RespondUsing(MockHttp.Response.IResponseStrategy responseStrategy); } public interface IThrows : MockHttp.IFluentInterface where out TResult : MockHttp.Language.Flow.IThrowsResult @@ -362,7 +362,7 @@ namespace MockHttp.Language.Response } public interface IWithResponse : MockHttp.IFluentInterface { - System.Collections.Generic.IList Behaviors { get; } + System.Collections.Generic.IList Behaviors { get; } } public interface IWithStatusCode : MockHttp.IFluentInterface, MockHttp.Language.Response.IWithContent, MockHttp.Language.Response.IWithResponse { @@ -374,18 +374,18 @@ namespace MockHttp.Matchers public interface IAsyncHttpRequestMatcher { bool IsExclusive { get; } - System.Threading.Tasks.Task IsMatchAsync(MockHttp.Responses.MockHttpRequestContext requestContext); + System.Threading.Tasks.Task IsMatchAsync(MockHttp.Response.MockHttpRequestContext requestContext); } } -namespace MockHttp.Responses +namespace MockHttp.Response { public interface IResponseBehavior { - System.Threading.Tasks.Task HandleAsync(MockHttp.Responses.MockHttpRequestContext requestContext, System.Net.Http.HttpResponseMessage responseMessage, MockHttp.Responses.ResponseHandler nextHandler, System.Threading.CancellationToken cancellationToken); + System.Threading.Tasks.Task HandleAsync(MockHttp.Response.MockHttpRequestContext requestContext, System.Net.Http.HttpResponseMessage responseMessage, MockHttp.Response.ResponseHandler nextHandler, System.Threading.CancellationToken cancellationToken); } public interface IResponseStrategy { - System.Threading.Tasks.Task ProduceResponseAsync(MockHttp.Responses.MockHttpRequestContext requestContext, System.Threading.CancellationToken cancellationToken); + System.Threading.Tasks.Task ProduceResponseAsync(MockHttp.Response.MockHttpRequestContext requestContext, System.Threading.CancellationToken cancellationToken); } public class MockHttpRequestContext { @@ -394,5 +394,5 @@ namespace MockHttp.Responses public System.Collections.Generic.IReadOnlyDictionary Services { get; } public bool TryGetService([System.Diagnostics.CodeAnalysis.NotNullWhen(true)] out TService? service) { } } - public delegate System.Threading.Tasks.Task ResponseHandler(MockHttp.Responses.MockHttpRequestContext requestContext, System.Net.Http.HttpResponseMessage responseMessage, System.Threading.CancellationToken cancellationToken); + public delegate System.Threading.Tasks.Task ResponseHandler(MockHttp.Response.MockHttpRequestContext requestContext, System.Net.Http.HttpResponseMessage responseMessage, System.Threading.CancellationToken cancellationToken); } \ No newline at end of file diff --git a/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_Standard_2.1.verified.txt b/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_Standard_2.1.verified.txt index 9bd23c80..c91e5044 100644 --- a/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_Standard_2.1.verified.txt +++ b/test/MockHttp.Tests/PublicApiTests.Api_has_not_changed.NET_Standard_2.1.verified.txt @@ -53,9 +53,9 @@ namespace MockHttp { public static TResult Respond(this MockHttp.Language.IResponds responds, System.Action with) where TResult : MockHttp.Language.Flow.IResponseResult { } - public static TResult Respond(this MockHttp.Language.IResponds responds, System.Action with) + public static TResult Respond(this MockHttp.Language.IResponds responds, System.Action with) where TResult : MockHttp.Language.Flow.IResponseResult { } - public static TResult Respond(this MockHttp.Language.IResponds responds, System.Action with) + public static TResult Respond(this MockHttp.Language.IResponds responds, System.Action with) where TResult : MockHttp.Language.Flow.IResponseResult { } public static TResult Respond(this MockHttp.Language.IResponds responds, System.Func response) where TResult : MockHttp.Language.Flow.IResponseResult { } @@ -331,7 +331,7 @@ namespace MockHttp.Language public interface IResponds : MockHttp.IFluentInterface where out TResult : MockHttp.Language.Flow.IResponseResult { - TResult RespondUsing(MockHttp.Responses.IResponseStrategy responseStrategy); + TResult RespondUsing(MockHttp.Response.IResponseStrategy responseStrategy); } public interface IThrows : MockHttp.IFluentInterface where out TResult : MockHttp.Language.Flow.IThrowsResult @@ -362,7 +362,7 @@ namespace MockHttp.Language.Response } public interface IWithResponse : MockHttp.IFluentInterface { - System.Collections.Generic.IList Behaviors { get; } + System.Collections.Generic.IList Behaviors { get; } } public interface IWithStatusCode : MockHttp.IFluentInterface, MockHttp.Language.Response.IWithContent, MockHttp.Language.Response.IWithResponse { @@ -374,18 +374,18 @@ namespace MockHttp.Matchers public interface IAsyncHttpRequestMatcher { bool IsExclusive { get; } - System.Threading.Tasks.Task IsMatchAsync(MockHttp.Responses.MockHttpRequestContext requestContext); + System.Threading.Tasks.Task IsMatchAsync(MockHttp.Response.MockHttpRequestContext requestContext); } } -namespace MockHttp.Responses +namespace MockHttp.Response { public interface IResponseBehavior { - System.Threading.Tasks.Task HandleAsync(MockHttp.Responses.MockHttpRequestContext requestContext, System.Net.Http.HttpResponseMessage responseMessage, MockHttp.Responses.ResponseHandler nextHandler, System.Threading.CancellationToken cancellationToken); + System.Threading.Tasks.Task HandleAsync(MockHttp.Response.MockHttpRequestContext requestContext, System.Net.Http.HttpResponseMessage responseMessage, MockHttp.Response.ResponseHandler nextHandler, System.Threading.CancellationToken cancellationToken); } public interface IResponseStrategy { - System.Threading.Tasks.Task ProduceResponseAsync(MockHttp.Responses.MockHttpRequestContext requestContext, System.Threading.CancellationToken cancellationToken); + System.Threading.Tasks.Task ProduceResponseAsync(MockHttp.Response.MockHttpRequestContext requestContext, System.Threading.CancellationToken cancellationToken); } public class MockHttpRequestContext { @@ -394,5 +394,5 @@ namespace MockHttp.Responses public System.Collections.Generic.IReadOnlyDictionary Services { get; } public bool TryGetService([System.Diagnostics.CodeAnalysis.NotNullWhen(true)] out TService? service) { } } - public delegate System.Threading.Tasks.Task ResponseHandler(MockHttp.Responses.MockHttpRequestContext requestContext, System.Net.Http.HttpResponseMessage responseMessage, System.Threading.CancellationToken cancellationToken); + public delegate System.Threading.Tasks.Task ResponseHandler(MockHttp.Response.MockHttpRequestContext requestContext, System.Net.Http.HttpResponseMessage responseMessage, System.Threading.CancellationToken cancellationToken); } \ No newline at end of file