I am trying to write a unit test for a class, and one of the dependency's method has a LINQ exresssion as a parameter passed into it. Now, I've mocked the dependency. But I am trying to tell this mock to return an object. Which I've done. But I don't know what matching argument 'arg' to pass as a parameter.
I tried to use the solution suggested here, but I couldn't really follow it 100%. Is this the answer? That there is no way?
Code in class under test:
var user = await _userRepository.GetFirstOrDefaultAsync(predicate: x =>
x.Email.ToLower() == dto.Email.ToLower());
I've mocked _userRepository
, by saying _userRepositoryMock = Substitute.For<IUserRepository>();
Now, trying to tell it to return an object when called:
_userRepositoryMock.GetFirstOrDefaultAsync(not sure what goes
here).Returns(user);
In the meantime, I've just passed null
like what this guy did.
_userRepositoryMock.GetFirstOrDefaultAsync(null).Returns(user);