Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
对于使用 ExpectCall 或 OnCall 模拟成员方法,您可以使用 Do 方法。但是对于静态函数,如果您尝试 Do,编译器会告诉您 Do 不是 Call 类的成员。有没有类似的机制?
好吧,我的坏。显然将 Do 放在 Return 后面不起作用: mocker.OnCallFunc(ReadFile).Return(true).Do(ReadFileMock);
mocker.OnCallFunc(ReadFile).Return(true).Do(ReadFileMock);
但这只是编译没有问题: mocker.OnCallFunc(ReadFile).Do(ReadFileMock).Return(true);
mocker.OnCallFunc(ReadFile).Do(ReadFileMock).Return(true);
我不知道有一个强制性的命令。我应该提供代码示例。