Unit testing an AuthorizeAttribute on an ASP.NET Core MVC API controller
I have a ASP.NET Core MVC API with controllers that need to be unit tested. Controller: using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using System.Threading.Tasks; namespace TransitApi.Api.Controllers { [Route("api/foo")] public class FooController : Controller { private IFooRepository FooRepository { get; } public FooController(IFooRepository fooRepository) { FooRepository = fooRepository; } [HttpGet] [Authorize("scopes:getfoos")] public async Task<IActionResult> GetAsync() { var foos = await FooRepository.GetAsync(); return Json(foos); } } } It is essential that I