您如何模拟使用DllImport调用外部函数的类 [英] How do you mock a class calling an external function using DllImport
本文介绍了您如何模拟使用DllImport调用外部函数的类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我需要为包含一个函数的类编写单元测试,该函数又使用DLL导入属性依次调用外部函数("C"函数).
我需要模拟外部"C"函数并返回模拟值.我没有任何想法..请帮帮我...
预先感谢,
Deepak
Hi all,
I need to write unit test for a class which contains a function which in turns calling an external function (''C'' function) using DLL Import attribute.
I need to mock the external ''C'' function and return the mocked values. I dont have any ideas.. please help me out ...
Thanks in advance,
Deepak
推荐答案
通过以下链接进入
http://msdn.microsoft.com/en-us/library/aa288468 (v = vs.71).aspx [ http://www.java2s.com/Tutorial/CSharp/0520__Windows/DllImportloaddlllibrary.htm [ ^ ]
go through the below link
http://msdn.microsoft.com/en-us/library/aa288468(v=vs.71).aspx[^]
Example Here
http://www.java2s.com/Tutorial/CSharp/0520__Windows/DllImportloaddlllibrary.htm[^]
这篇关于您如何模拟使用DllImport调用外部函数的类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文