Skip to Content
Building RESTful Web Services with .NET Core
book

Building RESTful Web Services with .NET Core

by Gaurav Aroraa, Tadit Dash
May 2018
Intermediate to advanced
334 pages
7h 25m
English
Packt Publishing
Content preview from Building RESTful Web Services with .NET Core

Run tests

Let's take the application we developed in the previous section on unit testing. Follow the steps mentioned in the preceding section and add a new xUnit test project.

We are looking for fake objects or data for testing purposes, so we will not be hitting our actual database server. Instead, here we will use the InMemory database.

You need to add the Microsoft.EntityFrameworkCore.InMemory NuGet package to start the InMemory database.

We are not going to change anything here, but we will create fake data and records to test. To proceed, add the following code to the TestStartup.cs file in the ConfigureServices method:

//for tests use InMemory dbservices.AddDbContext<ProductContext>(  o => o.UseInMemoryDatabase  ( InitConfiguration().GetConnectionString ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Hands-On RESTful Web Services with ASP.NET Core 3

Hands-On RESTful Web Services with ASP.NET Core 3

Samuele Resca
Microservices in .NET Core

Microservices in .NET Core

Christian Horsdal Gammelgaard

Publisher Resources

ISBN: 9781788291576Supplemental Content