Testing using xUnit

In this section we will learn to write unit and integration tests for our controllers. There are a number of options available to us for choosing the test framework. We will use xUnit for all our unit tests and Moq for mocking objects. Let's create a xUnit test project by doing the following:

  1. Open the Let's Chat project in Visual Studio 2017
  2. Create a new folder named  Test
  3. Right-click the Test folder and click Add | New Project
  4. Select xUnit Test Project (.NET Core) under Visual C# project templates, as shown here:
  1. Delete the default test class that gets created with the template
  2. Create a test class inside this project  ...

Get .NET Core 2.0 By Example now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.