【发布时间】:2011-05-11 10:57:34
【问题描述】:
每当使用 Rhino Mocks 设置某个属性时,我想在存根对象上引发一个事件。例如
public interface IFoo
{
int CurrentValue { get; set; }
event EventHandler CurrentValueChanged;
}
设置CurrentValue 将引发CurrentValueChanged 事件
我尝试了myStub.Expect(x => x.CurrentValue).WhenCalled(y => myStub.Raise...,但它不起作用,因为该属性是可设置的,并且它说我正在对已定义为使用 PropertyBehaviour 的属性设置期望。我也知道这是对WhenCalled 的滥用,我对此并不满意。
实现这一目标的正确方法是什么?
【问题讨论】:
标签: c# rhino-mocks