MockMethodCalledEventHandler Delegate

Typemock Isolator Developer Guide
Event that is fired after a mocked method is called and after validation is performed

Namespace:  TypeMock
Assembly:  TypeMock (in TypeMock.dll) Version: 9.3.6.0 (9.3.6.0)
Syntax

public delegate void MockMethodCalledEventHandler(
	Object sender,
	MockMethodCallEventArgs e
)

Parameters

sender
Type: SystemObject
The Mocked Object or null is the method called is static
e
Type: TypeMockMockMethodCallEventArgs
Event Method
Remarks

The following example will setup Typemock Isolator to call SuccessEvent after each call to a mocked method.
Examples

// This will be called when a mocked method is called
private void SuccessEvent(object sender,MockMethodCallEventArgs e) 
{
    Assert.AreEqual(typeof(TestedClass),e.CalledType);
    Assert.AreEqual("getVar",e.CalledMethodName);
    Assert.AreEqual(0,e.SentArguments.Length);
    Assert.AreEqual(0,e.ExpectedArguments.Length);
    Assert.AreEqual(false,e.WillThrowException);
    Assert.AreEqual(null,e.Exception);
    Assert.AreEqual(5,e.ReturnValue);
    Assert.AreEqual(true,e.HasPassedValidation);
}
[Test]
public void SimpleEventSuccess() 
{
    Mock mock = MockManager.Mock(typeof(TestedClass),false);
    TestedClass t = new TestedClass();

    mock.ExpectAndReturn("getVar",5);
    // set event listener
    mock.MockMethodCalled += new MockMethodCalledEventHandler(SuccessEvent);
    // the event will be called
    Assert.AreEqual(5,t.getVar());
    mock.Verify();
}
To set an event per method see IMethodSettings and Mock.MethodSettings(String) To set a global event for a mocked type see Mock.MockMethodCalled
Note Note
When static methods are called events from ALL mocks of that type are triggered. So if a type is mocked for two instances, and both have AfterMock Events, both will be triggered after a static member of that type is called. This is because static methods are not associated with an instance.
See Also

Reference