About the course
This intensive 3-day hands-on training course is specifically designed for .NET developers who want to significantly improve their code quality, design, and maintainability by adopting Test Driven Development (TDD). Moving beyond the pitfalls of traditional testing approaches that often occur late in the development cycle, TDD advocates writing tests before the code, leading to tighter feedback loops, clearer design, and more robust software from the outset. The course explores why testing is crucial, the specific problems TDD is designed to solve, and contrasts it with traditional methods through practical case studies, focusing on quality assurance within the .NET software development process.
A core focus is understanding how TDD promotes and integrates with principles of clean code and design. We will examine the SOLID principles (Single Responsibility, Open/Closed, Liskov Substitution, Interface Segregation, Dependency Inversion) in detail, demonstrating how applying TDD naturally encourages designs that are more flexible, maintainable, and testable. Participants will gain a deep understanding of Unit Testing concepts, explore the TDD cycle (Red-Green-Refactor), learn to use test doubles (Stubs, Fakes, Mocks, Spies), and receive an overview of Behaviour Driven Development (BDD). The training also provides practical introductions to popular .NET automated testing tools (MSTest, nUnit, xUnit) and essential mocking frameworks (Moq).
Through extensive, real-life coding examples and hands-on exercises using C# and .NET, attendees will gain practical experience applying TDD techniques to build working code, refactor effectively, and write high-quality unit tests. Discussions will cover the tangible benefits and associated costs of investing in automated testing and code reviewing within an Agile context, highlighting how TDD goes hand-in-hand with frameworks like Scrum. By the end of the course, participants will be equipped with the knowledge and skills to successfully implement TDD effectively in their own .NET projects, leading to more reliable and higher-quality codebases.
Instructor-led online and in-house face-to-face options are available - as part of a wider customised training programme, or as a standalone workshop, on-site at your offices or at one of many flexible meeting spaces in the UK and around the World.
-
- Understand the fundamental need for software testing, the problems with traditional testing approaches, and how Test Driven Development (TDD) effectively addresses these issues.
- Apply the SOLID principles (Single Responsibility, Open/Closed, Liskov Substitution, Interface Segregation, Dependency Inversion)1 to design cleaner, more maintainable, and testable .NET code.
- Understand the core concepts of Unit Testing, Test Driven Development (TDD), and Behaviour Driven Development (BDD).
- Implement the TDD cycle (Red-Green-Refactor) as a practical development workflow to drive code development and design.
- Effectively use test doubles (Stubs, Fakes, Mocks, Spies) to isolate units of code and manage dependencies during testing.
- Utilise popular .NET automated testing tools (MSTest, nUnit, xUnit) and mocking frameworks (Moq) to write unit tests effectively.
- Apply TDD techniques through hands-on coding examples to build working features incrementally, informed by tests and focusing on code quality.
- Understand the benefits and costs associated with automated testing and code reviewing in a software development lifecycle and how TDD impacts these.
- Explain the relationship between TDD, Agile methodologies, and continuous quality assurance practices.
-
This 3-day intensive hands-on training course is designed for software developers working with the .NET platform who want to significantly improve their code quality, design practices, and testability by adopting Test Driven Development (TDD). It is ideal for:
.NET Developers seeking to learn and implement TDD as a core development practice.
Developers wanting to write better, more maintainable, and robust code.
Teams looking to improve their software quality assurance practices at the development level.
Developers interested in understanding Unit Testing, Mocking, and their practical integration with TDD.
Anyone wanting to deepen their understanding of clean code and design principles (SOLID) and how testing methodologies support them.
-
Participants should have attended our .NET with C# training course or have equivalent experience:
Experience developing applications using the C# programming language and the .NET framework is essential.
Familiarity with object-oriented programming (OOP) concepts.
Experience using an Integrated Development Environment (IDE) like Visual Studio or VS Code with .NET support.
Basic understanding of software testing concepts is helpful but not strictly required, as the course covers the fundamentals.
-
This TDD with .NET course is available for private / custom delivery for your team - as an in-house face-to-face workshop at your location of choice, or as online instructor-led training via MS Teams (or your own preferred platform).
Get in touch to find out how we can deliver tailored training which focuses on your project requirements and learning goals.
-
Why Test?
The fundamental need for software testing in modern development.
Problems with traditional testing approaches (testing late, cost, quality issues).
The benefits of shifting testing left.
Testing case study: Illustrating the impact of testing practices on project outcomes.
The benefits and costs of code reviewing.
The benefits and costs of automated testing.
Clean, S.O.L.I.D. code - Part 1
Introduction to code quality: WET (Write Everything Twice) vs. DRY (Don't Repeat Yourself) code.
What is Clean Code?
Introduction to the S.O.L.I.D. principles of object-oriented design.
The Single Responsibility Principle (SRP).
The Open / Closed Principle (OCP).
The Liskov Substitution Principle (LSP).
The Interface Segregation Principle (ISP).
The Dependency Inversion Principle (DIP).
Discussion: Why are these principles important for testability?
Automated Testing Overview
Introduction to the different types of automated testing (Unit, Integration, End-to-End - focusing on Unit Testing for this course).
Introduction to automated testing tools in the .NET ecosystem.
Overview of Microsoft Testing Framework (MSTest).
Introduction to nUnit.
Introduction to xUnit (often preferred for TDD).
Introduction to Moq (or other mocking libraries).
Lab: Setting up a unit testing project and writing your first simple test using xUnit.
Clean, S.O.L.I.D. code - Part 2
Deeper dive into the Dependency inversion Principle (DIP).
Introduction to Dependency Injection (DI) as a technique to achieve DIP.
Understanding Inversion of Control (IoC) and the role of IoC Containers.
SOLID design example: Applying SOLID principles and seeing how they relate to testability.
Hands-on Exercise: Refactoring code to apply SOLID principles and enable testability.
Test Driven Development (TDD) - Concepts
What is TDD? Understanding the Red-Green-Refactor cycle.
The principles and benefits of the TDD workflow.
Unit Testing in the context of TDD (testing the smallest testable parts).
Behaviour Driven Development (BDD) - Overview and its relationship with TDD as a communication/discovery practice.
TDD in the project lifecycle and how it integrates with Agile methodologies.
Discussion: Contrasting TDD workflow with traditional "write code then test" approaches.
Test Doubles
The need for Test Doubles when isolating code for unit tests.
Understanding the different types of Test Doubles: Stubs, Fakes, Mocks & Spies.
When to use each type of test double.
Practical examples of using test doubles in C#.
Lab: Writing unit tests that require the use of simple Stubs and Fakes.
TDD Examples - Hands-on Application
Applying the Red-Green-Refactor cycle through guided coding examples.
Writing a failing test (Red).
Writing the minimum code to make the test pass (Green).
Refactoring the code and tests while keeping the tests Green.
Building features incrementally using TDD.
Hands-on Exercise: Apply the TDD cycle to build a small feature or component.
Automated Testing Tools - Deep Dive
Practical usage of .NET testing frameworks introduced earlier.
xUnit examples: Writing tests, using assertions, structuring test classes.
nUnit examples: Writing tests, using assertions, structuring test classes.
MSTest examples: Writing tests, using assertions, structuring test classes (Comparison of frameworks).
Introduction to Moq: Setting up mock objects and verifying interactions.
Moq examples: Using Moq to create and configure mocks for dependencies.
Hands-on Exercise: Write unit tests using xUnit, nUnit, or MSTest and integrate Moq to mock dependencies.
Summary and next steps
Review of key concepts: TDD cycle, SOLID, Test Doubles, Tools.
Discussion on integrating TDD into team workflows.
Q&A and next steps.
-
.NET Documentation (Unit Testing): Official Microsoft documentation on setting up and running unit tests with various frameworks.
xUnit.net Documentation: Comprehensive documentation for the xUnit testing framework.
NUnit Documentation: Documentation for the NUnit testing framework.
Moq Documentation: Documentation and examples for the Moq mocking library.
"Test Driven Development: By Example" Look for this classic, foundational book by Kent Beck explaining the TDD process.
"Clean Code: A Handbook of Agile Software Craftsmanship" by Robert C. Martin (Uncle Bob): A highly influential book on writing maintainable code, covering principles that align well with TDD.
Trusted by