namespace Elsa.Activities.UnitTests.Helpers;
///
/// Custom test HTTP message handler that allows full control over HTTP responses for testing.
/// Use this class to simulate different HTTP scenarios without making actual network calls.
///
public class TestHttpMessageHandler : HttpMessageHandler
{
private readonly Func> _sendAsyncFunc;
///
/// Initializes a new instance of TestHttpMessageHandler.
///
/// Function that defines how to handle HTTP requests and generate responses
public TestHttpMessageHandler(Func> sendAsyncFunc)
{
_sendAsyncFunc = sendAsyncFunc;
}
///
/// Handles HTTP requests using the provided function.
///
protected override Task SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
{
return _sendAsyncFunc(request, cancellationToken);
}
}