Moq: Creating an integration test with database access


/ Published in: C#
Save to your folder(s)

using (var scope = new TransactionScope()) makes sure that any changes to the database are temporary and only last as long as the test is running.

The ExecuteScalar is used to get a value from the table.

The ExecuteNonQuery is used to insert a record that the test will use.

_target is the class that is accessing the database.

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.