Having looked at the
Stock classes, let us now turn our attention to the
Event class. The
Event class is very simple: receivers can register with the event to be notified when the event occurs. When the event fires, all the receivers are notified of the event.
A more detailed description is as follows:
Writing tests for the
connect method is fairly straightforward—we just need to check that the receivers are being stored properly. But, how do we write the tests for the fire method? This method does not change any state or store any value that we can assert on. The main responsibility of this method is to call other methods. How do we test that this is being done correctly?
This is where mock objects come...