Unit test code that interacts with the database without creating data in the database

I want to test my C # code in Visual Studio with unit tests. The code interacts with the MySQL database.

An example of what I want to check. A
user opens my application and will be saved to the database through webservice. Now I want to know if the table Usershas another row before a new user appears. But if I test the method in a web service that will create an entry in the database, the test data will be in the database. And I do not need test data in my database.

Is there a solution to this problem?

+4
source share
4 answers

, , . -.

, moq moh.

, , . , .

+9

, , - Mock. , Moq #.

unit test. , , .

+1

- .

( , ), MySql.

, MySql .

Nuget (Mysql.Server) : https://github.com/stumpdk/MySql.Server

+1

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


All Articles