I never did unittesting for an asp.net web api. The service is about posting a JSON in the request and returning a JSON result after JSON schemavalidation and querying. Just wondering how to unittest a web api in general. An example of a test would be posting an invalid JSON string and testing whether this returns the correct HTTPcode ie 400 or something. This is roughly what my service looks like:
public class MyApiController : ApiController
{
public HttpResponseMessage Post([FromBody]dynamic value)
{
return response;
}
}
Also how can I use constructor injection with web apis? If I use a constructor here my value that is posted is null?