WireMock.Net.FluentAssertions : upgrade to latest FluentAssertions (#635)

* .

* #634

* fix UT
This commit is contained in:
Stef Heyenrath
2021-09-27 21:03:54 +02:00
committed by GitHub
parent 772398bea1
commit 2ab075ee09
13 changed files with 160 additions and 142 deletions
+1 -3
View File
@@ -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)
+1 -1
View File
@@ -4,7 +4,7 @@
</PropertyGroup>
<PropertyGroup>
<VersionPrefix>1.4.22</VersionPrefix>
<VersionPrefix>1.4.23</VersionPrefix>
<PackageReleaseNotes>See CHANGELOG.md</PackageReleaseNotes>
<PackageIcon>WireMock.Net-Logo.png</PackageIcon>
<PackageProjectUrl>https://github.com/WireMock-Net/WireMock.Net</PackageProjectUrl>
+3 -3
View File
@@ -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%
GitHubReleaseNotes --output PackageReleaseNotes.txt --skip-empty-releases --exclude-labels question invalid doc duplicate --template PackageReleaseNotes.template --version %version% --token %GH_TOKEN%
+2 -2
View File
@@ -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
@@ -36,7 +36,7 @@ namespace WireMock.FluentAssertions
[CustomAssertion]
public AndConstraint<WireMockAssertions> 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<WireMockAssertions> WithHeader(string expectedKey, string[] expectedValues, string because = "", params object[] becauseArgs)
@@ -4,23 +4,39 @@ using WireMock.Server;
// ReSharper disable once CheckNamespace
namespace WireMock.FluentAssertions
{
/// <summary>
/// Contains a number of methods to assert that the <see cref="IWireMockServer"/> is in the expected state.
/// </summary>
public class WireMockReceivedAssertions : ReferenceTypeAssertions<IWireMockServer, WireMockReceivedAssertions>
{
public WireMockReceivedAssertions(IWireMockServer server)
/// <summary>
/// Create a WireMockReceivedAssertions.
/// </summary>
/// <param name="server">The <see cref="IWireMockServer"/>.</param>
public WireMockReceivedAssertions(IWireMockServer server) : base(server)
{
Subject = server;
}
/// <summary>
/// Asserts if <see cref="IWireMockServer"/> has received a call.
/// </summary>
/// <returns><see cref="WireMockAssertions"/></returns>
public WireMockAssertions HaveReceivedACall()
{
return new WireMockAssertions(Subject, null);
}
/// <summary>
/// Asserts if <see cref="IWireMockServer"/> has received n-calls.
/// </summary>
/// <param name="callsCount"></param>
/// <returns><see cref="WireMockAssertions"/></returns>
public WireMockANumberOfCallsAssertions HaveReceived(int callsCount)
{
return new WireMockANumberOfCallsAssertions(Subject, callsCount);
}
/// <inheritdoc/>
protected override string Identifier => "wiremockserver";
}
}
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Description>FluentAssertions extensions for WireMock.Net</Description>
@@ -29,11 +29,18 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="FluentAssertions" Version="5.10.3" />
<PackageReference Include="JetBrains.Annotations" Version="2020.1.0" PrivateAssets="All" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net451' or '$(TargetFramework)' == 'netstandard1.3'">
<PackageReference Include="FluentAssertions" Version="5.10.3" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' != 'net451' and '$(TargetFramework)' != 'netstandard1.3'">
<PackageReference Include="FluentAssertions" Version="6.1.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\WireMock.Net.Abstractions\WireMock.Net.Abstractions.csproj" />
</ItemGroup>
@@ -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<Exception>()
.And.Message.Should()
.Be(
$"Expected headers from requests sent {sentHeaderString} to contain key \"Authorization\".{NewLine}");
.Contain("to contain key \"Authorization\".");
}
[Fact]
@@ -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,7 +207,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" }));
Action act = () => _server.Should()
.HaveReceivedACall()
@@ -231,7 +224,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("");
@@ -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");
}
@@ -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<Task> a = async () => await responseBuilder.ProvideResponseAsync(request, _settings);
// Assert
a.Should().Throw<HandlebarsException>();
a.Should().ThrowAsync<HandlebarsException>();
}
[Fact]
@@ -243,7 +243,7 @@ namespace WireMock.Net.Tests.ResponseBuilders
Func<Task> a = async () => await responseBuilder.ProvideResponseAsync(request, _settings);
// Assert
a.Should().Throw<HandlebarsException>();
a.Should().ThrowAsync<HandlebarsException>();
}
}
}
@@ -48,7 +48,6 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="FluentAssertions" Version="5.10.3" />
<PackageReference Include="Moq" Version="4.16.0" />
<PackageReference Include="System.Threading" Version="4.3.0" />
<PackageReference Include="RestEase" Version="1.5.5" />
@@ -63,9 +62,14 @@
<!--<PackageReference Include="StrongNamer" Version="0.0.8" />-->
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net452'">
<ItemGroup Condition="'$(TargetFramework)' == 'net452' or '$(TargetFramework)' == 'net461'">
<PackageReference Include="Microsoft.Owin.Host.HttpListener" Version="3.1.0" />
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
<PackageReference Include="FluentAssertions" Version="5.10.3" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' != 'net452' and '$(TargetFramework)' != 'net461'">
<PackageReference Include="FluentAssertions" Version="6.1.0" />
</ItemGroup>
<ItemGroup>
@@ -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();
@@ -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();
}