Testing a controller

Once we have implemented the InMemoryApplicationFactory class, it is possible to utilize it by implementing the IClassFixture interface in our test classes. Therefore, let's start by initializing a new ItemControllerTests class in the Catalog.API.Tests project:

using System.Net.Http;using System.Text;using System.Threading.Tasks;using Newtonsoft.Json;using Shouldly;using Catalog.Domain.Infrastructure.Entities;using Catalog.Fixtures;using Xunit;namespace Catalog.API.Tests.Controllers{    public class ItemControllerTests : IClassFixture<InMemoryApplicationFactory<Startup>>    {        private readonly InMemoryApplicationFactory<Startup> _factory;        public ItemControllerTests(InMemoryApplicationFactory<Startup>          factory)        {            _factory 

Get Hands-On RESTful Web Services with ASP.NET Core 3 now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.