I have a method on my interface that looks like:
T GetSingle(Expression> criteria);
I\'m trying to mock the setup som
I managed to get this to work:
Expression<Func<User, bool>> expr = user => user.EmailAddress == "a@b.com";
_mockUserRepository.Setup(c => c.GetSingle(It.Is<Expression<Func<User, bool>>>(criteria => criteria == expr)))
.Returns(new User { EmailAddress = "a@b.com" });
User result = _mockUserRepository.Object.GetSingle(expr);
If you don't mind a generic set up, it can be simpler like this.
_mockUserRepository.Setup(c => c.GetSingle(It.IsAny<Expression<Func<User, bool>>>()))
.Returns(new User { EmailAddress = "a@b.com" });