December 2001
Intermediate to advanced
416 pages
8h 16m
English
In the introduction to the delegate type in Section 2.12, there is a brief discussion of a testHarness class. testHarness maintains a static delegate member in which other classes register test functions they wish executed. It looks like this:
public delegate void Action();
public class testHarness
{
static private Action theAction;
static public Action Tester
{ get{ return theAction; }
set{ theAction = value; }}
static private void reSet() { theAction = null; }
static public int count()
{ return theAction != null
? theAction.GetInvocationList().Length : 0; }
// ...
}
By convention, a class wishing to register one or more member functions with Tester does so within the static constructor of the class—for ...
Read now
Unlock full access