Working in asp.net core, there are several controllers which has claims. The sample code is like this.
[HttpGet, Route("GetCustomerList")]
public ActionResult<GenericResponse> Get()
{
var claims = User as ClaimsPrincipal;
string username = claims.Claims.Where(c => c.Type == "UserName").Select(x => x.Value).FirstOrDefault();
string roleid = claims.Claims.Where(c => c.Type == "RoleId").Select(x => x.Value).FirstOrDefault();
........
........
}
How should I handle this claims while controller testing? I have tried the solution given How to add claims in a mock ClaimsPrincipal i.e. first solution. However, in my controller while debugging gives User a null and it stops.