Test Driven Development in .NET

All developers want to build good quality software but not all developers test their software as they go along. Why not? A common explanation is I do not have time to write tests!. The more pressure they feel, the fewer tests they write. This leads to less accurate and stable code, less productivity, less confidence and, ultimately, more pressure. It is a vicious cycle. This course is designed to help you break out of the cycle by embracing unit-testing and, in particular, test-driven development. We will introduce the techniques and the tools necessary to prove your code as you go along. The course can be run using C# or VB.

What you will learn:

  • Understanding TDD principles
  • Writing effective unit tests
  • Refactoring code
  • Implementing Inversion of Control (IoC)
  • Using mocking frameworks

Prerequisites:

At least 6 months experience in C# or VB

Course outline:

Overview of Test-Driven Development

  • Test, code, refactor, repeat
  • The benefits of TDD
  • The process of TDD
  • Tools available

Unit testing basics

  • Getting started with unit testing using Test Explorer in Visual Studio
  • Structure of a unit test
  • Using assertions
  • Dealing with exceptions
  • Using MS Test Extensions
  • Additional techniques

Additional testing techniques

  • Using NUnit
  • NUnit constraint syntax
  • NUnit data-driven design
  • Code coverage

Refactoring

  • The need for refactoring
  • Types of refactoring
  • Guidelines and recommendations
  • Creating layered designs
  • Using dependency injection

Inversion of control

  • Overview of IoC
  • Using factories
  • Using IoC containers
  • Using a configuration file

Test doubles and mocking

  • Principles and techniques
  • Getting started with RhinoMocks
  • Working with mock objects
  • Additional techniques and considerations

Testing legacy code

  • Where to start
  • Adding new behaviour
  • Finding change points
  • Breaking dependencies

Andy Olsen - author of the course

Andy is a freelance consultant and instructor based in the UK, working mostly in the City of London and Oxford. Andy has been working with .NET since the Beta 1 days and has extensive experience in many facets of .NET development including WCF, WPF, WF, ASP.NET MVC Web development, and mobile applications. Andy has designed and written many Microsoft Official Curriculum courses in the last decade, and has been engaged as author and technical reviewer with Apress on some of their biggest selling books.

Other relevant courses

23. April
4 days
Classroom Virtual On Demand Guaranteed to run