File: DelegateSupportedConditionAttribute.cs
Web Access
Project: src\src\Servers\HttpSys\test\FunctionalTests\Microsoft.AspNetCore.Server.HttpSys.FunctionalTests.csproj (Microsoft.AspNetCore.Server.HttpSys.FunctionalTests)
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
 
using Microsoft.AspNetCore.InternalTesting;
 
namespace Microsoft.AspNetCore.Server.HttpSys.FunctionalTests;
 
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false)]
public class DelegateSupportedConditionAttribute : Attribute, ITestCondition
{
    private readonly bool _isSupported;
    private readonly bool _httpApiSupportsDelegation;
    public DelegateSupportedConditionAttribute(bool isSupported)
    {
        _isSupported = isSupported;
        try { _httpApiSupportsDelegation = HttpApi.SupportsDelegation; } catch { }
    }
 
    public bool IsMet => _httpApiSupportsDelegation == _isSupported;
 
    public string SkipReason => $"Http.Sys does {(_isSupported ? "not" : "")} support delegating requests";
}