I have the following code which i am using to try and mock an event:
public class ClassWithEvent
{
public event EventHandler<EventArgs> MyEvent;
}
[TestMethod, Isolated]
public void MockMyEvent()
{
var myClass = Isolate.Fake.Instance<ClassWithEvent>();
bool hasBeenCalled = false;
myClass.MyEvent += (sender, args) => { hasBeenCalled = true; };
Isolate.Invoke.Event(() => myClass.MyEvent += null, EventArgs.Empty);
Assert.IsTrue(hasBeenCalled);
}
When run, the test fails due to a TypeMockException being thrown:
TypeMock.TypeMockException :
*** Event expects arguments of types {Object, EventArgs} use Isolate.Invoke.Event(()=>fake.Event+=null,arg1,arg2...);
Could not invoke with arguments of types {EventArgs}
I've looked over and over this and must be missing something.
Any help would be great :)