Sorry again. I try to mock the event argument object and fire it like the code below ... but it still not mock. Is there somthing wrong with my code?
MyEvent eventArg;
public void FireEventWithinAMockedMethof()
{
// mock event and save handle
MockObject eventMock = MockManager.MockObject(typeof(MyEvent));
eventMock.ExpectGetAlways("Properties","Value");
eventArg = (MyEvent)eventMock.object;
handle = eventMock.ExpectAddEvent("TheEvent");
// mock a class and use a Dynamic Return Value
Mock anotherMock = MockManager.Mock(typeof(OtherType));
anotherMock.ExpectAndReturn("DoSomething", new DynamicReturnValue(FireIt));
// continue test -> when DoSomething is called TheEvent will be fired
}
// the delegate called when DoSomething is called
public object FireIt(object[] parameters, object that)
{
handle.Fire(this, eventArg);
return true;
}