Using the Mock Database Service

The MockDatabaseService class is a full IDatabaseService implementation that, instead of actually accessing a database, records the query execution and optionally returns previously stubbed data. In addition to recording query execution, it provides a host of assertions that can be run to ensure that the database access was as expected. It can also be provided as an implementation for use with DatabaseServiceAsync.


Assertions are provided for the following:
  • query name (string)
  • query name and parameter dictionary (IDictionary<string, object>)
  • query name and number of times executed (int)
  • query name, number of times executed, and parameter dictionary

There are sets of assertions for each query type (for example, MockDatabaseService.AssertPerformedSelect() is the name for methods that specify only SELECT executions), and one set of assertions that do not have the type restrictions (MockDatabaseService.AssertPerformed()).


Last edited Apr 1, 2013 at 9:22 PM by danielsummers, version 1


No comments yet.