TDD和ADO.NET实体框架 [英] TDD and ADO.NET Entity Framework

查看:180
本文介绍了TDD和ADO.NET实体框架的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近一直在玩ADO.NET实体框架,我发现它适合我正在开发的项目的需要。我也很酷的非侵入性。



从现有数据库生成数据模型后,您将面临生成模型和业务逻辑的集成任务。更具体地说,我习惯于通过DAL接口的mocks / stub来集成测试与数据存储交互的类。问题是您不能使用ADO.NET实体框架,因为它生成的实体是没有接口的简单类。



问题是:如何应用开发使用ADO.NET实体框架的应用程序的 TDD方法?这是甚么可能的,还是应该迁移到另一个DAL代工具集?

解决方案

对实体框架的一个大批评一直以来本身就很难测试,例如在ALT.Net 不信任投票被引用。



这是一篇博客文章,讨论如何解决这个问题,并且能够测试你的代码而不用数据库,当使用实体框架。



如果可测性是一个很大的问题,你可能想看另一个ORM框架,如NHibernate至少直到实体框架2.0发布。


I've been playing with ADO.NET Entity Framework lately, and I find that it suits my needs for a project I'm developing. I also find cool its non-invasive nature.

After generating a data model from an existing database you are faced with the task of integrating the generated model and your business logic. More specifically, I'm used to integration-test my classes that interact with the data store via mocks/stubs of the DAL interfaces. The problem is that you cannot do this using the ADO.NET Entity Framework because the entities it generates are simple classes with no interface.

The question is: how do I apply a TDD approach to the development of an application that uses ADO.NET Entity Framework? Is this even possible or should I migrate to another DAL-generation toolset?

解决方案

One of the big critiques against the Entity Framework has been that it is inherently hard to test, for example in the ALT.Net Vote of No Confidence that gef quoted.

Here is a blog post discussing how to get around this, and be able to test your code without hitting the database, when using Entity Framework.

If testability is a big concern, you might want to look at another ORM framework, such as NHibernate, at least until Entity Framework 2.0 is released.

这篇关于TDD和ADO.NET实体框架的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆