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 - ASP.NET Core Tutorial
From the course: Advanced ASP.NET Core: Unit Testing
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…
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.
Contents
-
-
-
-
ASP.NET Core console project overview1m 46s
-
(Locked)
Set up the console testing project5m 20s
-
(Locked)
xUnit Theory with InlineData6m 15s
-
(Locked)
Challenge: Test add and average methods51s
-
(Locked)
Solution: Test add and average methods4m 25s
-
(Locked)
xUnit Theory with MemberData4m 29s
-
(Locked)
xUnit Theory with ClassData4m 7s
-
-
-
-