Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions Mockly.Specs/HttpMockSpecs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,45 @@ public async Task The_query_does_not_require_a_question_mark()
response.StatusCode.Should().Be(HttpStatusCode.OK);
}

[Fact]
public async Task Can_match_path_with_pipe_character()
{
// Arrange
var mock = new HttpMock();
var key = $"{Guid.NewGuid()}|{Guid.NewGuid()}";

mock.ForDelete()
.WithPath($"IncomeRelations/{key}")
.RespondsWithStatus(HttpStatusCode.OK);

// Act
var client = mock.GetClient();
var response = await client.DeleteAsync($"https://localhost/IncomeRelations/{key}");

// Assert
response.StatusCode.Should().Be(HttpStatusCode.OK);
}

[Fact]
public async Task Can_match_query_with_pipe_character()
{
// Arrange
var mock = new HttpMock();
var filter = "status=active|pending";

mock.ForGet()
.WithPath("api/items")
.WithQuery($"filter={filter}")
.RespondsWithStatus(HttpStatusCode.OK);

// Act
var client = mock.GetClient();
var response = await client.GetAsync($"https://localhost/api/items?filter={filter}");

// Assert
response.StatusCode.Should().Be(HttpStatusCode.OK);
}

[Fact]
public async Task Can_mock_get_request_with_json_response()
{
Expand Down
2 changes: 1 addition & 1 deletion Mockly/RequestMock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public async Task<bool> Matches(RequestInfo request)
// Check path pattern if specified
if (PathPattern != null)
{
var path = request.Uri?.AbsolutePath ?? string.Empty;
var path = WebUtility.UrlDecode(request.Uri?.AbsolutePath ?? string.Empty);
if (!MatchesPattern(path.TrimStart('/'), PathPattern.TrimStart('/')))
{
return false;
Expand Down