Getting ready for the test project

We will test our microservice application: FlixOne bookstore. With the help of code examples, we will see how to perform unit tests, stubbing, and mocking.

We created the FlixOne bookstore application in Chapter 2, Implementing Microservices.

Before we start writing tests, we should set up a test project in our existing application. There are a few simple steps we can take with this test project setup:

  1. From Solution Explorer within Using Visual Studio, right-click on Solution and click New Project—refer to the following screenshot:
  1. From the Add New Project template select .NET Core and xUnit Test Project (.NET Core), and provide a meaningful name, for example, FlixOne.BookStore.ProductService.UnitTests:
  1. Go to project Properties, by right-clicking on the project name from Solution Explorer. Open the Build tab from the Properties page and click on Advance and select C# 7.0 as Language version:

Our project structure should look like this: