Rhinos. How to add an event handler has been signed

I have an interface like this:

interface IView
{
     event EventHandler<MyEventArgs> SomeEvent;
}

and class

class Presenter
{
     private IView _view;
     public Presenter(IView view)
     {
         view.SomeEvent += MyEventHandler;
     }

     private MyEventHandler(...)
}

I am trying to check this stuff with 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 is:

How to add the expectation that the event is signed?

+5
source share
1 answer

Sorry guys, I found what I'm doing wrong:

_viewMock.Expect(x => x.SomeEvent+= Arg<EventHandler<MyEventArgs>>.Is.Anything); 

Presenter p = new Presenter(_viewMock);

_mockRepository.ReplayAll();

...

_mockRepository.VerifyAll();

I had to replay ALL before I created a new instance of Presenter.

Thank.

+4
source

All Articles