实体框架4 CTP 5 POCO

编程入门 行业动态 更新时间:2024-10-20 15:57:28
本文介绍了实体框架4 CTP 5 POCO - 如何单元测试我的存储库< T>的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

这是另一个问题的第二部分实体框架4 CTP 4 / CTP 5通用存储库模式和单元可测试),其中我询问如何使用EF 4 POCO实现通用存储库模式。现在我的存储库正在运行,我想知道如何单元测试我的存储库(TDD或BDD)。

This is the 2nd part of another question Entity Framework 4 CTP 4 / CTP 5 Generic Repository Pattern and Unit Testable), where I asked how to implement a generic repository pattern using EF 4 POCO. Now that my repository is working, I would like to know how to unit test my Repository (TDD or BDD).

感谢所有。

推荐答案

我用SpecFlow写了一些博客文章。但是,当它复杂时,这是一场灾难。

Hey I wrote some blog posts on doing this with SpecFlow. But that was a disaster when it got complex.

我试图实现一个也是灾难的测试库。尝试复制数据上下文的工作方式不是一个聪明的想法。

I tried to implement a testing repository which was also a disaster. Trying to replicate how the data context work is not a smart idea.

但是,您可以从错误中学习,并开始乐趣。我学到的是使用轻量级或内存中的数据库(SQLite)。

But you learn from your mistakes and have fun along the way. What I learnt was to use a light-weight or in-memory database (SQLite).

所以我一定会说使用SQLite数据库,如果你可以使它工作与EF代码优先。我不能这样做,所以我去了一个SQL CE紧凑版本。即使在测试中,它的运行速度也非常快。

So I would definitely say to use a SQLite database if you can get it working with EF Code First. I wasn't able to do this, so I went with a SQL CE compact edition. It runs amazingly quick, even in testing.

您可能知道这篇博客文章,但重新检查步骤4. weblogs.asp/scottgu/archive /2010/07/16/code-first-development-with-entity-framework-4.aspx

You probably know all about this blog post, but re-check step 4. weblogs.asp/scottgu/archive/2010/07/16/code-first-development-with-entity-framework-4.aspx

所以在本质上,我在我的最近的项目是要有一个单独的数据库SQL CE 4.0紧凑版本进行测试。超快速,无投诉。

So in essence, all I did on my most recent project was to have a separate database SQL CE 4.0 compact edition for testing. Super quick and no complaints.

更多推荐

实体框架4 CTP 5 POCO

本文发布于:2023-11-14 15:19:52,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1587790.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:实体   框架   POCO   CTP

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!