I have the following interface
public interface Itf {
bool M();
bool Method<T>(Expression<Func<T, bool>> x);
}
I cannot figure out how to mock the method Method (using Moq)
var mck = new Mock<Itf>();
mck.Setup(o => o.M()).Callback(() => { }); //Ok
mck.Setup(o => o.Method(???)).Callback(x => {...}); //What should I replace ??? with?
DESIRED BEHAVIOUR
What I would like to achieve is to have my callback called whenever Method is called. This is what I tried :
mck.Setup(o => o.Method(It.IsAny<Expression<Func<DocumentCollectionModel, bool>>>()))).Callback<Expression<Func<DocumentCollectionModel, bool>>>(x => {...}); //OK
mck.Setup(o => o.Method(It.IsAny<Expression<Func<It.IsAnyType, bool>>>()))).Callback<Expression<Func<It.IsAnyType, bool>>>(x => {...}); //Callack not called
mck.Setup(o => o.Method(It.IsAny<Expression<Func<It.IsSubtype<object>, bool>>>()))).Callback<Expression<Func<It.IsSubtype<object>, bool>>>(x => {...}); //Callack not called
While the first example works, if possible I would like to have it generic, like the second or third, otherwise I have to repeat the mock for every specific type.