我试图用 RhinoMocks 断言调用了某个属性设置器。但它没有按预期工作。
以下简化示例说明了该问题。
考虑这个接口:
public interface IMyInterface
{
string SomeProperty { get; set; }
}
现在考虑以下代码:
var mock = MockRepository.GenerateStub<IMyInterface>();
mock.SomeProperty = "abc";
mock.AssertWasCalled(x => x.SomeProperty = Arg<string>.Is.Anything);
我期待最后一行的断言会毫无问题地通过。但是,它抛出了一条ExpectationViolationException
消息:
“IMyInterface.set_SomeProperty(anything); 预期 #1,实际 #0。”
我不明白为什么会发生这种情况。有人可以帮忙吗?