The “Thunderdome Principle” – All@H_403_4@ Controller methods take in one@H_403_4@ viewmodel object (or zero objects in@H_403_4@ some cases) and return a single@H_403_4@ viewmodel object (one object enters,@H_403_4@ one object leaves). The Controller@H_403_4@ classes will NEVER be directly exposed@H_403_4@ to anything related to HttpContext.@H_403_4@ Nothing makes me cry like seeing@H_403_4@ people trying to write tests that mock@H_403_4@ or stub that new IHttpContextWrapper@H_403_4@ interface. Likewise,Controller@H_403_4@ methods do not return ViewResult@H_403_4@ objects and are generally decoupled@H_403_4@ from all MVC infrastructure. We@H_403_4@ adopted this strategy very early on as@H_403_4@ a way to make Controller testing@H_403_4@ simpler mechanically. It’s definitely@H_403_4@ achieved that goal,but it’s also made@H_403_4@ the Controller code very streamlined@H_403_4@ and easy to read. We’ll explain how@H_403_4@ this works at KaizenConf.
解决方法
由于我们所有的控制器操作都遵循相同的模式,因此我们可以假设很多事情并加速并简化我们的控制器集成测试工作.
有一个控制器动作有多个参数,没有什么不对,但我们发现有一个实际的模型对象为我们提供了一些额外的功能,因为模型可以包含简单的逻辑并暴露方便的属性,这可能只是一些更复杂的方面.它自己的状态等 – 基本上,这是拥有任何丰富模型的论据,并不是Thunderdome / OMIOMO模式所独有的.