【发布时间】:2010-10-12 15:14:42
【问题描述】:
我正在尝试使用流利的测试助手来测试 AbstractRestfulFluentController
public class CustomerController : AbstractRestfulFluentController
{
private readonly IService<Customer> _customerService;
private readonly IService<CustomerAddress> _addressService;
public CustomerController(IService<Customer> customerService, IService<CustomerAddress> addressService)
{
//Assume we use these in other actions
_customerService = customerService;
_addressService = addressService;
}
public ActionResult Index()
{
return View();
}
}
如您所见,我将一些服务注入控制器并使用 IOC 解决它们。我的问题是,我在 mvccontrib 中使用流利的测试方法找到的所有示例在没有无参数控制器的情况下都无法工作。
public void SuccessfulIndex()
{
GivenController.As<CustomerController>()
.ShouldRenderItself(RestfulAction.Index)
.WhenCalling(x => x.Index());
}
我不确定我需要做什么才能将 IOC 与 mvccontrib 中的流畅测试技术结合使用。我发现了一些可能的cmets,但没有找到任何东西。我该怎么做才能真正使用 IOC 和流利的测试?
【问题讨论】:
标签: c# asp.net-mvc-2 ioc-container mvccontrib