I have an c# interface with multiple implementations & each implementation is taking various dependencies object in its constructor.
In order to achieve DI using LightInjector on web api project, Im registering a 'Func' like below & its working as expected but can't able to unit test it.
Any way I can write the below code in unit testable way?
container.RegisterInstance<Func<IHandler, HandlerType, IHandler>>
((handler, type) =>
{
IHandler context = null;
switch (type)
{
case HandlerType.Type0:
context = new Type0(orderHandler, container.GetInstance<IUtilityLogic>());
break;
case HandlerType.Type1:
context = new Type1(orderHandler, container.GetInstance<IUtilityLogic>(), container.GetInstance<IShipmentLogic>());
break;
case HandlerType.Type2:
context = new Type2(orderHandler);
break;
case HandlerType.Type3:
context = new Type3(orderHandler, container.GetInstance<IUtilityLogic>());
break;
case HandlerType.Type4:
context = new Type4(orderHandler, container.GetInstance<IUtilityLogic>(), container.GetInstance<IShipmentLogic>(), container.GetInstance<Func<string, string, ICache>>());
break;
default:
context = null;
break;
}
return context;
});