It's our 2nd Birthday! 🎉
Everything 40% off with code EARLYBDAY40! (Excl. Team and VS Pro)
00
Days
00
Hrs
00
Min
00
Sec
Get 40% off anything!

From Zero to Hero: Writing Testable Code in C#

Learn how to write testable C# code using modern coding practices

Everyone knows by now that testing is a mandatory part of software development, but it's very easy to make it hard for yourself to write tests for the code you just wrote. Writing testable code is a craft practised by the most seasoned software engineers, and it is usually a sign of a clean codebase that uses modern practices. Nowadays, it is pretty easy to use AI coding assistants to write tests for you, but true engineers develop a deep understanding of how you can write testable code. In this course, Gui Ferreira will walk you through why writing testable code using C# is so important and show you step-by-step how you can learn this art and follow it for the code you write.

Curriculum

Welcome (01:32)

What will you learn in this course? (03:05)

Who is the course for and prerequisites (00:57)

The Cost of Untestable Code (05:49)

What makes Code "Testable Code" (08:53)

What is Unit Testing (02:52)

How to approach Testable Code (06:37)

Introduction (02:51)

Clear Inputs and Outputs (14:03)

Explicit Error Handling (11:18)

Separation of Construction and Logic (07:56)

Visible State Changes (05:38)

Exercise (03:09)

Section Recap (00:54)

Introduction (03:58)

Identifying and Extracting Responsibilities (10:09)

Dealing with Constructor Bloat (08:07)

Creating Effective Injection Points (13:34)

Injectable vs. Newable Objects (05:54)

Composition of Narrow Components (11:11)

Exercise (02:48)

Section Recap (01:24)

Introduction (04:58)

Working with Static Dependencies (09:13)

Breaking Dependency Chains (08:39)

Creating Abstractions for External Services (08:25)

Isolating Framework Code (06:31)

Exercise (01:46)

Section Recap (02:06)

Introduction (07:21)

Avoiding Test Interference (10:04)

Converting Static Dependencies to Testable Code (06:56)

Implementing Pure Functions (00:00)

Replacing Traditional Singletons (06:11)

Exercise (01:21)

Section Recap (01:33)

Introduction (01:12)

Writing Testable ASP.NET Core Controllers (15:08)

Designing Entity Framework Code for Testability (09:22)

Making Time-Dependent Code Testable (05:33)

Creating Testable External Dependencies (11:56)

Implementing Testable Authentication and Authorization (05:35)

Section Recap (02:30)

Conclusion (01:10)

Course Info

Level:
From Zero to Hero
Duration:
4h 30m
Rating (New):
star

Lifetime access

Add to Cart

Part of the bundle

From Zero to Hero: Testing Essentials Bundle in .NET Bundle thumbnail Get it for 20% off
Dometrain Pro

Want access to all of our courses? Subscribe to Dometrain Pro!

Try it for free!

About the Author

author_img

Gui Ferreira

Guilherme Ferreira, also known as Gui, is a Minimalist Software Craftsman, passionate about simplicity and continuous learning. Gui is a Microsoft MVP for Developer Technologies, a Tech Speaker, a YouTuber, and a .NET content creator. With over 15 years of experience in software development, Gui went from Startups to Tech Giants. Along his journey, he got to know several hats, including Software Engineer, Architect, CTO, and Developer Advocate, gathering a diverse and invaluable skill set.

More courses by Gui Ferreira