When unit testing ViewModels, it is best to break the tests into individual test classes that represent each ViewModel, resulting in a one-to-one relationship between ViewModel classes and the unit test classes that test their logic.
In order to test our ViewModels, we will need to add a reference to them within the unit tests project, as shown in the following screenshot:
We will start by creating a set of unit tests for DetailViewModel:
- First, create a new folder in the TripLog.Tests project named ViewModels. This helps keep the file structure of the tests the same as the library being tested.
- Next, create a new empty ...