Vad*_*dim 6 rhino-mocks moq mocking
Moq允许开发人员模拟受保护的成员.我在Rhino.Mocks中寻找相同的功能但却找不到它.
以下是Moq快速入门页面如何模拟受保护方法的示例.
// at the top of the test fixture
using Moq.Protected()
// in the test
var mock = new Mock<CommandBase>();
mock.Protected()
.Setup<int>("Execute")
.Returns(5);
// if you need argument matching, you MUST use ItExpr rather than It
// planning on improving this for vNext
mock.Protected()
.Setup<string>("Execute",
ItExpr.IsAny<string>())
.Returns(true);
Run Code Online (Sandbox Code Playgroud)
如果我正在追逐不退出的东西,请告诉我.