[英]for testable controller do I need UoW or just repository?
I used to use Repository with Unit of Work patrons in my DAL. 我曾经在DAL中将Repository与Work Unit顾客一起使用。 I m just starting working with MVC. 我刚刚开始使用MVC。 Here I need some help please. 在这里,我需要一些帮助。
Do I need to implement Unit of Work in my DAL for making my controller testable or just repository with Interface implementation is required ? 我是否需要在DAL中实现工作单元以使控制器可测试,还是仅需要通过接口实现存储库?
I m confuse how I will do controller unit tests if I implement UoW ? 如果实现UoW,我将如何进行控制器单元测试?
Sorry my question may be a little theoretical but it is definite I guess :) 抱歉,我的问题可能有点理论性,但是我想这是肯定的:)
A repository interface in your controller constructor is simple enough for controller testing. 控制器构造函数中的存储库接口非常简单,可以进行控制器测试。 If you want to also unit test repositories, you can use a unit of work interface to abstract the DB work, which is easy enough to create for EF. 如果您还希望对测试存储库进行单元化,则可以使用工作单元界面来抽象数据库工作,这对于EF而言很容易创建。 That just allows you to test multiple layers. 那只允许您测试多层。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.