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 - ASP.NET Core Tutorial
From the course: Advanced ASP.NET Core: Unit Testing
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…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
(Locked)
ASP.NET Core MVC project overview5m
-
(Locked)
Set up MVC testing project2m 34s
-
(Locked)
Unit testing index ActionResult7m 55s
-
(Locked)
Challenge: Unit testing details ActionResult54s
-
(Locked)
Solution: Unit testing details ActionResult9m 54s
-
(Locked)
Unit testing create ActionResult7m 45s
-
(Locked)
Unit testing remove ActionResult5m 30s
-
(Locked)
-