diff --git a/CHANGELOG.md b/CHANGELOG.md index 5b8e7103..6f7dca41 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -107,6 +107,7 @@ - [#549](https://github.com/WireMock-Net/WireMock.Net/issues/549) - WithProxy(...) does not save the mappings to file [bug] # 1.3.8 (03 December 2020) +- [#539](https://github.com/WireMock-Net/WireMock.Net/pull/539) - Support for partial JSON matching contributed by [gleb-osokin](https://github.com/gleb-osokin) - [#542](https://github.com/WireMock-Net/WireMock.Net/pull/542) - Create dotnet-wiremock tool [feature] contributed by [StefH](https://github.com/StefH) - [#543](https://github.com/WireMock-Net/WireMock.Net/pull/543) - Add support for .NET 5 [feature] contributed by [StefH](https://github.com/StefH) - [#544](https://github.com/WireMock-Net/WireMock.Net/pull/544) - Use Java 11 in Azure Pipelines (needed for SonarCloud) [feature] contributed by [StefH](https://github.com/StefH) @@ -114,9 +115,6 @@ - [#547](https://github.com/WireMock-Net/WireMock.Net/pull/547) - Fix Proxying with SSL and NetCoreApp3.1 [bug] contributed by [StefH](https://github.com/StefH) - [#524](https://github.com/WireMock-Net/WireMock.Net/issues/524) - Proxying with SSL Not Working in .NET Core 3.1 [bug] -# 1.3.7 (17 November 2020) -- [#539](https://github.com/WireMock-Net/WireMock.Net/pull/539) - Support for partial JSON matching contributed by [gleb-osokin](https://github.com/gleb-osokin) - # 1.3.6 (10 November 2020) - [#529](https://github.com/WireMock-Net/WireMock.Net/pull/529) - Add assertions for ClientIP, Url and ProxyUrl [feature] contributed by [akamud](https://github.com/akamud) - [#535](https://github.com/WireMock-Net/WireMock.Net/pull/535) - WithCallback should use also use enum HttpStatusCode [bug] contributed by [StefH](https://github.com/StefH) diff --git a/Directory.Build.props b/Directory.Build.props index 4a8af1de..87ad1fed 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -4,7 +4,7 @@ - 1.4.22 + 1.4.23 See CHANGELOG.md WireMock.Net-Logo.png https://github.com/WireMock-Net/WireMock.Net diff --git a/Generate-ReleaseNotes.cmd b/Generate-ReleaseNotes.cmd index e7704113..274e6525 100644 --- a/Generate-ReleaseNotes.cmd +++ b/Generate-ReleaseNotes.cmd @@ -1,7 +1,7 @@ rem https://github.com/StefH/GitHubReleaseNotes -SET version=1.4.22 +SET version=1.4.23 -GitHubReleaseNotes --output CHANGELOG.md --skip-empty-releases --exclude-labels question invalid doc duplicate --version %version% +GitHubReleaseNotes --output CHANGELOG.md --skip-empty-releases --exclude-labels question invalid doc duplicate --version %version% --token %GH_TOKEN% -GitHubReleaseNotes --output PackageReleaseNotes.txt --skip-empty-releases --exclude-labels question invalid doc duplicate --template PackageReleaseNotes.template --version %version% \ No newline at end of file +GitHubReleaseNotes --output PackageReleaseNotes.txt --skip-empty-releases --exclude-labels question invalid doc duplicate --template PackageReleaseNotes.template --version %version% --token %GH_TOKEN% \ No newline at end of file diff --git a/PackageReleaseNotes.txt b/PackageReleaseNotes.txt index 118ed379..3d621f92 100644 --- a/PackageReleaseNotes.txt +++ b/PackageReleaseNotes.txt @@ -1,4 +1,4 @@ -# 1.4.21 (16 September 2021) -- #631 Add WireMock.org RestClient [feature] +# 1.4.22 (22 September 2021) +- #633 Implement Random Delay [feature] The full release notes can be found here: https://github.com/WireMock-Net/WireMock.Net/blob/master/CHANGELOG.md \ No newline at end of file diff --git a/src/WireMock.Net.FluentAssertions/Assertions/WireMockAssertions.cs b/src/WireMock.Net.FluentAssertions/Assertions/WireMockAssertions.cs index 027bd35d..bd6e9aa9 100644 --- a/src/WireMock.Net.FluentAssertions/Assertions/WireMockAssertions.cs +++ b/src/WireMock.Net.FluentAssertions/Assertions/WireMockAssertions.cs @@ -36,7 +36,7 @@ namespace WireMock.FluentAssertions [CustomAssertion] public AndConstraint WithHeader(string expectedKey, string value, string because = "", params object[] becauseArgs) - => WithHeader(expectedKey, new[] {value}, because, becauseArgs); + => WithHeader(expectedKey, new[] { value }, because, becauseArgs); [CustomAssertion] public AndConstraint WithHeader(string expectedKey, string[] expectedValues, string because = "", params object[] becauseArgs) @@ -69,7 +69,7 @@ namespace WireMock.FluentAssertions return new AndConstraint(this); } - + [CustomAssertion] public AndConstraint AtUrl(string url, string because = "", params object[] becauseArgs) { @@ -85,10 +85,10 @@ namespace WireMock.FluentAssertions .FailWith( "Expected {context:wiremockserver} to have been called at address matching the url {0}{reason}, but didn't find it among the calls to {1}.", _ => url, requests => requests.Select(request => request.Url)); - + return new AndConstraint(this); } - + [CustomAssertion] public AndConstraint WithProxyUrl(string proxyUrl, string because = "", params object[] becauseArgs) { @@ -104,10 +104,10 @@ namespace WireMock.FluentAssertions .FailWith( "Expected {context:wiremockserver} to have been called with proxy url {0}{reason}, but didn't find it among the calls with {1}.", _ => proxyUrl, requests => requests.Select(request => request.ProxyUrl)); - + return new AndConstraint(this); } - + [CustomAssertion] public AndConstraint FromClientIP(string clientIP, string because = "", params object[] becauseArgs) { @@ -123,7 +123,7 @@ namespace WireMock.FluentAssertions .FailWith( "Expected {context:wiremockserver} to have been called from client IP {0}{reason}, but didn't find it among the calls from IP(s) {1}.", _ => clientIP, requests => requests.Select(request => request.ClientIP)); - + return new AndConstraint(this); } } diff --git a/src/WireMock.Net.FluentAssertions/Assertions/WireMockReceivedAssertions.cs b/src/WireMock.Net.FluentAssertions/Assertions/WireMockReceivedAssertions.cs index 0eba33b7..39b7a734 100644 --- a/src/WireMock.Net.FluentAssertions/Assertions/WireMockReceivedAssertions.cs +++ b/src/WireMock.Net.FluentAssertions/Assertions/WireMockReceivedAssertions.cs @@ -4,23 +4,39 @@ using WireMock.Server; // ReSharper disable once CheckNamespace namespace WireMock.FluentAssertions { + /// + /// Contains a number of methods to assert that the is in the expected state. + /// public class WireMockReceivedAssertions : ReferenceTypeAssertions { - public WireMockReceivedAssertions(IWireMockServer server) + /// + /// Create a WireMockReceivedAssertions. + /// + /// The . + public WireMockReceivedAssertions(IWireMockServer server) : base(server) { - Subject = server; } - + + /// + /// Asserts if has received a call. + /// + /// public WireMockAssertions HaveReceivedACall() { return new WireMockAssertions(Subject, null); } - + + /// + /// Asserts if has received n-calls. + /// + /// + /// public WireMockANumberOfCallsAssertions HaveReceived(int callsCount) { return new WireMockANumberOfCallsAssertions(Subject, callsCount); } + /// protected override string Identifier => "wiremockserver"; } } \ No newline at end of file diff --git a/src/WireMock.Net.FluentAssertions/WireMock.Net.FluentAssertions.csproj b/src/WireMock.Net.FluentAssertions/WireMock.Net.FluentAssertions.csproj index 08b9e4b2..92b1da83 100644 --- a/src/WireMock.Net.FluentAssertions/WireMock.Net.FluentAssertions.csproj +++ b/src/WireMock.Net.FluentAssertions/WireMock.Net.FluentAssertions.csproj @@ -1,4 +1,4 @@ - + FluentAssertions extensions for WireMock.Net @@ -29,13 +29,20 @@ - + + + + + + + + - + \ No newline at end of file diff --git a/test/WireMock.Net.Tests/FluentAssertions/WireMockAssertionsTests.cs b/test/WireMock.Net.Tests/FluentAssertions/WireMockAssertionsTests.cs index 58374707..b56c85cb 100644 --- a/test/WireMock.Net.Tests/FluentAssertions/WireMockAssertionsTests.cs +++ b/test/WireMock.Net.Tests/FluentAssertions/WireMockAssertionsTests.cs @@ -1,15 +1,15 @@ -using FluentAssertions; using System; using System.Linq; using System.Net.Http; using System.Net.Http.Headers; +using System.Threading.Tasks; +using FluentAssertions; +using WireMock.FluentAssertions; using WireMock.RequestBuilders; using WireMock.ResponseBuilders; using WireMock.Server; -using Xunit; -using WireMock.FluentAssertions; -using System.Threading.Tasks; using WireMock.Settings; +using Xunit; using static System.Environment; namespace WireMock.Net.Tests.FluentAssertions @@ -100,16 +100,9 @@ namespace WireMock.Net.Tests.FluentAssertions .HaveReceivedACall() .WithHeader("Authorization", "value"); - var sentHeaders = _server.LogEntries.SelectMany(x => x.RequestMessage.Headers) - .ToDictionary(x => x.Key, x => x.Value) - .ToList(); - - var sentHeaderString = "{" + string.Join(", ", sentHeaders) + "}"; - act.Should().Throw() .And.Message.Should() - .Be( - $"Expected headers from requests sent {sentHeaderString} to contain key \"Authorization\".{NewLine}"); + .Contain("to contain key \"Authorization\"."); } [Fact] @@ -156,7 +149,7 @@ namespace WireMock.Net.Tests.FluentAssertions .And.Message.Should() .Be($"{string.Join(NewLine, missingValue1Message, missingValue2Message)}{NewLine}"); } - + [Fact] public async Task AtUrl_WhenACallWasMadeToUrl_Should_BeOK() { @@ -200,7 +193,7 @@ namespace WireMock.Net.Tests.FluentAssertions { _server.ResetMappings(); _server.Given(Request.Create().UsingAnyMethod()) - .RespondWith(Response.Create().WithProxy(new ProxyAndRecordSettings {Url = "http://localhost:9999"})); + .RespondWith(Response.Create().WithProxy(new ProxyAndRecordSettings { Url = "http://localhost:9999" })); await _httpClient.GetAsync(""); @@ -214,8 +207,8 @@ namespace WireMock.Net.Tests.FluentAssertions { _server.ResetMappings(); _server.Given(Request.Create().UsingAnyMethod()) - .RespondWith(Response.Create().WithProxy(new ProxyAndRecordSettings {Url = "http://localhost:9999"})); - + .RespondWith(Response.Create().WithProxy(new ProxyAndRecordSettings { Url = "http://localhost:9999" })); + Action act = () => _server.Should() .HaveReceivedACall() .WithProxyUrl("anyurl"); @@ -231,8 +224,8 @@ namespace WireMock.Net.Tests.FluentAssertions { _server.ResetMappings(); _server.Given(Request.Create().UsingAnyMethod()) - .RespondWith(Response.Create().WithProxy(new ProxyAndRecordSettings {Url = "http://localhost:9999"})); - + .RespondWith(Response.Create().WithProxy(new ProxyAndRecordSettings { Url = "http://localhost:9999" })); + await _httpClient.GetAsync(""); Action act = () => _server.Should() @@ -244,7 +237,7 @@ namespace WireMock.Net.Tests.FluentAssertions .Be( $"Expected _server to have been called with proxy url \"anyurl\", but didn't find it among the calls with {{\"http://localhost:9999\"}}."); } - + [Fact] public async Task FromClientIP_whenACallWasMadeFromClientIP_Should_BeOK() { diff --git a/test/WireMock.Net.Tests/ResponseBuilders/ResponseWithCallbackTests.cs b/test/WireMock.Net.Tests/ResponseBuilders/ResponseWithCallbackTests.cs index 00ad8931..7c50ad75 100644 --- a/test/WireMock.Net.Tests/ResponseBuilders/ResponseWithCallbackTests.cs +++ b/test/WireMock.Net.Tests/ResponseBuilders/ResponseWithCallbackTests.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using System.Net; using System.Threading.Tasks; using FluentAssertions; @@ -139,7 +139,7 @@ namespace WireMock.Net.Tests.ResponseBuilders // Assert response.Message.BodyData.BodyAsString.Should().Be("/fooBar"); - response.Message.StatusCode.Should().Be(HttpStatusCode.Accepted); + response.Message.StatusCode.Should().Be((int) HttpStatusCode.Accepted); response.Message.Headers[header].Should().ContainSingle("Stef"); } diff --git a/test/WireMock.Net.Tests/ResponseBuilders/ResponseWithHandlebarsLinqTests.cs b/test/WireMock.Net.Tests/ResponseBuilders/ResponseWithHandlebarsLinqTests.cs index 6fc457a5..2ce7c1db 100644 --- a/test/WireMock.Net.Tests/ResponseBuilders/ResponseWithHandlebarsLinqTests.cs +++ b/test/WireMock.Net.Tests/ResponseBuilders/ResponseWithHandlebarsLinqTests.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Threading.Tasks; using FluentAssertions; using HandlebarsDotNet; @@ -216,7 +216,7 @@ namespace WireMock.Net.Tests.ResponseBuilders Func a = async () => await responseBuilder.ProvideResponseAsync(request, _settings); // Assert - a.Should().Throw(); + a.Should().ThrowAsync(); } [Fact] @@ -243,7 +243,7 @@ namespace WireMock.Net.Tests.ResponseBuilders Func a = async () => await responseBuilder.ProvideResponseAsync(request, _settings); // Assert - a.Should().Throw(); + a.Should().ThrowAsync(); } } } \ No newline at end of file diff --git a/test/WireMock.Net.Tests/WireMock.Net.Tests.csproj b/test/WireMock.Net.Tests/WireMock.Net.Tests.csproj index 031b6660..2b50f371 100644 --- a/test/WireMock.Net.Tests/WireMock.Net.Tests.csproj +++ b/test/WireMock.Net.Tests/WireMock.Net.Tests.csproj @@ -1,105 +1,109 @@ - - Stef Heyenrath - net452;net461;netcoreapp3.1;net5.0 - false - full - WireMock.Net.Tests - WireMock.Net.Tests - true - {31DC2EF8-C3FE-467D-84BE-FB5D956E612E} + + Stef Heyenrath + net452;net461;netcoreapp3.1;net5.0 + false + full + WireMock.Net.Tests + WireMock.Net.Tests + true + {31DC2EF8-C3FE-467D-84BE-FB5D956E612E} - - true - ../../src/WireMock.Net/WireMock.Net.snk - - true + true + ../../src/WireMock.Net/WireMock.Net.snk + + true - - true - true - + + true + true + - - - - - - - + + + + + + + - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + - - - - - - - - - - - - - - + + + + + + + + + + + + + - - - - + + + + + - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - + + + - - - + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + + + + \ No newline at end of file diff --git a/test/WireMock.Net.Tests/WireMockServer.Proxy.cs b/test/WireMock.Net.Tests/WireMockServer.Proxy.cs index d1d1a8f2..a6617b14 100644 --- a/test/WireMock.Net.Tests/WireMockServer.Proxy.cs +++ b/test/WireMock.Net.Tests/WireMockServer.Proxy.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Linq; using System.Net; using System.Net.Http; @@ -691,7 +691,7 @@ namespace WireMock.Net.Tests var result = await new HttpClient(httpClientHandler).SendAsync(requestMessage); // Assert - result.StatusCode.Should().Be(500); + result.StatusCode.Should().Be(HttpStatusCode.InternalServerError); var content = await result.Content.ReadAsStringAsync(); content.Should().NotBeEmpty(); diff --git a/test/WireMock.Net.Tests/WireMockServerTests.WithCallback.cs b/test/WireMock.Net.Tests/WireMockServerTests.WithCallback.cs index a0b7b1fb..030a4304 100644 --- a/test/WireMock.Net.Tests/WireMockServerTests.WithCallback.cs +++ b/test/WireMock.Net.Tests/WireMockServerTests.WithCallback.cs @@ -1,4 +1,4 @@ -using System.Net; +using System.Net; using System.Net.Http; using System.Threading.Tasks; using FluentAssertions; @@ -31,7 +31,7 @@ namespace WireMock.Net.Tests var response = await httpClient.PostAsync("http://localhost:" + server.Ports[0] + "/foo", new StringContent("dummy")); // Assert - response.StatusCode.Should().Be(409); + response.StatusCode.Should().Be(HttpStatusCode.Conflict); server.Stop(); }