Unit Testing an ASP.NET Core MVC Web Application
Unit testing your ASP.NET Core MVC web application helps with improving its reliability. This course will teach you the ins and outs of unit testing with xUnit in detail.
What you'll learn
Unit testing improves the reliability of your application. In this course, Unit Testing an ASP.NET Core MVC Web Application, you’ll learn the ins and outs of unit testing with xUnit.net.
First, you’ll explore the Arrange, Act and Assert pattern by covering core unit testing scenarios like asserting on strings, collections and exceptions. Next, you’ll discover different approaches to set up your test context, work with data-driven tests and how to isolate tests.
Finally, you’ll learn different approaches to testing MVC-specific concerns like testing controllers, middleware and filters. At the end of the course you’ll learn how to integrate testing in your workflow and you’ll have the skills and knowledge needed to improve your ASP.NET Core MVC application reliability with unit testing.
Table of contents
- Coming Up 3m
- Positioning This Course 2m
- Course Prerequisites 1m
- Frameworks and Tooling 3m
- Demo - Introducing the Demo Scenario 6m
- The What, Why, and What Not of Unit Testing 3m
- Comparing Unit Tests, Integration Test, and Functional Tests 4m
- Demo - Adding a Unit Test Project 4m
- Demo - Writing Your First Unit Test 8m
- Naming Guidelines for Unit Tests 1m
- The Arrange, Act, and Assert Pattern 2m
- Comparing xUnit, NUnit, and MSTest 2m
- Summary 1m
- Coming Up 1m
- Learning about Assertions 4m
- Demo - Asserting on Booleans 5m
- Demo - Asserting on Strings 11m
- Demo - Asserting on Numeric Values 4m
- Demo - Asserting on Floating Points with Precision 2m
- Demo - Introducing a Repository Implementation with Test Data 4m
- Demo - Asserting on Arrays and Collection Content 11m
- Demo - Asserting Asynchronous Code 3m
- Demo - Asserting on Exceptions 6m
- Demo - Asserting on Events 3m
- Demo - Asserting on Object Types 3m
- Asserting on Private Methods 2m
- Summary 1m
- Coming Up 1m
- Setting up Tests and Sharing Test Context 3m
- Demo - Sharing Context with the Constructor and Dispose Approach 4m
- Demo - Sharing Context with the Class Fixture Approach 6m
- Demo - Sharing Context with the Collection Fixture Approach 5m
- Integrating Test Context With the ASP.NET Core Dependency Injection System 1m
- Demo - Integrating Test Context With the ASP.NET Core Dependency Injection System 5m
- Demo - Categorizing and Running Subsets of Tests 4m
- Demo - Skipping Tests 2m
- Demo - Adding Additional Test Output 3m
- Summary 2m
- Coming Up 1m
- Introducing Theories and Data-driven Tests 3m
- Demo - Testing a Theory with Inline Data 3m
- Demo - Testing a Theory with Member Data 6m
- Demo - Testing a Theory with Class Data 3m
- Demo - Testing a Theory With Strongly-typed Test Data 5m
- Getting Data From an External Source 1m
- Demo - Getting Data From an External Source 3m
- Summary 1m
- Coming Up 1m
- Investigating Test Isolation Approaches 5m
- Unit Testing with Entity Framework Core 3m
- Demo - Using SQLite In-memory Mode for Unit Testing 6m
- Unit Testing with HttpClient 2m
- Demo - Unit Testing with HttpClient 6m
- Introducing Moq 2m
- Demo - Creating and Using a Mock Object 6m
- Demo - Configuring Mock Object Return Values 8m
- Demo - Mocking an Interface 3m
- Demo - Mocking Async Code 2m
- Which Test Isolation Approach Should You Use? 2m
- Summary 1m
- Coming Up 1m
- Code Coverage and Deciding What to Unit Test 4m
- Introduction to Testing MVC Controllers 6m
- Demo - Verifying ViewResult when Testing 4m
- Demo - Verifying ViewModel Types when Testing 3m
- Demo - Verifying ViewModel Content when Testing 3m
- Demo - Combining Controller Action Asserts in One Unit Test and Testing Mapping Code 4m
- Demo - Dealing with AutoMapper Dependencies 4m
- Demo - Testing Validation and ModelState 4m
- Testing with HttpContext 2m
- Demo - Testing with HttpContext and TempData 5m
- Demo - Testing with HttpContext.Session 5m
- Demo - Testing with HttpContext.Features 5m
- Demo - Testing with HttpContext.User 7m
- Demo - Testing with HttpClient Calls 10m
- Summary 1m
- Coming Up 1m
- Demo - Running Tests With the CLI 4m
- Test Runners Versus Test Frameworks 4m
- Running Tests in Parallel 1m
- Demo - Parallelism in Test Frameworks 5m
- Demo - Parallelism in Test Runners 4m
- Running Tests Against Multiple Target Frameworks 1m
- Demo - Running Tests Against Multiple Target Frameworks 2m
- Integrating Unit Tests in Your CI/CD Pipeline 2m
- Demo - Integrating Unit Tests in Your CI/CD Pipeline 3m
- Summary 1m