Non Interface dependent Mocking Frameworks for C#

后端 未结 4 1797
刺人心
刺人心 2020-12-25 08:37

I am new to mocking so I might have it totally wrong here but I believe that most mocking frameworks are interface dependent. Unfortunately most of our code is not using an

4条回答
  •  粉色の甜心
    2020-12-25 08:59

    You can use classes instead of interfaces with both Moq and Rhino.Mocks, but the mocked methods must be virtual. Mark Rushakoff's answer on TypeMock is correct (+1).

    The best option is to refactor your existing code for testability (which may take time). I'd recommend reading Working Effectively with Legacy Code by Michael Feathers.

提交回复
热议问题