是否可以测试使用Rhino Mocks 3.5未调用属性设置器? 这完全有可能: public class OneProperty{ virtual public int MyInt { get; set; }}[Test]public void IntWasSet(){ var prop = Rhino.Mocks.MockRepository.GenerateMockOnePr
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();
}
在Rhino Mocks 3.5上运行此测试会导致以下错误:
Errors and Failures: 1) Test Error :
InterfacerTests.TestMatchesInterface.IntWasSet
Rhino.Mocks.Exceptions.ExpectationViolationException
: Expected that
OneProperty.set_MyInt(anything); would
not be called, but it was found on the
actual calls made on the mocked
object.
我发现了Arg< T>语法from this part of the Rhino documentation.
