File: ApplicationModels\ClientErrorResultFilterConventionTest.cs
Web Access
Project: src\src\Mvc\Mvc.Core\test\Microsoft.AspNetCore.Mvc.Core.Test.csproj (Microsoft.AspNetCore.Mvc.Core.Test)
// 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.Mvc.Infrastructure;
 
namespace Microsoft.AspNetCore.Mvc.ApplicationModels;
 
public class ClientErrorResultFilterConventionTest
{
    [Fact]
    public void Apply_AddsFilter()
    {
        // Arrange
        var action = GetActionModel();
        var convention = GetConvention();
 
        // Act
        convention.Apply(action);
 
        // Assert
        Assert.Single(action.Filters.OfType<ClientErrorResultFilterFactory>());
    }
 
    private ClientErrorResultFilterConvention GetConvention()
    {
        return new ClientErrorResultFilterConvention();
    }
 
    private static ActionModel GetActionModel()
    {
        var action = new ActionModel(typeof(object).GetMethods()[0], new object[0]);
 
        return action;
    }
}