How do you mock a Sealed class?

前端 未结 10 2288
鱼传尺愫
鱼传尺愫 2020-11-27 15:27

Mocking sealed classes can be quite a pain. I currently favor an Adapter pattern to handle this, but something about just keeps feels weird.

So, What is t

10条回答
  •  温柔的废话
    2020-11-27 15:59

    I almost always avoid having dependencies on external classes deep within my code. Instead, I'd much rather use an adapter/bridge to talk to them. That way, I'm dealing with my semantics, and the pain of translating is isolated in one class.

    It also makes it easier to switch my dependencies in the long run.

提交回复
热议问题