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
I am trying to write an extension method for Mock to verify a call to every item in a list.
My extension: public static void VerifyMultiple<T, TItem>(this Mock<T> value, Action<T, TItem> action, Times times, IEnumerable<TItem> items) where T : class { foreach (var item in items) { value.Verify(x => action(x, item), times); } }
Example call: this._mockDAL.VerifyMultiple((x,i) => x.Save(i), Times.Once(), items);
But I get the error System.NotSupportedException: 'Unsupported expression: x'
I unfortunately do not know what is wrong with that call or why this exception is thrown
Can somebody explain?
The text was updated successfully, but these errors were encountered:
Make your action parameter an Expression<Action<T, TItem>> instead? That's the type Mock<T>.Verify receives and is that makes it possible to inspect which mock member invocation to verify.
I am trying to write an extension method for Mock to verify a call to every item in a list.
My extension:
public static void VerifyMultiple<T, TItem>(this Mock<T> value, Action<T, TItem> action, Times times, IEnumerable<TItem> items) where T : class { foreach (var item in items) { value.Verify(x => action(x, item), times); } }
Example call:
this._mockDAL.VerifyMultiple((x,i) => x.Save(i), Times.Once(), items);
But I get the error
System.NotSupportedException: 'Unsupported expression: x'
I unfortunately do not know what is wrong with that call or why this exception is thrown
Can somebody explain?
The text was updated successfully, but these errors were encountered: