简体   繁体   English

对于可测试的控制器,我需要UoW还是仅存储库?

[英]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.

相关问题 使用 DI 和 UoW 模式时是否需要使用 EF 语句 - Do i need using statements for EF when utilising DI and UoW patterns 带有UoW更新的EF存储库 - EF Repository with UoW Update 存储库/ UoW - 使用或不使用? - Repository / UoW - To use or not to use? 为什么我需要在 Controller 类构造函数中和 Repository 类构造函数中启动 DBContext 对象 - Why do i need to Initiate the DBContext object inside the Controller class constructor & inside the Repository class constructor 具有服务层的存储库和UoW模式 - Repository and UoW pattern with service layer EF5中的UOW和存储库模式 - UOW and Repository Pattern in EF5 最佳实践:实体框架:如果使用存储库和UoW模式,在哪里进行联接 - Best practice: entity framework: where to do joins if using repository and UoW patterns 您是否将文件处理逻辑放在存储库中? (在EF中使用通用存储库和UoW模式)? - Do you place files processing logic in repositories? (Using generic repository and UoW pattern with EF)? 将逻辑从控制器操作移动到“服务层”,而不使用ASP.NET MVC中的IoC / DI,Uo​​W和存储库模式 - Moving logic from controller action to a “service layer” without using IoC/DI, UoW and repository patterns in ASP.NET MVC UOW + Repository + Autofac加载两个不同的DbContext - UOW + Repository + Autofac load two different DbContext
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM