From 447342ba30801e40faf9ef7b9cf3dedb4cadf5f7 Mon Sep 17 00:00:00 2001 From: Timothy Makkison Date: Tue, 15 Oct 2024 22:20:30 +0100 Subject: [PATCH] feat: added derived type argument tests --- Refit.Tests/RestService.cs | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/Refit.Tests/RestService.cs b/Refit.Tests/RestService.cs index 1b94c915e..cf940c7ad 100644 --- a/Refit.Tests/RestService.cs +++ b/Refit.Tests/RestService.cs @@ -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("SomeProperty3", "test"), + new KeyValuePair("SomeProperty2", "barNone"), + new KeyValuePair("SomeProperty", "1") + } + ) + .Respond("application/json", "Ok"); + + var settings = new RefitSettings { HttpMessageHandlerFactory = () => mockHttp }; + var fixture = RestService.For("http://foo", settings); + + await fixture.GetBarsByFoo( + new PathBoundDerivedObject() + { + SomeProperty = 1, + SomeProperty2 = "barNone", + SomeProperty3 = "test" + } + ); + mockHttp.VerifyNoOutstandingExpectation(); + } + [Fact] public async Task GetWithPathBoundObjectAndQueryParameter() {