I want my Web API app to sign in users via ASP.NET Identity.
In my AuthController I do the following:
//...getting claimsIdentity etc...
_authenticationManager.SignIn(claimsIdentity)
where _authenticationManager is an instance of IAuthenticationManager
I'm using Unity so IAuthenticationManager is registered in the following way:
container.RegisterType<IAuthenticationManager>(new InjectionFactory(o => HttpContext.Current.GetOwinContext().Authentication));
And that works for my app that is hosted in IIS. But I also have some integration tests that are run on the self-hosted environment and the problem is that IAuthenticationManager resolution fails because HttpContext.Current is null.
Is there any way to register IAuthenticationManager implementation and use it in both self-hosted and IIS? I do also want to be able to inject this dependency via my controller's constructor in unit tests.