When unit testing, how do I mock a return null from async method?

You get a compiler error because you return a task that doesn’t match the type the async method returns. You should return Task<Member> instead of simply Task<object>:

repository.Setup(r => r.GetMemberAsync(email)).Returns(Task.FromResult<Member>(null));

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)