Let's take the same application we created in the previous section for unit tests:
- Add a new project for integration tests, and make sure the project structure looks like the following screenshot:
- Write the following code in the constructor of ProductTest.cs:
var server = new TestServer( new WebHostBuilder() .UseStartup<TestStartup>());_client = server.CreateClient();
In the preceding code block, we initialized TestServer , where we used TestStartup as our startup entry file. Finally, we created a private readonly HttpClient _client; of our WebHostBuilder().
- Then, write a simple method that calls the productlist resource: