Using ASP.NET Core's TestServer allows us to create an in-memory web server. This allows us to write xUnit tests, focusing on endpoints in a ASP.NET Core Web API application.
First, we will go ahead and set up our xUnit test project in Visual Studio 2019.
Afterwards, we will create a new instance of WebHostBuilder. Our instance of WebHostBuilder allows us to create a custom Startup class for our xUnit project.
We then pass this instance of WebHostBuilder into a new instance of TestServer. This is then setup to test our API endpoints.
In addition, we will have a look at ways of how we can use a SQL Server database in TestServer. This includes looking at Entity Framework's InMemory tool, allowing us to run an instance of EF without a database.
📖 Learn .NET and C# with our online courses 📖
https://www.roundthecode.com/dotnet-c...
► More Information: https://www.roundthecode.com/dotnet-t...
► ASP.NET Core's TestServer Playlist: • ASP.NET Core's TestServer - Test Web ...
#testserver #aspnetcore #xunit
Watch video Use ASP.NET Core's TestServer in xUnit to Test Web API Endpoints: TestServer - Part 1 online without registration, duration hours minute second in high quality. This video was added by user Round The Code 20 November 2020, don't forget to share it with your friends and acquaintances, it has been viewed on our site 4,237 once and liked it 66 people.