Instead of consuming DbConnection, can you use IDbConnection and mock it? We do something similar, pass the DataSet layout. DataSet.CreateDataReader returns a DataTableReader that inherits from DbDataReader.
We wrapped DbConnection in our own interface, like IDbConnection, to which we added the ExecuteReader () method, which returns a class that implements the same interfaces as DbDataReader. In our layout, ExecuteReader simply returns what the DataSet.CreateDataReader feeds.
Sounds a roundabout way, but it is very convenient to create a DataSet with a possible set of result sets. We call DataTables after the stored processes that they present the results, and our IDbConnection layout captures the right Datatable based on the process that the client invokes. DataTable also implements CreateDataReader, so we are good to go.
n8wrl
source share