Hello, I have an action that relies on User.Identity.Name to get the username of the current user to get a list of his orders:
public ActionResult XLineas()
{
ViewData["Filtre"] = _options.Filtre;
ViewData["NomesPendents"] = _options.NomesPendents;
return View(_repository.ObteLiniesPedido(User.Identity.Name,_options.Filtre,_options.NomesPendents));
}
Now I'm trying to write unit tests for this, but I get stuck on how to provide a Mock for User.Identity.Name. If I run my test as I have it (without mock for User...), I get a Null.. exception.
Which is the correct approach for this? I'm thinking that my Action code is not good for unit testing.