vendredi 4 novembre 2016

Automatic testing of ApiController

I have an APIController and would like to test it including the routing.

An example:

[RoutePrefix("prefix")]
public class Controller :ApiController{
     [HttpGet]
     [Route({"id1"}]
     public int Add(int id1, [FromUri] int id2)
     {
         return id1+id2;
     }
}

I would now like to test this method. I see, that I can test it like an ordinary method. But I would also like to test it with the translation of the url to the method parameters.

Basically I would like to have an automatic test where I call an url like "prefix/10?id2=5" and get a result of 15. Is this somehow possible?

Aucun commentaire:

Enregistrer un commentaire