【发布时间】:2017-07-20 13:08:52
【问题描述】:
我有一个类似的控制器:
public ActionResult Index([ModelBinder(typeof(MyBinder))]int? MyId)
我想创建一个单元测试via Nunit+Moq+AutoFixture 以确保 MyId 参数使用 MyBinder 进行装饰,这似乎是一个有效的单元测试,因为如果它被删除,代码将按预期停止工作。显然,实际自定义模型绑定器的测试是单独进行的。
我希望它类似于测试一个属性被特定属性修饰,如下所示,但找不到如何以这种方式访问参数:
private readonly PropertyInfo _SomeProp = typeof(AddressViewModel).GetProperty("SomeProp");<br>
_SomeProp.Should().BeDecoratedWith<DisplayAttribute>();
【问题讨论】:
标签: c# asp.net-mvc unit-testing nunit moq