Robbiew.Online
✅ Use static class or DI?
You could also introduce a factory, which when you're not testing returns back your static cache, but in tests could return a different one for your required test.
Nowadays I'd go for IoC unless it's a utilities class like a unit converter, string helper, etc. where you know you'll never need a variant of it, ever.
Nowadays I'd go for IoC unless it's a utilities class like a unit converter, string helper, etc. where you know you'll never need a variant of it, ever.
9 replies