You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...].
mocking the IDownstreamApi class in tests isn't trivial, the interface contains 36 methods (by creating a test class the implements this interface).
Describe the solution you'd like
To have a base abstract class DownstreamApiBase that implements the interface and exposes just a single method
internal/* for tests */asyncTask<HttpResponseMessage>CallApiInternalAsync(string?serviceName,DownstreamApiOptionseffectiveOptions,boolappToken,HttpContent?content=null,ClaimsPrincipal?user=null,CancellationTokencancellationToken=default){// Downstream API URIstringapiUrl=effectiveOptions.GetApiUrl();// Create an HTTP request messageusingHttpRequestMessagehttpRequestMessage=new(newHttpMethod(effectiveOptions.HttpMethod),apiUrl);if(content!=null){httpRequestMessage.Content=content;}// call the new protected APIreturnawaitCallApiInternalAsync(message,effectiveOptions,appToken,user,cancellationToken);
then the current DownstreamApi class would extend this abstract-class and override the CallApiInternalAsync method.
This would allow any HttpClient mocking library to easily be leveraged here since the new API would be close to the HttpClient.SendAsync API.
Describe alternatives you've considered
using the Moq library and mocking the interface IDownstreamApi - mocking the correct method is a bit of a nuisance since there are many similar API's.
Additional context
Add any other context or screenshots about the feature request here.
The text was updated successfully, but these errors were encountered:
Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...].
mocking the IDownstreamApi class in tests isn't trivial, the interface contains 36 methods (by creating a test class the implements this interface).
Describe the solution you'd like
To have a base abstract class
DownstreamApiBase
that implements the interface and exposes just a single methodthis would mean that the current https://github.com/AzureAD/microsoft-identity-web/blob/master/src/Microsoft.Identity.Web.DownstreamApi/DownstreamApi.cs#L455 API would be slightly different
then the current
DownstreamApi
class would extend this abstract-class and override theCallApiInternalAsync
method.This would allow any HttpClient mocking library to easily be leveraged here since the new API would be close to the
HttpClient.SendAsync
API.Describe alternatives you've considered
using the
Moq
library and mocking the interfaceIDownstreamApi
- mocking the correct method is a bit of a nuisance since there are many similar API's.Additional context
Add any other context or screenshots about the feature request here.
The text was updated successfully, but these errors were encountered: