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.

Refactor code and tests

Refactor code and tests - ASP.NET Core Tutorial

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

Start my 1-month free trial

Refactor code and tests

- So we're ready to do some refactoring. Refactoring is important to do at each step but remember that you don't have to. And also, it's important to take a step back every so often and look at what you've done. Ask yourself if it makes sense, or if it would be better if it were structured a little differently. You should be able to do these restructures, and your tests should give you confidence in your changes. So let's start by looking at our tests. We want to clean up some of this duplication. We have four tests for our pet scenario, but really the only difference is the true false values, and the outcome. I think there's a much more explicit way of expressing that. And actually, you can do this for theories. So let's create a theory. We'll copy our last test. Instead of a fact, we'll give it the theory attribute. We'll change it's name to Pets given it's testing all of our Pets scenarios. And we're going to give it three parameters. If the pets are allowed, if the booking has…

Contents