From the course: ASP.NET Core: Test-Driven Development
Unlock the full course today
Join today to access over 22,700 courses taught by industry experts or purchase this course individually.
Confidently change your code, part 1 - ASP.NET Core Tutorial
From the course: ASP.NET Core: Test-Driven Development
Confidently change your code, part 1
- [Instructor] Before we start TDD-ing our new changes, it's a good idea to add test coverage to the areas you'll be modifying. Not only does this improve your test coverage, but when you make your changes, it gives you confidence that you haven't broken any existing behavior. We're going to be making changes in the booking controller and the booking service classes. Let's start with a test for the booking service. We have a blank test file here where I'm going to be adding my test for the booking service class. I already wrote the test needed for this method. You can find them in the course files for this video. I'm going to copy this in and paste. Now, we can run the test. Cool, so now we can start TDD on this class. Let's start by copying this test, and we'll rename it to DiscountsCouponCode. Next, we know that our method is going to need to pull data from the coupon repository, so let's add a mock for that. We'll scroll up, and add a new private mock to our tests for the…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.