You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What I mean by this is that I've been struggling with a MockException thrown stating:
Moq.MockException : DbDataReader.GetFieldValueAsync(0, System.Threading.CancellationToken) invocation failed with mock behavior Strict.
All invocations on the mock must have a corresponding setup.
I was getting this exception despite quite clearly having set up that method in my testing suite.
In the end the issue was caused because DbDataReader.GetFieldValueAsync is actually defined as: DbDataReader.GetFieldValueAsync<TResult>.
Keeping to a DRY principle when writing my test, rather than write 8 setup calls, i threw everything into an array and used that....not thinking that by doing so I was changing the specialization of the calls from string, DateTime, etc to object.
If the message were to indicate the generic specialization it was looking for when throwing the exception, it would make debugging such errors much easier to find.
The text was updated successfully, but these errors were encountered:
hasaki
added a commit
to hasaki/moq4
that referenced
this issue
Jun 7, 2015
Adds type information for a generic method to the exception output,
making it easier to debug issues where passed arguments may match, but
the generic parameters do not. Fixesdevlooped#176
hasaki
added a commit
to hasaki/moq4
that referenced
this issue
Jun 7, 2015
What I mean by this is that I've been struggling with a MockException thrown stating:
I was getting this exception despite quite clearly having set up that method in my testing suite.
In the end the issue was caused because
DbDataReader.GetFieldValueAsync
is actually defined as:DbDataReader.GetFieldValueAsync<TResult>
.Keeping to a DRY principle when writing my test, rather than write 8 setup calls, i threw everything into an array and used that....not thinking that by doing so I was changing the specialization of the calls from
string
,DateTime
, etc toobject
.If the message were to indicate the generic specialization it was looking for when throwing the exception, it would make debugging such errors much easier to find.
The text was updated successfully, but these errors were encountered: