单元测试实体框架 [英] Unit Testing Entity Framework

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

问题描述

我刚刚开始使用Entity Framework(v4)和Linq。



我有一个从数据库生成的实体数据模型。我已经实现了存储库类,以实现我的实体的业务逻辑,并且它们包含我的LINQ查询以与实体/数据库进行交互。



什么是最简单和最简单的单独测试我的存储库类中的方法/函数的最简单的方法,而不用打数据库?

解决方案

内存数据库。 检查此问题


I have just started using Entity Framework(v4) and Linq.

I have a Entity data model, which has been generated from a database. I have then implemented repository classes in order to implement the business logic for my entities and they contain my LINQ queries for interacting with the entities/database.

What is the easiest and simplest way to unit test the methods/functions in my repository classes without hitting the database?

解决方案

You can run your tests against an inmemory database. Check this question

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

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