How do you mock a Sealed class?

前端 未结 10 2290
鱼传尺愫
鱼传尺愫 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:33

    The problem with TypeMock is that it excuses bad design. Now, I know that it is often someone else's bad design that it's hiding, but permitting it into your development process can lead very easily to permitting your own bad designs.

    I think if you're going to use a mocking framework, you should use a traditional one (like Moq) and create an isolation layer around the unmockable thing, and mock the isolation layer instead.

提交回复
热议问题