Typemock-Isolator has a little know Decorator feature that allows developers to simply add capabilities to their test framework (all test framework).
Using this feature Typemock-Isolator creates the [VerifyMocks] decorator that automatically verifies the mocks at the end of your tests.
To create a custom decorator simply extend the DecoratorAttribute and implement the Execute method.
public override object Execute()
{
// Trace start of method
Console.WriteLine(“Entering Method:”+
OriginalMethod.ToString());
// Execute the original method
return base.CallDecoratedMethod();
}
To support multiple decorators on the same test method, Typemock-Isolator makes sure that even if a developer forgot to call CallDecoratedMethod() the test method will still run. This is done by calling the decorated method if it wasn’t explicitly called.
We discovered that some Decorator implementers want more control and need to explicitly make sure that the test method was NOT called.
A new API was added in version 4.2 to do just that.
Once this is called (inside Execute), the decorator mechanism will not call the test method.
Of course if there is another decorator on the test method that calls CallDecoratedMethod() the test method will be executed.