My latest Pluralsight course just went live a couple of days ago — Architecting an ASP.NET Core MVC Application for Unit Testability. I’ve been wanting to write this course for at least a couple of years now. I like to think of is as the missing modules from all my TFS and DevOps classes.
When I was writing my other courses, I kept running out of time. Well, that’s not 100% accurate. My courses were getting insanely long and I needed to cut content. The content that I reluctantly chose to cut? All the details of how to build an actually unit testable application. Well, I finally got around to writing a course that’s dedicated to just software architecture plus unit testing.
Now why does anyone need this course? Well, having worked with a lot of teams over the last decade or more, I kept finding that they usually didn’t write unit tests. Maybe they started out with good intentions and wrote some tests but they eventually stopped. Why? Because it got hard. Really hard. And for all the online demos and blog posts about how to write a unit test, that content mostly missed the point.
The hard part isn’t writing the test. The hard part is building your application so that it can be tested. That’s what the new course covers.
I hope you like it. Here’s the outline.
(BTW, if you’re looking for this content as a private course for your team or company, please drop me at line at firstname.lastname@example.org.)
Want to quickly and easily know if your app is working? You’ll need automated tests. This course will show you how to architect an ASP.NET Core app so that you can write great automated unit tests.
1 – What Should I Test?
- Overview / Why Write Tests?
- What Should You Test?
- Design for Testability
- Demo: Write Code Using Unit Tests
- Demo: Code Coverage
2 – Using Abstraction to Test the User Interface
- User Interface Testing and the MVC Design Pattern
- Thinking About Unit Testing ASP.NET MVC + Demo Overview
- Demo Part 1 of 3: Setting up the Unit Test and ASP.NET Code
- Demo Part 2 of 3: Creating the Model and ASP.NET Controller
- Demo Part 3 of 3: Unit Testing the Operators Drop-down List
- Demo: Unit Testing Adding Two Numbers in the Web Calculator
- Demo: Unit Testing an Error Case in the Web Calculator
- Dependency Injection in an ASP.NET Controller
- Demo: Refactor the Controller and Unit Tests to Use Dependency Injection
- “Mocks, Stubs, Fakes, and Dependency Injection”
- Demo Part 1 of 2: Using a Mock to Unit Test an ASP.NET Controller
- Demo Part 2 of 2: Using a Mock to Do Behavior Verification
3 – Overthrowing the Tyranny of the Database with Repository and Adapter Patterns
- Databases Are Hard to Test. So What Do You Do About It?
- The Object-relational Impedance Mismatch Problem
- Designing and Implementing Repositories
- EF Core and the Adapter Pattern: It’s the Right Thing to Do and the Tasty Way to Do It
- The Design of the Sample Application
- Demo: Implementing the Adapter Pattern
- Demo Part 1 of 2: Reusable EF Core Repository Classes
- Demo Part 2 of 2: Integration Testing EF Core Repositories
- Demo: Implementing the Service Layer Pattern
- Demo Part 1 of 3: Unit Test Structure for Service Layer Business Logic
- Demo Part 2 of 3: Writing Service Layer Business Logic Unit Tests
- Demo Part 3 of 3: Using an In-memory Repository for Unit Testing
4 – Leveraging the Strategy Pattern to Encapsulate Business Logic
- “Validation, ASP.NET’s ModelState.IsValid, and the Strategy Pattern”
- Validation with System.ComponentModel.DataAnnotations
- Demo Part 1 of 2: Implement Validation with the Strategy Pattern
- Demo Part 2 of 2: Use Strategy Pattern in an ASP.NET MVC Controller
- Demo: Implementing Validation Using a Custom Validation Attribute
- Demo: Implementing Validation Using IValidatableObject
- Demo Part 1 of 2: Using the Strategy Pattern to Implement a Calculation
- Demo Part 2 of 2: Connecting the Calculation Strategy in to the Application
5 – Invoking the Right Logic and Loading the Correct Page
- Routing in ASP.NET MVC Core
- Demo Part 1 of 2: Create a New Controller Action and a Custom Route
- Demo Part 2 of 2: ASP.NET Integration Tests for the Custom Route
- Demo Part 1 of 2: Legacy URL Route Integration Tests
- Demo Part 2 of 2: Implementing Controller Routes for Legacy URLs
6 – Testing Security: Authorization & Policies
- “Security Overview: Authentication, Authorization, Roles, and Claims”
- Coding Security in ASP.NET Core
- Authorization in ASP.NET Core
- Policy-based Authorization and Authorization Handlers in ASP.NET Core
- Demo: Unit Testing the Authorize Attribute
- Demo Part 1 of 4: Policy-based Authorization in ASP.NET Core
- Demo Part 2 of 4: Unit Testing Policy-based Authorization
- Demo Part 3 of 4: Implementing AuthorizationHandler in ASP.NET Core
- Demo Part 4 of 4: Configuring the Authorization Policy in ASP.NET Core
7 – Testing Security: Custom Logic & Middleware
- Demo Part 1 of 2: Using the Strategy Pattern to Make Security Decisions
- Demo Part 2 of 2: Implementing IUserAuthorizationStrategy with Claims-based Authorization
- ASP.NET Core Middleware
- Demo Part 1 of 4: Using Custom Middleware to Populate User Claims
- Demo Part 2 of 4: Implementing Custom Middleware with Unit Tests
- Demo Part 3 of 4: Configuring Custom Middleware in ASP.NET Core
- “Demo Part 4 of 4: Connecting Middleware, IUserAuthorizationStrategy, and Views”
8 – Validating Your Web API Service Code
- Demo: Integration Testing the Accept Header for JSON and XML
- Demo: Unit Testing Custom Formatted JSON Objects