这完全有可能:
public class OneProperty
{
virtual public int MyInt
{
get;
set;
}
}
[Test]
public void IntWasSet()
{
var prop = Rhino.Mocks.MockRepository.GenerateMock<OneProperty>();
prop.MyInt = 5;
prop.AssertWasNotCalled(x => x.MyInt = Arg<int>.Is.Anything);
prop.VerifyAllExpectations();
}
Run Code Online (Sandbox Code Playgroud)
在Rhino Mocks 3.5上运行此测试会导致以下错误:
错误和失败:1)测试错误:InterfacerTests.TestMatchesInterface.IntWasSet Rhino.Mocks.Exceptions.ExpectationViolationException:期望OneProperty.set_MyInt(任何东西); 不会被调用,但它是在模拟对象上进行的实际调用中找到的.
我从Rhino文档的这一部分中发现了Arg<T>语法.