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
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(); }
![]() |
---|
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