Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

StatusCode not built correctly when loaded from mapping file. #400

Closed
FrostyZoob opened this issue Jan 9, 2020 · 2 comments
Closed

StatusCode not built correctly when loaded from mapping file. #400

FrostyZoob opened this issue Jan 9, 2020 · 2 comments
Labels

Comments

@FrostyZoob
Copy link

FrostyZoob commented Jan 9, 2020

Scenario:
Using WireMock.Net v1.1.0.0

All requests that match the attached mapping (Returns500Response.txt) get a response whose StatusCode is 200.

Expectation:
The response should have the StatusCode that is specified in the mapping file. (500)

Analysis:
The problem appears to be here: (WireMockServer.Admin.cs, line 811)

switch (responseModel.StatusCode)
{
    case int statusCodeAsInteger:
        responseBuilder = responseBuilder.WithStatusCode(statusCodeAsInteger);
        break;

    case string statusCodeAsString:
        responseBuilder = responseBuilder.WithStatusCode(statusCodeAsString);
        break;
}

When stepping through the code, responseModel.StatusCode is 500. (Which is correct.) However, according to the debugger it has been deserialized as a long. Because of that, it skips over the switch statement entirely and responseBuilder.ResponseMessage.StatusCode ends up being set to 200.

@FrostyZoob FrostyZoob changed the title Bug: StatusCode not built correctly when loaded from mapping file. StatusCode not built correctly when loaded from mapping file. Jan 9, 2020
@StefH StefH added the bug label Jan 9, 2020
@StefH
Copy link
Collaborator

StefH commented Jan 9, 2020

Thanks a lot for finding this issue!

@StefH
Copy link
Collaborator

StefH commented Jan 9, 2020

PR was already created, merged to master.

@StefH StefH closed this as completed Jan 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants