我有三個項目,它使用本地代碼
1)託管C++包含完整的業務邏輯單元測試C#項目
2)C++/CLI(項目名稱管理)
3) C#GUI
我已經在C++/CLI中添加了非託管C++的庫文件,然後在C#項目中添加了C++/CLI的dll。這一切工作正常,執行無故障。
現在我想對C#函數進行單元測試,它調用C++/CLI包裝,然後獲取結果。我使用Visual Studio 2010.創建了一個單元測試。我在測試中添加了C++/CLI的dll project.Now當我試圖執行測試拋出例外managed.dll沒有找到
這裏是代碼
[TestMethod()]
public void getstateTest()
{
bool expected=true;
bool actual=false;
try
{
GUI.test target = new test();
expected = true; // TODO: Initialize to an appropriate value
actual = target.getstate();
}
catch (FileNotFoundException exception)
{
MessageBox.Show("Missing file is : " + exception.FileName);
}
Assert.AreEqual(expected, actual);
}
The getstate function is
namespace GUI
{
public class test
{
public bool getstate()
{
bool chk = false;
bool result;
String a = "some path";
String b = "some path"
String c = "some path"
managed objct;
objct = new managed();
objct.Initialize(a, b, c, chk);
objct.Execute();//calls the C++/CLI execute which calls unmanaged C++
result = objct.Executionresult();//gets a bool result
return result;
}
}
}
同樣的事情,工作正常,當我運行應用程序上運行的測試項目,它說的DLL文件丟失
很抱歉,如果我做到了confusing.Please問,如果你提前
是否報告DLL丟失或格式無效?您的單元測試需要以與它們加載的本機代碼相同的位運行。 – 2012-03-21 18:26:17
Dll被報告爲丟失...單元測試和本地代碼都在x86中運行 – 2012-03-22 04:22:10