Testing Dapper Queries

Possible duplicate:
DbConnection without Db using the built-in DataSet (or the like) as a source

I have a repository that is responsible for several complex queries, and I use dapper in this repository to map objects. Queries worked too poorly in EF, and dapper worked just fine.

I want to check the scope of these queries, although of course they are correct.

The repository has one dependency on an IDBConnection object.

public class TaskRepository(IDBConnection connection){}

I currently have a separate development database with mock data used only for these tests. There are some problems though ...

  • Testing is slow as they get into the database
  • The database is too large to support just to run some tests.
  • It takes a long time to manually collect data for new test cases.

I would consider these integration tests, I want to get unit tests if I can.

Can I mock the IDBConnection interface with a collection of data in memory? . This would allow me to keep the mock data close to the tests that use it, and create more unique data so that it matches more test cases.

0
source share

All Articles