Bad to Good: Techniques for Refactoring an Existing Codebase to a Better, More Testable Design

We all know how important it is to write testable code, but sometimes it is hard to know where to start.  This is especially when you are dealing with an existing codebase that wasn't designed with testability in mind.  Maybe you aren't quite sure how to refactor the code to a better design, how to implement dependency injection or how to use a mocking framework.  If so, this session is for you.

In a play by play style, we'll refactor an existing piece of code to a better, more testable design.  We'll show how introducing interfaces at the appropriate spots allows you to inject dependencies and opens your code up to using a mocking framework.  We'll then demonstrate some of the different uses of Moq, one of the most popular mocking frameworks and how it can help you test different aspects of your code.  Finally, we'll show how you can abstract away some system dependencies that commonly get in the way of writing unit tests, like dependencies on DateTime.  When finished, you will have a clearer understanding about how you can safely refactor your existing code base to include unit tests and be more comfortable with some of the most important building blocks of modern software development.
Beginner : refactoring testable code dependencyinjection mocking