Skip to content

[Feature]: HttpClient Mock - Add / at the beginning if not given for partial endpoints #5838

@AdrianoAE

Description

@AdrianoAE

Problem Statement

var httpClientFactory = IHttpClientFactory.Mock(MockBehavior.Strict);
var httpClient = Mock.HttpClient("https://my.domain/");
httpClientFactory.CreateClient("myClient").Returns(httpClient);

// This will not match, it requires the `/` in front
httpClient.Handler.OnPost("my_endpoint").Respond(HttpStatusCode.Accepted);

// This works
httpClient.Handler.OnPost("/my_endpoint").Respond(HttpStatusCode.Accepted);

Proposed Solution

It's easy to miss and be overlooked when trying to figure out the problem, so my input is to by default check if the / is there, if not, simply add it internally

Feature Category

Test Mocking

How important is this feature to you?

QOL

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions