inside of the method which I'm evaluating in my Unit Test I want to return a mocked value which call my repository pattern, but always return null.
I've tried with both options below but the behavior is the same (return null):
Repository.FindAsync<User>(Arg.Is<Expression<Func<User, bool>>>(x => x.Email == "Test")).Returns(new User() { FirstName = "Test"});
and
Repository.FindAsync<User>(x => x.Email == "Test").Returns(new User() { FirstName = "Test"});
I paste the whole code of my unit test
public class WhenTestingUser : WhenTesting<Customer>
{
private IRepository Repository { get; set; }
protected override void Given()
{
Repository = Fixture.Freeze<IRepository>();
Repository.Find<User>(Arg.Any<Expression<Func<User, bool>>>()).ReturnsNull();
Repository.FindAsync<User>(Arg.Is<Expression<Func<User, bool>>>(x => x.Email == "Test")).Returns(new User() { FirstName = "Test"});
}
protected override void When()
{
SystemUnderTest.UpdateUser().GetAwaiter();
}
[Test]
public void WhenCalled()
{
throw new NotImplementedException();
}
}
I'm working with AutoFixture.AutoNSubstitute, NSubstite and NUnit