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

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

问题描述

我一直在玩ADO.NET实体框架最近,我发现它适合的项目中,我发展我的需求。我还发现冷却其非侵入性的。

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.

这是你面对的是生成的模型整合的任务,你的业务逻辑现有数据库生成数据模型之后。更具体地说,我已经习惯了集成测试我的课,与通过DAL接口的嘲笑/存根数据存储进行交互。问题是,你不能使用ADO.NET实体框架,因为它生成的实体是简单的类,没有界面做到这一点。

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.

现在的问题是:如何申请一个 TDD方法以使用ADO.NET实体框架的应用程序的开发?这甚至可能或者我应该迁移到另一个DAL代工具?

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?

推荐答案

一对实体框架大的批评之一是,它本质上是难以测试,例如在ALT.Net的不信任,全球环境基金引述投票。

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.

<一个href="http://blogs.msdn.com/diego/archive/2008/03/03/unit-testing-your-entity-framework-domain-classes.aspx"相对=nofollow>这里是一个博客帖子讨论如何解决这个问题,并能够在不进入数据库,使用实体框架时,来测试你的code。

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.

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

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天全站免登陆