Non Interface dependent Mocking Frameworks for C#

后端 未结 4 1817
刺人心
刺人心 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:58

    Microsoft Research has developed Moles for this, which is a part of Pex but can be installed independently. And it's free. There's a good introductory article (pdf) on the website that explains how to mock a static method. It takes some time before they get to the stuff you want (page 16, Task 3).

    Here and here (Channel 9) you can find an example on how to stub DateTime.Now. Using Moles, you can mock anything you want.

提交回复
热议问题