(no title)
sfotm | 3 years ago
Coming from Java into a C# job, I'm used to mocking downstream dependencies, and even POJOs in some cases, that a class depends on. C# has stuff like Moq, but you _have to_ wrap everything with an interface to mock it since C# seals by default.
Meanwhile, in JVM land, you can use Kotlin, which still seals classes by default, but allows test compiles to open classes by default so you can still mock them.
Every C# thread I read suggests wrapping all concrete implementations with an interface like I'm coding in the 90's for the sake of decent tests, or they talk about how my code must be written poorly for me to be in this situation. Meanwhile, I'm just trying to get _some_ testing into this code I've inherited.
int_19h|3 years ago
Also, C# doesn't seal anything by default. The methods are non-virtual by default, but that's a very different thing, and there's a good reason for it when it comes to libraries and versioning.