IMockControlAnonymousMethodOf Method

Typemock Isolator Developer Guide
Use to mock all anonymous methods that are called from within a method

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

string AnonymousMethodOf(
	string calledFromMethod
)

Parameters

calledFromMethod
Type: SystemString
Method from which the anonymous method is called

Return Value

Type: String
Anonymous Method Mock Name
Examples

Assuming that we have this code
C#
public void DoSomething()
{
    button1.Click += delegate
     {
         MessageBox.Show("Click!");
     };
} 
public void FireClick()
{
    button1.PerformClick();
}
We can Mock the button1.Click Anonymous Method as follows:
C#
[Test] 
public void AnonymousTest()
{
     // Mock TestedClass 
     Mock mock = MockManager.Mock(typeof(TestedClass)); 
     // set up our expectations for anonymous method called in DoSomething
     // check that the delegate will be called without displaying the message box 
     mock.ExpectCall(mock.AnonymousMethod("DoSomething"));

     // create the instances
     TestedClass tested = new TestedClass();
     // Test the code 
     tested.DoSomething();
     tested.FireClick();
     // Verify that all calls were made (This can be done in the [Teardown]) 
     MockManager.Verify();
}
See Also

Reference