Mocking Static methods using Rhino.Mocks

前端 未结 6 1084
夕颜
夕颜 2020-11-29 07:14

Is it possible to mock a static method using Rhino.Mocks? If Rhino does not support this, is there a pattern or something which would let me accomplish the same?

6条回答
  •  没有蜡笔的小新
    2020-11-29 07:37

    The only mock framework that I know of that supports mocking statics is TypeMock.

    As Rytmis suggested, you need to wrap the statics in something (i.e. an instance class with virtual methods or an interface) that you can then mock out.

提交回复
热议问题