Unit testing controllers

The ASP.NET Core MVC Controller classes handle users interactions, which translates to the request on the browser. The controller gets the appropriate model and selects a view to render that displays the user interface. The controller reads a user's input data, events, and interactions from the view, and passes it to the model. The controller validates the input it receives from the view and then performs the business operation that modifies the state of the data model.

The Controller classes should be lightweight and contain the minimal logic needed to render the view based on a user's interactions to allow easy testing and maintenance. The controller should verify the state of the model and ascertain the validity, ...

Get C# and .NET Core Test Driven Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.