I have the following function signature:
T SomeMethod(Expression<Func<T, string>> param1,
, params Expression<Func<T, object>>[] items);
I want it to throw an exception everytime it's executed.
I tried to do the following setup:
myMock.Setup(x => x.SomeMethod(Moq.It.IsAny<Expression<Func<SomeClass, string>>>()))
.Throws(new Exception());
Everything works find but when I arrive to this method it does't throw an exception (although the object is my mock).
I assume my setup is incorrect.
I tried many variation for a while and now I'm a bit frustrated.
I would have put more code but it is restricted. Each piece I want to upload I should alter so excuse me for being cheap with information.
Hope it's enough and some one can assist me.
Looks like the problem is in the params
parameter. Try adding it to the setup
myMock.Setup(x => x.SomeMethod(
Moq.It.IsAny<Expression<Func<SomeClass, string>>>()),
Moq.It.IsAny<Expression<Func<T, object>>[]>())
).Throws(new Exception());
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With