File: TestHttpMessageHandler.cs
Web Access
Project: src\src\Security\Authentication\test\Microsoft.AspNetCore.Authentication.Test.csproj (Microsoft.AspNetCore.Authentication.Test)
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
 
using System.Net.Http;
 
namespace Microsoft.AspNetCore.Authentication;
 
public class TestHttpMessageHandler : HttpMessageHandler
{
    public Func<HttpRequestMessage, HttpResponseMessage> Sender { get; set; }
 
    protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, System.Threading.CancellationToken cancellationToken)
    {
        if (Sender != null)
        {
            return Task.FromResult(Sender(request));
        }
 
        return Task.FromResult<HttpResponseMessage>(null);
    }
}