I have a method something like this:
public Something MyMethod()
{
Setup();
Do something useful...
TearDown();
return something;
}
The Setup and TearDown methods are in the base class.
The problem I'm having is that I have to write this type of method over and over again with the Setup() and TearDown() method calls.
EDIT: The tricky part of this method is that "Do something useful..." is specific to this method only. This part is different for every method I create.
Also, I can have MyMethod2, MyMethod3, in a single class. In all cases, I would like to run the setup and teardown
Is there an elegant way of doing this without having to write this every single time?
Perhaps I'm delusional, but is a way to add an attribute to the method and intercept the method call, so I can do stuff before and after the call?