How can I check for Dapper requests in the .net kernel?

With code targeting for the full .net Framework, I could mock IDbConnection and point it to the ridiculed DataSet to verify that my queries were correctly executed. Similarly, if I were using EntityFramework 6, I could mock DbSet to return IQueryables and test my data-level logic against this.

However .net core does not support DataSets (although this may change in the future ?).

At the same time, is there a way to create a collection of objects that dapper can query using IDbConnection to check the logic of the request?

+4
source share
1 answer

No, all dappers are extension methods on top of the class IDbConnection.

There is no InMemory ( IDbConnection) implementation (which understands SQL strings) for this.

Best of all, if you want to run it completely autonomously, you would have to deploy a new sql server for each test module run. This is easy to do using the docker image made by Microsoft for sqlserver: https://hub.docker.com/r/microsoft/mssql-server-linux/

or...

Or go to the Entity infrastructure, they will allow you to unit test in the backup storage in memory.

why?

Dapper SQL. SQL. sql - #. . , unit test sql/dapper .

-. , , # /​​ (, IDbCollection). 1 , sql , . unit test .

Microsoft

Microsoft , . / ( ). , sql, , , .

+5

Source: https://habr.com/ru/post/1675305/


All Articles