mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-01-11 21:10:32 +01:00
Stubbed response with only callback returns unexpected status code. #311
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 @rudi-brunner on GitHub (Nov 6, 2020).
Describe the bug
When setting up a stubbed response with only a callback I would expect that the status code which I set on the returned
ResponseMessagewould be the status code which the request will receive. But you always getHttpStatusCode.OKanyway.Expected behavior:
If I only specify
.WithCallback()and not.WithStatusCode()I would expect that the status code of the returnedResponseMessageobject is returned.Test to reproduce
This test is currently failing with WireMock.Net 1.3.5
It fails with:
Other related info
I checked in the debugger that the callback was triggered. It was triggered.
@StefH commented on GitHub (Nov 6, 2020):
Hello @rudi-brunner, thank you for finding this bug. I'll take a look.
@StefH commented on GitHub (Nov 6, 2020):
The issue is that you use an Enum, if you use
new ResponseMessage {StatusCode = (int) HttpStatusCode.Conflict}));it should work.However, I'll make a fix in the code.
@StefH commented on GitHub (Nov 6, 2020):
@rudi-brunner can you try preview version
WireMock.Net.1.3.5-ci-13952.nupkg(from MyGet)?@rudi-brunner commented on GitHub (Nov 6, 2020):
Thanks for the quick response :)
I'm not familiar with MyGet. Is it myget.org? Created an account now. But how do I access your feed? Any URL I can use?
@StefH commented on GitHub (Nov 6, 2020):
See https://github.com/WireMock-Net/WireMock.Net/wiki/MyGet-preview-versions
@rudi-brunner commented on GitHub (Nov 6, 2020):
Works like a charm 🥇
Verified that it works both in the minimum test case which I posted here and in my full-blown test setup.
Good to go 👌