Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
StefH committed Sep 27, 2021
1 parent 4453b22 commit 5fb1efa
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,39 @@
// 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";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<PackageReference Include="FluentAssertions" Version="5.10.3" />
</ItemGroup>

<ItemGroup Condition="('$(TargetFramework)' != 'net451' and '$(TargetFramework)' == 'netstandard1.3')">
<ItemGroup Condition="'$(TargetFramework)' != 'net451' and '$(TargetFramework)' != 'netstandard1.3'">
<PackageReference Include="FluentAssertions" Version="6.1.0" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Threading.Tasks;
using FluentAssertions;
using HandlebarsDotNet;
Expand Down Expand Up @@ -216,7 +216,7 @@ public void Response_ProvideResponse_Handlebars_Linq1_ParseError_Throws_Exceptio
Func<Task> a = async () => await responseBuilder.ProvideResponseAsync(request, _settings);

// Assert
a.Should().Throw<HandlebarsException>();
a.Should().ThrowAsync<HandlebarsException>();
}

[Fact]
Expand All @@ -243,7 +243,7 @@ public void Response_ProvideResponse_Handlebars_Linq2_ParseError_Throws_Exceptio
Func<Task> a = async () => await responseBuilder.ProvideResponseAsync(request, _settings);

// Assert
a.Should().Throw<HandlebarsException>();
a.Should().ThrowAsync<HandlebarsException>();
}
}
}
4 changes: 2 additions & 2 deletions test/WireMock.Net.Tests/WireMockServer.Proxy.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Linq;
using System.Net;
using System.Net.Http;
Expand Down Expand Up @@ -691,7 +691,7 @@ public async Task WireMockServer_Proxy_WhenTargetIsNotAvailable_Should_Return_Co
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();
Expand Down
4 changes: 2 additions & 2 deletions test/WireMock.Net.Tests/WireMockServerTests.WithCallback.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Net;
using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
using FluentAssertions;
Expand Down Expand Up @@ -31,7 +31,7 @@ public async Task WireMockServer_WithCallback_Should_Use_StatusCodeFromResponse(
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();
}
Expand Down

0 comments on commit 5fb1efa

Please sign in to comment.