Moq,如何匹配2个参数?

qin*_*126 1 c# moq

我是moq的新手,需要帮助来匹配2个参数.

这是我从quickstart中找到的例子.

mock.Setup(foo => foo.DoSomething(It.IsAny<string>())).Returns(true);
Run Code Online (Sandbox Code Playgroud)

但是我的函数Dosomething需要2个参数(字符串和AccountType),AccountType是枚举类型.

我试过了,

mock.Setup(foo => foo.DoSomething(It.IsAny<string, AccountType>())).Returns(true);
Run Code Online (Sandbox Code Playgroud)

我知道这是错的.请帮帮我.

Dav*_*d M 7

只需在设置中添加2个参数:

mock
  .Setup(foo => foo.DoSomething(It.IsAny<string>(), It.IsAny<AccountType>()))
  .Returns(true);
Run Code Online (Sandbox Code Playgroud)