Skip to content

Commit

Permalink
Pass parameters to GetEndpointFullPath (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
ligowsky authored May 1, 2024
1 parent adb9c7c commit d0a129d
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/BitzArt.Flux.REST/Models/FluxRestSetContext{TModel}.cs
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ protected string GetPageEndpoint()
protected virtual RequestUrlParameterParsingResult GetEndpointFullPath(params object[]? parameters)
{
var endpoint = GetEndpoint();
return GetFullPath(endpoint, true);
return GetFullPath(endpoint, true, parameters);
}

protected string GetEndpoint()
Expand Down
24 changes: 24 additions & 0 deletions tests/BitzArt.Flux.REST.Tests/MockedRestServiceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,30 @@ public async Task GetAllAsync_MockedHttpClient_ReturnsAll(int setCount)
Assert.True(result.Count() == setCount);
}

[Fact]
public async Task GetAllAsync_WithQuery_ReturnsAll()
{
var baseUrl = "https://mocked.service";
var query = "?sort=id";
var setCount = 10;

var setContext = TestSetContext.GetTestSetContext(baseUrl, x =>
{
x.When($"{baseUrl.TrimEnd('/')}/model{query}")
.Respond(HttpStatusCode.OK,
JsonContent.Create(TestModel.GetAll(setCount)));
});

((FluxRestSetContext<TestModel>)setContext)
.SetOptions.Endpoint = "model{query}";

var result = await setContext.GetAllAsync(query);

Assert.NotNull(result);
if (setCount > 0) Assert.True(result.Any());
Assert.True(result.Count() == setCount);
}

[Theory]
[InlineData(0, 0, 0)]
[InlineData(0, 0, 10)]
Expand Down

0 comments on commit d0a129d

Please sign in to comment.