• Courses
  • TutorialsFree
  • Learning Paths
  • Blogs
  • Authors
  • Dometrain Pro
  • Shopping Basket

    Your basket is empty

  • Business Portal
  • From Zero to Hero: Unit testing in C#

    Mastering the bedrock of testing

    About This Course

    There is a reason why Unit Testing is the bottom layer in the testing pyramid. You can only build a solid testing suite on a robust foundation. Nothing is more reassuring when working on a codebase than knowing that if you accidentally break something, a test will alert you, saving you hundreds to thousands or even hundreds of thousands of dollars in potential customer impact. In this course, Nick will teach you how to write modern unit tests for your code bases so you are always confident in change. Oh, and if you don't know what the testing pyramid is, don't worry. You will after you take this course.

    Course Curriculum

    3h 38m 8 sections
    Welcome
    2:21 Free preview
    What will you learn in this course?
    3:55 Free preview
    Who is this course for and prerequisites
    1:49 Free preview
    Different types of testing
    7:15
    What is unit testing and why it's important?
    1:30
    The testing pyramid
    1:57
    Why should you write unit tests?
    3:12
    The 3 core unit testing concepts
    1:57
    Why xUnit?
    0:57
    Writing your first unit test
    6:23
    Structuring your solution
    2:50
    Naming in unit tests
    3:32
    Arrange, Act, Assert
    2:09
    xUnit's test execution model
    2:54
    Test Setup and Teardown
    5:46
    Parameterizing tests
    3:18
    Ignoring tests
    1:23
    Your turn to practice (Project source under the video)
    1:04
    My answer to the exercise
    0:40
    Section recap
    0:48
    Writing fluent assertions
    3:19
    Testing strings
    2:58
    Testing numbers
    2:00
    Testing dates
    1:37
    Testing objects
    3:32
    Testing enumerables
    3:32
    Testing methods that throw Exceptions
    2:23
    Testing for raised events
    1:29
    Testing private methods (members)
    1:24
    Testing internal methods (members)
    3:01
    Section recap
    0:26
    The problem with dependencies
    3:54
    Dependency injection to the rescue
    2:55
    What are fakes?
    3:03
    What is mocking?
    6:11
    Moq vs NSubstitute
    2:35
    Section recap
    0:53
    The project we will be adding unit tests to
    3:38
    The scope of our testing
    3:59
    Testing the application layer
    22:35
    Exercise: Testing the rest of the application layer (Project source under the video)
    1:24
    Exercise answer: Testing the rest of the application layer
    15:21
    But was all that necessary?
    2:10
    Testing the data layer
    1:13
    Testing the API layer
    9:51
    Exercise: Testing the rest of the API layer (Project source under the video)
    1:03
    Exercise answer: Testing the rest of the API layer
    13:19
    Section recap
    0:42
    Observing the default test execution behavior
    2:41
    The Class Fixture
    4:12
    The Collection Fixture
    5:04
    Running test in parallel
    5:43
    Advanced parameterization
    4:53
    Setting test execution timeouts
    1:17
    Testing Date and Time
    5:19
    Continuous testing
    1:55
    What is code coverage?
    2:57
    Measuring code coverage
    6:35
    Section recap
    0:48
    Course conclusion
    0:37

    Meet Your Instructor

    Nick Chapsas

    Nick Chapsas

    Nick Chapsas is a .NET & C# content creator, educator and a Microsoft MVP for Developer Technologies with years of experience in Software Engineering and Engineering Management.

    He has worked for some of the biggest companies in the world, building systems that served millions of users and tens of thousands of requests per second.

    Nick creates free content on YouTube and is the host of the Keep Coding Podcast.

    View all courses by Nick Chapsas

    What's New

    What's new in C# 14
    blog

    What's new in C# 14

    This guide covers every new C# 14 feature, explains its benefits, and provides practical code examples to help you navigate how you can use them.

    Learn More
    Let's Build It: AI Chatbot with RAG in .NET Using Your Data
    course

    Let's Build It: AI Chatbot with RAG in .NET Using Your Data

    Build a Retrieval-Augmented Generation (RAG) chatbot that can answer questions using your data.

    Learn More
    Working with Large Language Models
    tutorial

    Working with Large Language Models

    Learn how to work with Large Language Models (LLMs). Understand the fundamentals of how GPT works, the transformer architecture, and master prompt engineering techniques to build AI agents.

    Learn More
    From Zero to Hero: SignalR in .NET
    course

    From Zero to Hero: SignalR in .NET

    Enable enterprise-grade real-time communication for your web apps with SignalR.

    Learn More
    Deep Dive: Solution Architecture
    course

    Deep Dive: Solution Architecture

    Master solution architecture and turn business needs into scalable, maintainable systems.

    Learn More
    Migrating: ASP.NET Web APIs to ASP.NET Core
    course

    Migrating: ASP.NET Web APIs to ASP.NET Core

    A step-by-step process to migrate ASP.NET Web APIs from .NET Framework to ASP.NET Core.

    Learn More
    Getting Started: Caching in .NET
    course

    Getting Started: Caching in .NET

    Let's make the hardest thing in programming easy for .NET software engineers.

    Learn More
    From Zero to Hero: Testing with xUnit in C#
    course

    From Zero to Hero: Testing with xUnit in C#

    Learn how to test any codebase in .NET with the latest version of xUnit, the industry-standard testing library.

    Learn More
    Create a ChatGPT Console AI Chatbot in C#
    blog

    Create a ChatGPT Console AI Chatbot in C#

    This walkthrough is your hands-on entry point to create a basic C# console application that talks to ChatGPT using the OpenAI API.

    Learn More