Test Driven Development (TDD) with C#

Tools, patterns and techniques for writing well-designed and testable code

This Test-Driven Development in C# course presents a number of modern practices for developing code based on an iterative and incremental development lifecycle. Agility and predictability are two.

Course Code
2 Days
Delivery Style
Course Type
Private Only
Max Delegates
Available as Nutshell

Book your team training at your premises

  • Date
  • Venue
  • Cost
  • More info
Purpose of this course

The training course combines lectures with practical exercises that help the delegates to put what they have learned on the training course into practice.  The exercises specifically build on what has been recently taught and are built up as the training course progresses.

Who is this course for

The course is suitable for software developers experienced in C# and familiar with object-oriented principles and practices. Any previous exposure to NUnit or agile development concepts is.

You will learn how to
  • Appreciate the benefits of a continuous and iterative approach to design and delivery
  • Recognise the purpose and practice of refactoring 
  • Build up a set of unit tests in NUnit 2 and / or MSTest
  • Understand the consequences of dependency management on testing and code quality
  • Work with mocks using RhinoMock
Benefits for your organisation

TDD offers a wealth of benefits to your organisation, it can cut development costs for example.  Shorten the development Time to Market and increase the programmer’s productivity.  As well as encouraging the writing of quality code.

Benefits for you as an individual

TDD has many benefits but it can be hard to learn alone.  This course will help you write effective, organized and neat code that works.  It will teach you how to shorten the development feedback time and provide proof that your software code works as intended.

Agile Development Microprocess

Traditional versus agile development processes
Iterative and incremental development
Informal and continuous design
The role of refactoring
Refactoring versus other code changes
Extreme Programming
Test-Driven Development

Testing in Principle

Traditional view and reality of testing
Driving development through testing
Testing early, often and automatically
Testing versus debugging
White-box versus black-box testing
Functional versus operational testing

Basic Unit Testing in Practice

Test plans versus test code
Use of Debug.Assert
Testing at the interface
Testing the simplest things first
Testing incrementally
Testing correctness of failure

Overview of NUnit and MSTest

NUnit and the xUnit family
Test fixtures and test methods
The role of attributes in NUnit's design
Assertion methods
Testing correctness of exceptions
Defining common fixture code
Mocking with RhinoMock and MOQ

Test-Writing Techniques

Red, green, refactor
None to one to many
Faking it
Telling the truth
Isolated and short tests
Refactor common fixture code
Declare, prepare, assert
Test by method, state or scenario
Custom assertions

Common Refactorings

Renaming variables, methods, classes and packages
Restructuring class hierarchies by extracting interfaces, superclasses and subclasses
Partitioning classes by extracting classes and methods
Changing private representation

Decoupling Techniques

Unmanaged dependencies
Test-driven decoupling
Reorganising packages
Eliminating cyclic dependencies
Mock objects
Eliminating Singletons, statics and other globals
Testing I/O


Delegates should have experience in C# programming

About the Lead Trainer

Our Agile ‘evangelist’, it’s safe to say that Howie lives and breathes an Agile life. Never to be seen without a pack of post it notes and a sharpie pen in his back pocket, Howie coaches and trains our customers by sharing his passion for more efficient ways of working.