单元测试实体框架实体、框架、单元测试

2023-09-03 15:06:52 作者:往年岁月不忍欺

我刚开始使用实体框架(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