Integration Testing Entity Framework code first with in-memory database

后端 未结 2 502
没有蜡笔的小新
没有蜡笔的小新 2020-12-03 02:09

I\'d like to run actual integration tests of my EF4.1 repositories against an in-memory database a la ayende\'s nhibernate version.

I have a code first model, agains

2条回答
  •  清歌不尽
    2020-12-03 02:59

    Take a look at this article: Faking your LINQ provider. It describes how you can hide Entity Framework behind an abstraction, so that you can easily unit test your application, while still allowing to use LINQ (over IQueryable) queries against it in your application code.

    Note that this does not completely remove the need of writing integration tests, since you would still need to test the database mapping layer and possibly test whether the chosen LINQ provider is able to execute the LINQ queries.

提交回复
热议问题