using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using System.Security.Claims; namespace AsbCloudWebApi.Tests.ControllersTests { static class ControllerExtentions { public static void AddUser(this ControllerBase controller) { var claims = new Claim[] { new Claim("idCompany", "1") }; controller.AddUser(claims); } public static void AddUser(this ControllerBase controller, Claim[] claims) { var identity = new ClaimsIdentity(claims, "mock"); var user = new ClaimsPrincipal(identity); controller.ControllerContext = new ControllerContext() { HttpContext = new DefaultHttpContext() { User = user } }; } } }