Matching parameters which are expressions
Maybe it is already somehow possible, but I need to be able to do something like this:
mock.Verify(x => x.Foo(y => Bar(It.Is<int>(z => z == 2))), Times.Once);
Verify must match calls to Foo where the parameter is an expression calling 'Bar' with a parameter which must equal '2'.
I know I can write the following, which however is not quite specific enough.
mock.Verify(x => x.Foo(It.IsAny<Expression<Func<int, int>>()), Times.Once);
AdminDaniel Cazzulino (Admin, moq) commented
Comparison of expression trees is not provided by the underlying .NET, so Moq can't compare equality on them, hence the comparison fails.