How to unit test Database Class

This has probably been asked many times, but here it is:

I have a class full of db connections

open connection
query db
read values
close connection

How do I unit test this stuff?

Do I need to create a fake database? I guess I could make fun of MySql classes (for C #), but that is also a lot of work.

Some of the statements are: "INSERT INTO", what should I do with this?

+5
source share
3 answers

Those things that are difficult to verify are often closely related or do not follow the principle of shared responsibility .

. datalayer. . ( ) .

: IDbConnection SqlConnection. DbProviderFactory, . connection.CreateCommand(), ..

. , datalyer . - .

: - . ( ).

+7

db , - , , , ,

, sql , , . .

+2

MySql .

Nuget , : https://github.com/stumpdk/MySql.Server

MySql , . , , , .

0

All Articles