I build my first mvc6 api with :
I wanted to write test for it now but how can I cast a IActionResult which returns a JSON string to an Model(e.g User)
I get a error which says:
Cannot Convert IAction result to User ...
[HttpGet("{}")]
public IActionResult getUser()
{
Benutzer benutzerData = _context.benutzer.FirstOrDefault<User>();
return new ObjectResult(benutzerData);
}
and in my Test class :
Benutzer user = _controller.getUser();
Aucun commentaire:
Enregistrer un commentaire