Skip to content

Instantly share code, notes, and snippets.

@Ibro
Last active February 24, 2018 09:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Ibro/79e6bd4cb7c224f86c2fe5059de5d654 to your computer and use it in GitHub Desktop.
Save Ibro/79e6bd4cb7c224f86c2fe5059de5d654 to your computer and use it in GitHub Desktop.
BuildAuthorizationService - ASP.NET Core - Unit Testing Authorization Service - https://codingblast.com/asp-net-core-unit-testing-authorizationservice-inside-controller/
private IAuthorizationService BuildAuthorizationService(Action<IServiceCollection> setupServices = null)
{
var services = new ServiceCollection();
services.AddAuthorization();
services.AddLogging();
services.AddOptions();
setupServices?.Invoke(services);
return services.BuildServiceProvider().GetRequiredService<IAuthorizationService>();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment