When using IDataProtectionProvider
in a Web API, the IoC container is configured with AddDataProtection
(services.AddDataProtection();
) and enables the use of DI to retrieve a IDataProtectionProvider
in a service as such:
private readonly IDataProtectionProvider _dataProtectionProvider;
public CipherService(IDataProtectionProvider dataProtectionProvider)
{
_dataProtectionProvider = dataProtectionProvider;
}
If I would like to test my CipherService
(in my case using Xunit), I will not be able to make this work without using DI, so my question is;
Q: How can I use DI or otherwise make IDataProtectionProvider
in a test project?