You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
Currently the FluentAssertion extensions offer a pretty small feature set, which would not be a problem by itself, but the fact that they are not very open for extension makes this really problematic.
Describe the solution you'd like
I would like to for example access all the filtered requests on the WireMockAssertions object. That way I could write my own extension methods for it to for example assert that a request was using a specific path (currently only Url & AbsoluteUrl exist).
Describe alternatives you've considered
As far as I can tell the only alternative is using reflection to access the private members of WireMockAssertions.
The text was updated successfully, but these errors were encountered:
@chrischu
I've updated the code for WireMockAssertions so that you now can create an extension method like:
usingSystem;usingSystem.Linq;usingFluentAssertions;usingFluentAssertions.Execution;usingWireMock.FluentAssertions;namespaceWireMock.Net.Tests.FluentAssertions;publicstaticclassWireMockAssertionsExtensions{[CustomAssertion]publicstaticAndWhichConstraint<WireMockAssertions,string>AtAbsoluteUrl2(thisWireMockAssertionsassertions,stringabsoluteUrl,stringbecause="",paramsobject[]becauseArgs){var(filter,condition)=assertions.BuildFilterAndCondition(request =>string.Equals(request.AbsoluteUrl,absoluteUrl,StringComparison.OrdinalIgnoreCase));Execute.Assertion.BecauseOf(because,becauseArgs).Given(()=>assertions.RequestMessages).ForCondition(requests =>assertions.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));assertions.FilterRequestMessages(filter);returnnewAndWhichConstraint<WireMockAssertions,string>(assertions,absoluteUrl);}}
Note that the RequestMessages, BuildFilterAndCondition and FilterRequestMessages are made public so these can be used in the extension methods.
Would this fix your issue?
And if you have any useful default fliuent extensions, you can also add these to this project using a PR.
Is your feature request related to a problem? Please describe.
Currently the FluentAssertion extensions offer a pretty small feature set, which would not be a problem by itself, but the fact that they are not very open for extension makes this really problematic.
Describe the solution you'd like
I would like to for example access all the filtered requests on the
WireMockAssertions
object. That way I could write my own extension methods for it to for example assert that a request was using a specific path (currently only Url & AbsoluteUrl exist).Describe alternatives you've considered
As far as I can tell the only alternative is using reflection to access the private members of
WireMockAssertions
.The text was updated successfully, but these errors were encountered: