我試圖使用流利的測試助手來測試AbstractRestfulFluentControllerASP.MVC並與國際奧委會
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();
}
}
正如你可以看到我注射一些服務到控制器,並使用它們的解析mvccontrib流利測試國際奧委會。我的問題是,我發現在mvccontrib中使用流暢測試方法的所有示例在沒有無參數控制器的情況下都不起作用。
public void SuccessfulIndex()
{
GivenController.As<CustomerController>()
.ShouldRenderItself(RestfulAction.Index)
.WhenCalling(x => x.Index());
}
我不知道我需要做什麼才能在mvccontrib中使用IOC和流暢的測試技術。我發現了一些可能的但沒有發現的評論。我能做些什麼才能真正使用IOC和流利的測試?
這看起來是迄今爲止我最好的選擇。如果我必須做出任何額外的更改,我會發布更新。一旦確認,我會標記完成。 – Firestrand 2010-10-13 02:41:56