Test some code that is newing up its own objects, or is doing too much and is difficult or impossible to unit test. Also, identify some bug you'd want to fix.
- [Instructor] It's all well and good TDDing new code,…but often in the real world, you actually have to…edit some existing code.…Our client, Landon Hotel, wants us to make a change…to some existing code.…They have a feature to calculate a booking price…and now they want to add the option for a coupon code.…So, the big problem is, this code is untested…and not written in a way that's currently unit testable.…So this chapter is going to focus on how we can apply…TDD practices on code that's currently in…an untestable state.…So here's what we'll be doing, first we'll be identifying…where we need to make the change.…
Then, once we've done that, we can extract out…their dependencies to make use of dependency injection.…Then, we'll be writing tests to cover the existing…behavior, just so when we're making any new changes,…we don't break any of the existing stuff.…And finally, we'll be applying TDD practices…to make our new changes.…
Note: Examples in this course were developed using C# ASP.NET Core, but the concepts apply to all .NET Core applications.
- Getting the TDD tools
- Testing cases
- Refactoring code
- Completing test cases
- Testing changes in untested code
- Changing code