I have an interface like that:
interface IView
{
event EventHandler<MyEventArgs> SomeEvent;
}
and a class
class Presenter
{
private IView _view;
public Presenter(IView view)
{
view.SomeEvent += MyEventHandler;
}
private MyEventHandler(...)
}
I'm trying to test this stuff using RhinoMocks and MockRepository.VerifyAll() throws the following exception
Rhino.Mocks.Exceptions.ExpectationViolationException: IView.add_SomeEvent(System.EventHandler`1[MyEventArgs]); Expected #1, Actual #0.
So the question:
How to add the expectation that event is subscribed?
Sorry guys, I have found what I was doing wrong:
_viewMock.Expect(x => x.SomeEvent+= Arg<EventHandler<MyEventArgs>>.Is.Anything);
Presenter p = new Presenter(_viewMock);
_mockRepository.ReplayAll();
...
_mockRepository.VerifyAll();
I had to ReplayAll before I created new instance of Presenter.
Thanks.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With