-
-
Notifications
You must be signed in to change notification settings - Fork 213
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
215 additions
and
140 deletions.
There are no files selected for viewing
60 changes: 60 additions & 0 deletions
60
src/WireMock.Net.FluentAssertions/Assertions/WireMockAssertions.AtUrl.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
#pragma warning disable CS1591 | ||
using System; | ||
|
||
// ReSharper disable once CheckNamespace | ||
namespace WireMock.FluentAssertions; | ||
|
||
public partial class WireMockAssertions | ||
{ | ||
[CustomAssertion] | ||
public AndWhichConstraint<WireMockAssertions, string> AtAbsoluteUrl(string absoluteUrl, string because = "", params object[] becauseArgs) | ||
{ | ||
var (filter, condition) = BuildFilterAndCondition(request => string.Equals(request.AbsoluteUrl, absoluteUrl, StringComparison.OrdinalIgnoreCase)); | ||
|
||
Execute.Assertion | ||
.BecauseOf(because, becauseArgs) | ||
.Given(() => RequestMessages) | ||
.ForCondition(requests => CallsCount == 0 || requests.Any()) | ||
.FailWith( | ||
"Expected {context:wiremockserver} to have been called at address matching the absolute url {0}{reason}, but no calls were made.", | ||
absoluteUrl | ||
) | ||
.Then | ||
.ForCondition(condition) | ||
.FailWith( | ||
"Expected {context:wiremockserver} to have been called at address matching the absolute url {0}{reason}, but didn't find it among the calls to {1}.", | ||
_ => absoluteUrl, | ||
requests => requests.Select(request => request.AbsoluteUrl) | ||
); | ||
|
||
FilterRequestMessages(filter); | ||
|
||
return new AndWhichConstraint<WireMockAssertions, string>(this, absoluteUrl); | ||
} | ||
|
||
[CustomAssertion] | ||
public AndWhichConstraint<WireMockAssertions, string> AtUrl(string url, string because = "", params object[] becauseArgs) | ||
{ | ||
var (filter, condition) = BuildFilterAndCondition(request => string.Equals(request.Url, url, StringComparison.OrdinalIgnoreCase)); | ||
|
||
Execute.Assertion | ||
.BecauseOf(because, becauseArgs) | ||
.Given(() => RequestMessages) | ||
.ForCondition(requests => CallsCount == 0 || requests.Any()) | ||
.FailWith( | ||
"Expected {context:wiremockserver} to have been called at address matching the url {0}{reason}, but no calls were made.", | ||
url | ||
) | ||
.Then | ||
.ForCondition(condition) | ||
.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) | ||
); | ||
|
||
FilterRequestMessages(filter); | ||
|
||
return new AndWhichConstraint<WireMockAssertions, string>(this, url); | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
src/WireMock.Net.FluentAssertions/Assertions/WireMockAssertions.FromClientIP.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#pragma warning disable CS1591 | ||
using System; | ||
|
||
// ReSharper disable once CheckNamespace | ||
namespace WireMock.FluentAssertions; | ||
|
||
public partial class WireMockAssertions | ||
{ | ||
[CustomAssertion] | ||
public AndWhichConstraint<WireMockAssertions, string> FromClientIP(string clientIP, string because = "", params object[] becauseArgs) | ||
{ | ||
var (filter, condition) = BuildFilterAndCondition(request => string.Equals(request.ClientIP, clientIP, StringComparison.OrdinalIgnoreCase)); | ||
|
||
Execute.Assertion | ||
.BecauseOf(because, becauseArgs) | ||
.Given(() => RequestMessages) | ||
.ForCondition(requests => CallsCount == 0 || requests.Any()) | ||
.FailWith( | ||
"Expected {context:wiremockserver} to have been called from client IP {0}{reason}, but no calls were made.", | ||
clientIP | ||
) | ||
.Then | ||
.ForCondition(condition) | ||
.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) | ||
); | ||
|
||
FilterRequestMessages(filter); | ||
|
||
return new AndWhichConstraint<WireMockAssertions, string>(this, clientIP); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
src/WireMock.Net.FluentAssertions/Assertions/WireMockAssertions.WithProxy.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#pragma warning disable CS1591 | ||
using System; | ||
|
||
// ReSharper disable once CheckNamespace | ||
namespace WireMock.FluentAssertions; | ||
|
||
public partial class WireMockAssertions | ||
{ | ||
[CustomAssertion] | ||
public AndWhichConstraint<WireMockAssertions, string> WithProxyUrl(string proxyUrl, string because = "", params object[] becauseArgs) | ||
{ | ||
var (filter, condition) = BuildFilterAndCondition(request => string.Equals(request.ProxyUrl, proxyUrl, StringComparison.OrdinalIgnoreCase)); | ||
|
||
Execute.Assertion | ||
.BecauseOf(because, becauseArgs) | ||
.Given(() => RequestMessages) | ||
.ForCondition(requests => CallsCount == 0 || requests.Any()) | ||
.FailWith( | ||
"Expected {context:wiremockserver} to have been called with proxy url {0}{reason}, but no calls were made.", | ||
proxyUrl | ||
) | ||
.Then | ||
.ForCondition(condition) | ||
.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) | ||
); | ||
|
||
FilterRequestMessages(filter); | ||
|
||
return new AndWhichConstraint<WireMockAssertions, string>(this, proxyUrl); | ||
} | ||
} |
Oops, something went wrong.