Partial mocking of class with Moq

江枫思渺然 提交于 2019-12-03 11:39:12
Fabian

OK, I found the answer to this in another question: How to Mock the Internal Method of a class?. So this is a duplicate and can be closed.

Nevertheless, here's the solution: just add this line to the Assembly.config of the project you want to test:

[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")] // namespace in Moq

Did you try to specify Verifiable:

my.Setup(mock => mock.GetValue()).Callback(() => Console.WriteLine("MOCKED GetValue")).Returns(999).Verifiable();
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!