Moq - Linq expression in repository - Specify expression in setup

后端 未结 2 2042
梦谈多话
梦谈多话 2021-02-14 13:16

I have a method on my interface that looks like:

T GetSingle(Expression> criteria);

I\'m trying to mock the setup som

2条回答
  •  情话喂你
    2021-02-14 14:06

    If you don't mind a generic set up, it can be simpler like this.

    _mockUserRepository.Setup(c => c.GetSingle(It.IsAny>>()))
        .Returns(new User { EmailAddress = "a@b.com" });
    

提交回复
热议问题