Using the NSubstitute package
There are a number of different mocking libraries available to you, some free and some commercial. For this book, we’ll use NSubstitute, an open source and free option available as a NuGet package.
To get started, follow these steps:
- Right-click on your solution and choose ManageNugetPackagesForSolution.
- Go to the Browse tab and enter
NSubstitute
.
The first package you want is NSubstitute by Anthony Egerton et al., as shown here:
Figure 9.12 – NSubstitute NuGet package
- On the right, click on the project you want this added to (
ForgetMeNotDemo.Tests
) and click on Install, as shown in Figure 9.13:
Figure 9.13 – Installing NSubstitute
- Once that installs, install NSubstitute.Analyzers.CSharp, as shown in the following figure:
Figure 9.14 – Selecting NSubstitute.Analyzers.CSharp
While not strictly required, this second...