2020-04-25 14:14:59 +00:00
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Net.Http;
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
2020-08-01 14:55:24 +00:00
|
|
|
namespace NucuCar.Domain.Http
|
2020-04-25 14:14:59 +00:00
|
|
|
{
|
2020-11-25 18:49:15 +00:00
|
|
|
public class MockMinimalHttpClient : MinimalHttpClient
|
2020-04-25 14:14:59 +00:00
|
|
|
{
|
2021-08-01 18:01:19 +00:00
|
|
|
public readonly List<HttpRequestMessage> SendAsyncArgCalls;
|
|
|
|
public readonly List<HttpResponseMessage> SendAsyncResponses;
|
2020-04-25 14:14:59 +00:00
|
|
|
|
|
|
|
private int _sendAsyncCallCounter;
|
|
|
|
|
2020-11-25 18:49:15 +00:00
|
|
|
public MockMinimalHttpClient(string baseAddress) : base(baseAddress)
|
2020-04-25 14:14:59 +00:00
|
|
|
{
|
|
|
|
_sendAsyncCallCounter = 0;
|
|
|
|
SendAsyncArgCalls = new List<HttpRequestMessage>();
|
|
|
|
SendAsyncResponses = new List<HttpResponseMessage>();
|
|
|
|
}
|
|
|
|
|
|
|
|
public override Task<HttpResponseMessage> SendAsync(HttpRequestMessage requestMessage)
|
|
|
|
{
|
|
|
|
SendAsyncArgCalls.Add(requestMessage);
|
|
|
|
var response = SendAsyncResponses[_sendAsyncCallCounter];
|
|
|
|
_sendAsyncCallCounter += 1;
|
|
|
|
return Task.FromResult(response);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|