New to NSubstitute and having trouble mocking the returns for method calls that take a predicate. For example I have this in the main code
var currReport = this.ClientRepo.Get<Report>(x => x.Uid == reportUid).FirstOrDefault();
I want to do something like this in my test
var parentReport = new Report(){Uid = request.ParentReportUid, Name = "Test"};
this.clientRepository.Get(Arg.Is<Expression<Func<Report, bool>>>(expr => Lambda.Eq(expr, i => i.Uid == request.ParentReportUid))).Returns(new List<Report>() { parentReport }.ToArray());
This is not working. I have confirmed that request.ParentReportUid matches the reportUid in the actual method call. But still it returns a null. If I switch to an Arg.Any then it returns the report, like this
this.clientRepository.Get(Arg.Any<Expression<Func<Report, bool>>>()).Returns(new List<Report>() { parentReport }.ToArray());
This is the signature of the actual method I am trying to mock.
T[] Get<T>(System.Linq.Expressions.Expression<Func<T, bool>> predicate = null);
Please advise. Thanks