From the course: Advanced ASP.NET Core: Unit Testing

Unlock the full course today

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

Solution: Test add and average methods

Solution: Test add and average methods - ASP.NET Core Tutorial

From the course: Advanced ASP.NET Core: Unit Testing

Start my 1-month free trial

Solution: Test add and average methods

(fast beat music) - [Instructor] I asked you to unit test the add and average methods using the inline data attribute to pass parameters to these methods. Let us now walk through my solution together. For that, let's go to Visual Studio. And you scroll down to the DiffTest, because the AddTest is similar to the DiffTest. I'll just copy this unit test and paste it down here. Then change the name to AddTest, leave the parameters the same and then change the Diff method in here to Add method. Now, of course we need to change the inline data parameters because one plus two, will result in three. Let us now also use some negative numbers. So for example, minus four, minus six, the result is going to be minus 10. And save the changes. Let us now create a unit test for the average method. For that, I'll just copy the SumTest. And then paste it down here, I'll change the name from SumTest to AverageTest. Leave the…

Contents