I cant't find enough information about how to test controllers and classes in asp.net core, when dependency injection is needed.
Using nunit, how to test a class like this:
public class EventServices : Service<EventBase>, IEventServices
{
private readonly IMemoryCache memCache;
private readonly UserManager<ApplicationUser> userManager;
private readonly IHttpContextAccessor accessor;
public EventServices(
IRepository<Evento> repository,
IMemoryCache memCache,
UserManager<ApplicationUser> userManager,
IHttpContextAccessor accessor
) : base(repository)
{
this.memCache = memCache;
this.userManager = userManager;
this.accessor = accessor;
}
public IQueryable<Evento> MyMethod(string message)
{
....
This classe is registered in Startup class:
services.AddScoped<IEventServices, EventServices>();
like other classes in the constructor.