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

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

问题描述

我刚开始使用实体框架(V4)和LINQ。

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

我有一个实体的数据模型,它已经从一个数据库生成。我已经再实施库类,以实现业务逻辑为我的实体和它们所包含我的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?

推荐答案

您可以针对inmemory数据库运行测试。 检查这个问题

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

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

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