0
代碼被嘲笑看起來是這樣的:如何設置moq模擬來引發界面實現中定義的事件,而不是界面本身?
class Foo : IBar
{
public virtual event EventHandler FooEventHandler;
void FooMethod()
{
// blah, blah, blah...
}
void IBar.BarMethod()
{
this.FooEventHandler?.Invoke(this, new EventArgs());
}
}
interface IBar
{
void BarMethod();
}
我想嘲笑富及其實施伊巴爾的,這樣我可以測試它交給主題和斷言。要求告訴我,我不允許將事件處理程序放在IBar界面上,所以the explanation behind this link似乎不適用於我。