From the course: ASP.NET Core: Test-Driven Development

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Confidently change your code, part 2

Confidently change your code, part 2 - ASP.NET Core Tutorial

From the course: ASP.NET Core: Test-Driven Development

Start my 1-month free trial

Confidently change your code, part 2

- [Instructor] The last set of changes we need to make are in the booking controller. We'll start just as before by adding tests for existing functionality. Let's create a new test file. We'll right-click on the test project, go to Add, New Item. We'll call it BookingControllerTests. Just as before, I already wrote the test to cover the existing functionality. You can find the code in the exercise files. I'm going to copy this code, and paste it into Visual Studio. Next, I'm going to run my tests. Good, now I have code coverage for my existing code. I can start writing my new tests and my new code. We'll copy this last test here, and we want to add a test to ensure that the coupon code is passed from the view model into our CalculateBookingPrice. So we're going to call this WithCouponCode and change our test booking view model to CouponCode = "FREEMONEY." You might notice with this test, instead of calling a regular set method, we're calling our booking service mark.verify; and that's…

Contents