test: add TestableApiClient helper for ApiClientBase unit tests
This commit is contained in:
@@ -0,0 +1,30 @@
|
|||||||
|
using JdeScoping.Client.Services;
|
||||||
|
using JdeScoping.Core.ApiContracts.Results;
|
||||||
|
|
||||||
|
namespace JdeScoping.Client.Tests.Services;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Test wrapper to expose protected ApiClientBase methods for unit testing.
|
||||||
|
/// </summary>
|
||||||
|
public class TestableApiClient : ApiClientBase
|
||||||
|
{
|
||||||
|
public TestableApiClient(HttpClient httpClient) : base(httpClient) { }
|
||||||
|
|
||||||
|
public new Task<ApiResult<T>> GetAsync<T>(string route, CancellationToken ct = default)
|
||||||
|
=> base.GetAsync<T>(route, ct);
|
||||||
|
|
||||||
|
public new Task<ApiResult<T>> PostAsync<T, TBody>(string route, TBody body, CancellationToken ct = default)
|
||||||
|
=> base.PostAsync<T, TBody>(route, body, ct);
|
||||||
|
|
||||||
|
public new Task<ApiResult<T>> PostAsync<T>(string route, CancellationToken ct = default)
|
||||||
|
=> base.PostAsync<T>(route, ct);
|
||||||
|
|
||||||
|
public new Task<ApiResult<byte[]>> GetBytesAsync(string route, CancellationToken ct = default)
|
||||||
|
=> base.GetBytesAsync(route, ct);
|
||||||
|
|
||||||
|
public new Task<ApiResult<byte[]>> PostForBytesAsync<TBody>(string route, TBody body, CancellationToken ct = default)
|
||||||
|
=> base.PostForBytesAsync<TBody>(route, body, ct);
|
||||||
|
|
||||||
|
public new Task<ApiResult<T>> PostMultipartAsync<T>(string route, Stream fileStream, string fileName, CancellationToken ct = default)
|
||||||
|
=> base.PostMultipartAsync<T>(route, fileStream, fileName, ct);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user