/// <summary>
    /// Marks an endpoint to be cached using a named policy.
    /// </summary>
    public static TBuilder CacheOutput <TBuilder>(this TBuilder builder, string policyName) where TBuilder : IEndpointConventionBuilder
    {
        ArgumentNullException.ThrowIfNull(builder);

        var policy = new NamedPolicy(policyName);

        builder.Add(endpointBuilder =>
        {
            endpointBuilder.Metadata.Add(policy);
        });

        return(builder);
    }
    public async Task ProfilePolicy_UsesNamedProfile()
    {
        var options = new OutputCacheOptions();

        options.AddPolicy("enabled", EnableCachePolicy.Enabled);
        options.AddPolicy("disabled", EnableCachePolicy.Disabled);
        var context = TestUtils.CreateUninitializedContext(options: options);

        IOutputCachePolicy policy = new NamedPolicy("enabled");

        await policy.CacheRequestAsync(context, default);

        Assert.True(context.EnableOutputCaching);

        policy = new NamedPolicy("disabled");

        await policy.CacheRequestAsync(context, default);

        Assert.False(context.EnableOutputCaching);
    }