我试图测试我的基本控制器是否装饰了某个动作过滤器.因为这个过滤器的构造函数看起来web.config,我第一次尝试测试失败,因为测试项目没有有效的配置文件.继续,我使用了一个TestConfigProvider我注入到过滤器构造函数中,但是下面的测试失败了,因为配置提供程序没有传递给构造函数.如果应用此过滤器,我还能怎么测试?
[TestMethod]
public void Base_controller_must_have_MaxLengthFilter_attribute()
{
var att = typeof(BaseController).GetCustomAttribute<MaxLengthFilter>();
Assert.IsNotNull(att);
}
Run Code Online (Sandbox Code Playgroud)