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.

Solution: Unit testing details ActionResult

Solution: Unit testing details ActionResult - ASP.NET Core Tutorial

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

Start my 1-month free trial

Solution: Unit testing details ActionResult

(upbeat music) - [Instructor] I asked you to unit test the details action result and pass the parameters using the inline data attribute. Now, let us walk through my solution together. So before we write the unit test, let us go to the books controller. And I'll scroll down to the details, and we see that it takes a parameter an Id of type guid, it then gets the book using the GetById service method. And if it doesn't find any books, it will just return a not found, if it finds it's going to return a view which has the parameter a single book object. Now, let us go back to our unit test and start writing some code. Instead of fact, we said that we are going to create a theory. So let us write in your, theory. And then we are going to pass the data using the inline data attribute. Here, I'll pass two strings, a valid guid string, and one that is not valid, cause we want to test two cases, the first one, where we don't…

Contents