Skip to content

v1.5.33 Returns always StatusCode 500 #988

@macalbert

Description

@macalbert

Describe the bug

Version 1.5.33 always returns StatusCode 500 ' Internal Server Error'.

Expected behaviour:

Should return the StatusCode provided in the ResponseBuilder.

Test to reproduce

using System.Net;
using System.Text;
using WireMock.RequestBuilders;
using WireMock.ResponseBuilders;
using WireMock.Server;

public class SomeApiClientTests
{
    [Fact]
    public async Task Should_ReturnCreated_When_PostRequestedIsValid()
    {
        // Arrange        
        var server = WireMockServer.Start();
        server.Given(Request.Create().UsingPost().WithPath("/some/endpoint"))
              .RespondWith(Response.Create().WithStatusCode(HttpStatusCode.Created));
        var httpClient = new HttpClient { BaseAddress = new Uri(server.Url!) };
        var requestUri = new Uri(httpClient.BaseAddress!, "some/endpoint");
        var content = new StringContent(string.Empty, Encoding.UTF8, "application/json");

        // Act
        var actual = await httpClient.PostAsync(requestUri, content);

        // Assert
        actual.StatusCode.Should().Be(HttpStatusCode.Created);
    }
}

Other related info

Ran under .Net 7 with Microsoft Visual Studio Community 2022 (64-bit) -Version 17.6.5

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    pFad - Phonifier reborn

    Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

    Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


    Alternative Proxies:

    Alternative Proxy

    pFad Proxy

    pFad v3 Proxy

    pFad v4 Proxy