Monthly Archives: November 2011

Unit-testing Asynchronous Events

Once in the realm of asynchronous calls, we have no guarantee of which thread or precisely when an event handler might be called, which makes testing asynchronous events that much more difficult. As a result it makes the test shown … Continue reading

Posted in C#, Multi-threading, NUnit, TDD | Leave a comment

Unit-testing Synchronous Events

It’s easy to forget (or choose not to) test events when you’re writing test-driven code, but they mustn’t be ignored because client code which subscribes to your events will depend on them firing under the correct circumstances. And without tests … Continue reading

Posted in C#, NUnit, TDD | Leave a comment

Implementing IDisposable

There’s a bit more to implementing the IDisposable interface than just one Dispose method. For non-deterministic finalization to work properly you need to implement the disposable pattern shown below, making sure to distinguish between whether cleanup is being done via … Continue reading

Posted in C# | Leave a comment