Moq how do you test internal methods?

前端 未结 6 1785
借酒劲吻你
借酒劲吻你 2021-01-05 02:02

Told by my boss to use Moq and that is it. I like it but it seems that unlike MSTest or mbunit etc... you cannot test internal methods

So I am forced to make public

6条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-05 03:00

    You can use the InternalsVisibleTo attribute to make the methods visible to Moq.

    http://geekswithblogs.net/MattRobertsBlog/archive/2008/12/16/how-to-make-a-quotprotectedquot-method-available-for-quotpartialquot-mocking-and-again.aspx

提交回复
热议问题