Skip to content

Commit

Permalink
feat: added derived type argument tests (#1883)
Browse files Browse the repository at this point in the history
  • Loading branch information
TimothyMakkison authored Oct 16, 2024
1 parent 5df30d9 commit b32c305
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions Refit.Tests/RestService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,37 @@ await fixture.GetFooBarsDerived(
mockHttp.VerifyNoOutstandingExpectation();
}

[Fact]
public async Task GetWithDerivedObjectAsBaseType()
{
// possibly a bug see https://github.com/reactiveui/refit/issues/1882
var mockHttp = new MockHttpMessageHandler();
mockHttp
.Expect(HttpMethod.Get, "http://foo/foos/1/bar")
.WithExactQueryString(
new[]
{
new KeyValuePair<string, string>("SomeProperty3", "test"),
new KeyValuePair<string, string>("SomeProperty2", "barNone"),
new KeyValuePair<string, string>("SomeProperty", "1")
}
)
.Respond("application/json", "Ok");

var settings = new RefitSettings { HttpMessageHandlerFactory = () => mockHttp };
var fixture = RestService.For<IApiBindPathToObject>("http://foo", settings);

await fixture.GetBarsByFoo(
new PathBoundDerivedObject()
{
SomeProperty = 1,
SomeProperty2 = "barNone",
SomeProperty3 = "test"
}
);
mockHttp.VerifyNoOutstandingExpectation();
}

[Fact]
public async Task GetWithPathBoundObjectAndQueryParameter()
{
Expand Down

0 comments on commit b32c305

Please sign in to comment.