How to mock SqlParameterCollection using Moq
Personally, I approach this problem by writing an AddParameterWithValue
extension method to DbCommand
(or IDbCommand
). It has to be on the command so that you have access to CreateParameter
, and then call .Parameters.Add
.
This allows easy usage against any ADO.NET stack, including abstractions like logging decorators.