I have this factory:
public static class ClassFactory
{
public static IEnumHereClass CreateClass(EnumHere type)
{
switch (type)
{
case EnumHere.First:
return new EnumHereFirstClass();
case EnumHere.Second:
return new EnumHereSecondClass();
default:
throw new NotSupportedException();
}
}
}
Looks nice. But I see problem here: I can't inject it using IoC container (unity for instance) and can't mock it. I want to make this changes (use interface to inject it and delete static):
public class ClassFactory : IClassFactory
{
public IEnumHereClass CreateClass(EnumHere type)
{
switch (type)
{
case EnumHere.First:
return new EnumHereFirstClass();
case EnumHere.Second:
return new EnumHereSecondClass();
default:
throw new NotSupportedException();
}
}
}
What do you think?