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));