Hello,
I'm trying to mock an interface's events like the following:
[TestMethod]
public void NeedingDataFiresEvents()
{
//Arrange
var service = MockRepository.GenerateMock<IService>();
service.Expect(i => i.GetValue()).Return(5);
var view = MockRepository.GenerateMock<ILogView>();
view.NeedData += null;
LastCall.IgnoreArguments();
var evt = LastCall.GetEventRaiser();
var presenter = new LogPresenter(view, service);
var args = new DataEventArgs();
//Act
evt.Raise(view, args);
//Assert
Assert.AreEqual(1, args.Results.Count());
}
The error I'm getting is: System.InvalidOperationException: Invalid call, the last call has been used or no call has been made (make sure that you are calling a virtual (C#) / Overridable (VB) method).
I'm not sure why... what am I doing wrong? What would I apply virtual too, if I'm not actually instantiating the view... Something in the presenter?