mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-01-11 22:30:41 +01:00
WithCallback circumvent the rest of the builder #329
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @rlf on GitHub (Jan 27, 2021).
Originally assigned to: @StefH on GitHub.
Describe the bug
The code-line listed here:
ebb9f128c5/src/WireMock.Net/ResponseBuilders/Response.cs (L374)Effectively disables part of the builder - which IMO ruins the builder-pattern for the response builder.
Expected behavior:
I would expect the following code:
to generate a responsemessage with what-ever the callback provides, but with the status-code
Createdand the additional headerX-UserId.Test to reproduce
Create any
Given().RespondWith()chain that mixes bothWithCallbackand other builder-inputs.Verify the Callback short-circuits anything else you put into the Builder-pattern.
I do get, how-ever, that if the callback changes the default value of say the Status - that status should prevail - but not if you specifically add a non-default status to your response, using the builder.
Other related info
None that I can think of.
@StefH commented on GitHub (Feb 1, 2021):
@rlf I understand your issue.
I cannot remember anymore why I decided that WithCallback does behave like this.
(Maybe I thought that you want to do all logic in the callback, so also defining the status-codes and headers)
However, I see that in that case the fluentbuilder should not return a chainable thing so that it seems that you can add more fluent methods.
I'll check if it's easy to change that all additional .WIth*** are used.
@StefH commented on GitHub (Feb 18, 2021):
Hello @rlf,
Can you please try preview NuGet
WireMock.Net.1.4.6-ci-14668from MyGet (https://github.com/WireMock-Net/WireMock.Net/wiki/MyGet-preview-versions)? This should fix your issue.@StefH commented on GitHub (Feb 22, 2021):
Dear @rlf ; did you have time to test this?
@rlf commented on GitHub (Feb 26, 2021):
Verified. At least the tests I wrote when discovering this bug is now green.
Thanks!
Awesome work man!
@StefH commented on GitHub (Feb 26, 2021):
@rlf Thank you for testing.
I'll release a new official version today.