Unit testing ASP.NET Web API Controller

This post is about unit testing Web API controller. As we are using Entity Framework and some Web API related classes, we need to implement dependency injection to unit test Web API controllers. To manage Entity Framework dependency, I am using a simple Repository pattern. Here is my repository interface. As this post is moreRead More

Performing CURD operations using Web API – Part 3

I couldn’t complete this series without mentioning the model validations part. Like normal services you can do custom validations, if validation fails, can create error responses and return. Similar to ASP.Net MVC, WebAPI also supports Model validations using DataAnnotations. And in the code you can use ModelState.IsValid property to validate Model is valid or not.Read More

Performing CURD operations using Web API – Part 2

In the last post we implemented CRUD operations with Web API. According to HTTP method definitions, all the HTTP requests should return a HTTP response, which consists of Status Line Response Headers Response Message Body (optional) So we can rewrite all these methods with HttpResponseMessage class,this class help to create HTTP response message including theRead More