From the course: Advanced ASP.NET Core: Unit Testing
ASP.NET Core console project overview - ASP.NET Core Tutorial
From the course: Advanced ASP.NET Core: Unit Testing
ASP.NET Core console project overview
- [Instructor] In this chapter, we are going to learn how to unit test an existing ASP.NET Core console application. I'll be using the .NET Core 3.1, which is current latest stable version, but you can use any version of .NET Core, 2.2 or later. Let's go to Visual Studio and see our project. This is a simple console application named Calculator App, and inside here, you are going to see the default program.cs file, which has the main method, also known as the entry point in the .NET applications. And we have another file, the MathHelper.cs. Inside this file, which is a C# clause, you'll see a couple of methods. The first one is the IsEven method. This method checks if a number is an even number or not, and it returns true or false. The other method, named Diff, finds the difference between the second parameter and the first one. The other one, of the Add method, returns the sum of two parameters. Then next, we have the Sum and the Average methods. The Sum method will return the sum of all the elements in an integer array. And the Average one will return the average of the numbers in an integer array. Then next, we have a class member, which is going to return a list of objects. We are going to use this member when we want to pass as parameters for our testing methods a membered data. Then at the ends, we have the GetEnumerator method, which is used to return a list of objects when we want a test as a parameter to our unit testing method our class.
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
-
-
-
-