Skip to Main Content
Hands-On RESTful Web Services with ASP.NET Core 3
book

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

by Samuele Resca
December 2019
Intermediate to advanced content levelIntermediate to advanced
510 pages
11h 33m
English
Packt Publishing
Content preview from Hands-On RESTful Web Services with ASP.NET Core 3

Initializing the testing class

Let's proceed by creating a new testing class in our Catalog.Infrastructure.Tests project called ItemRepositoryTests:

using Xunit;namespace Catalog.Infrastructure.Tests{    public class ItemRepositoryTests    {        [Fact]        public void should_get_data()        {            Assert.True(true);        }    }}

The Xunit framework identifies test classes using the Fact attribute. Every class that contains a method that has the Fact attribute or, as we'll see later in this section, the Theory attribute, will be considered as a test by the unit test runner.

Let's continue by adding our first test method. This checks the GetAsync method of the ItemRepository class:

using System.Threading.Tasks;using Microsoft.EntityFrameworkCore;using Shouldly;using Catalog ...
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

Mastering ASP.NET Web API

Mastering ASP.NET Web API

Mithun Pattankar, Malendra Hurbuns
Pro ASP.NET Web API: HTTP Web Services in ASP.NET

Pro ASP.NET Web API: HTTP Web Services in ASP.NET

Tugberk Ugurlu, Alexander Zeitler, Ali Kheyrollahi
ASP.NET Core MVC 2.0 Cookbook

ASP.NET Core MVC 2.0 Cookbook

Jason De Oliveira, Engin Polat, Stephane Belkheraz

Publisher Resources

ISBN: 9781789537611Supplemental Content