Moq - mock.Raise should raise event in tested unit without having a Setup

后端 未结 2 2030
傲寒
傲寒 2020-12-29 19:01

I have a presenter class, that attaches an event of the injected view. Now I would like to test the presenter reacting on correctly on the event.

This is the view in

2条回答
  •  醉话见心
    2020-12-29 19:33

    Don't you need to pass the argument? Your event signature is EventHandler, which is
    (object sender, EventArgs e).

    this.mockView.Raise(mock => mock.MyEvent += null, new EventArgs());
    

    I've never used the overload you've specified here... it doesn't seem correct, though.

提交回复
热议问题