Event-driven .NET: How to unit test code that depends on an event

Testing code with a dependency on an event can be tricky. You may be tempted to directly unit test the event handling method. However, that doesn’t prove that code under test is listening for the event. It’s better to really fire the event, and then test side effects of the event handling method. Firing the … Read more Event-driven .NET: How to unit test code that depends on an event

TDD by Example: How to add tests against code that doesn’t exist yet

I personally use Test-Driven Development (TDD) on a daily basis because it allows me to focus on solving one test case at a time in the simplest way possible, and then refactor with the safety net of unit tests. It’s a bottom-up approach, and is a natural fit for my coding principles (unit test, refactor, … Read more TDD by Example: How to add tests against code that doesn’t exist yet

The bottom-up principles of unit testing, refactoring, and pragmatism

After years of coding and reading dev books I’ve distilled my coding principles down into these three simple principles: unit testing refactoring pragmatism I write these down in my notebook and repeat them to myself on a daily basis. These are my coding principles. It’s important to know your principles. Your principles act as a … Read more The bottom-up principles of unit testing, refactoring, and pragmatism