From the course: Advanced ASP.NET Core: Unit Testing

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Unit testing HttpGet API endpoint

Unit testing HttpGet API endpoint - ASP.NET Core Tutorial

From the course: Advanced ASP.NET Core: Unit Testing

Start my 1-month free trial

Unit testing HttpGet API endpoint

- [Instructor] We are going to follow a simple rule or flow and that is arrange, act, assert. But, what does this mean? Well, with arrange we mean that we need to arrange or set up the necessary parameters for the test. When we used the fact attribute for example, this happens inside the methods. And when we used the theory attribute, this happens in the InlineData, MemberData, or ClassData attributes where we provide the parameters. Act means just do the action which might be calling a method, calling a controller, et cetera. Now that we have the parameters or no parameters and we act it is time to assert or in other words evaluate the result. Well, let's go to visual studio and write our fist unit test. And you'll go to the Books Controller Test file and we are going to unit test the first API endpoint of the Books Controller. So if we go to Books Controller by right-clicking then Go To Definition, we are going to see…

Contents