I'm using moq framework for unit test my C# code. its working good with ef core and its objects, but I also have some sql queries in my code that I have to include in Unit Testing process. below is my method which contains some sql scripts, I want to run this script in unit testing but without affecting on real database.
public void DeleteContentData(string connectionString)
{
using IDbConnection db = new SqlConnection(connectionString);
DynamicParameters dynParameters1 = new DynamicParameters();
dynParameters1.Add("@contentId", _content.content_id);
db.Execute("DELETE FROM [content] WHERE content_id=@contentId", dynParameters1);
db.Execute("INSERT INTO [content] (content_id) VALUES (@contentId);", dynParameters1);
}
How can I execute this method and run sql scripts without delete records and insert new records in unit testing.