Unit testing

To test the business logic in our TripLog app we will start out by creating a new unit test project in our solution that will be responsible for testing our ViewModels. There are many options and libraries to create unit tests in .NET with Visual Studio. In this chapter we will use the NUnit Library Project template in Visual Studio for Mac.

In order to create a unit test project, perform the following steps:

  1. Create a new solution folder in the TripLog solution named Tests. Although this is not required, it helps keep any testing-related projects organized within the overall solution. To add a new solution folder in Visual Studio, simply right-click on the solution name, go to Add and click on Add Solution Folder, as shown in the following screenshot:
Adding a new solution folder in Visual Studio for Windows is the same process: right-click on the solution name, go to Add and click on New Solution Folder.
  1. Next, create a new NUnit Library Project within the new Tests solution folder:
  1. Name the NUnit Library Project TripLog.Tests, as shown in the following screenshot:

By default, the new NUnit project will contain a Test.cs file. You can safely delete this file, as we will create new ones that are specific to each of our ViewModels in the next section.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.12.162.65