i want to test a repository that uses the IHttpClientFactory interface.The repository i want to test makes an external api call to a web service using the httpclient.The web service returns json data i then return the Deserialized json data.This is the flow am following in all the methods in my repository class. i have read alot of articles regarding this matter but none were helpful,maybe its because am a beginner.any help will be highly appreciated. here is the repository code ``
public class Movies : IMovies
{
private readonly IHttpClientFactory _httpClientFactory;
public Movies(IHttpClientFactory httpClientFactory)
{
_httpClientFactory = httpClientFactory;
}
public async Task<MovieCollection> GetPopularMovies(int PageNumber = 1)
{
// Get an instance of HttpClient from the factpry that we registered
// in Startup.cs
var client = _httpClientFactory.CreateClient("Movie Api");
// Call the API & wait for response.
// If the API call fails, call it again according to the re-try policy
// specified in Startup.cs
var result =
await client.GetAsync($"movie/popular?api_key=18783d19189b3c4c0abc3c8e3080d3da&language=en-US&page={PageNumber}");
if (result.IsSuccessStatusCode)
{
// Read all of the response and deserialise it into an instace of
var content = await result.Content.ReadAsStringAsync();
return JsonConvert.DeserializeObject<MovieCollection>(content);
}
return null;
}}
``