Showing posts from October, 2014

Introduction to System.IO.Abstractions

One of the most important things about writing testable code is the elimination or reduction of dependencies between objects or components. Why is this important? Simply put, when one object depends on another (which in turn may rely on another, and so on) you can't truly say, "This is exactly how this works, I can guarantee consistent results, and I can do it quickly." Take, for example, testing a piece of code that interacts with a database. An all-too-common approach is to create a SQL query that sets the database to some known state, and then run that query prior to your test. That may work but, if you're working against a database with which others may be interacting, there's always the chance that between running your SQL query and executing your test that the state of the database has changed. Going a step further, there's the question of manageability. Are you really willing to write and maintain dozens of these setup queries as your project g