The reason you get:
An exception of type "System.ArgumentNullException" occurred in System.Web.Http.dll, but was not processed in the user code Additional information: The value cannot be null.
is that the Request object is null .

The solution for this is to instantiate your controller in your tests, for example:
var myApiController = new MyApiController { Request = new System.Net.Http.HttpRequestMessage(), Configuration = new HttpConfiguration() };
Thus, when creating a new instance of the MyApiController class MyApiController we initialize the Request object. In addition, you must also provide a related configuration object.
Finally, an example of Unit Test for your Api Controller might be:
[TestClass] public class MyApiControllerTests { [TestMethod] public void CreateEmployee_Returns_HttpStatusCode_Created() {
source share