IMethodSettingsMockMethodCalled Event

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

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

event MockMethodCalledEventHandler MockMethodCalled

Value

Type: TypeMockMockMethodCalledEventHandler
Remarks

To set an event for all calls see Mock.MockMethodCalled
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.MethodSettings("getVar").MockMethodCalled += new MockMethodCalledEventHandler(SuccessEvent);
    // the event will be called
    Assert.AreEqual(5,t.getVar());
    mock.Verify();
}
See Also

Reference