locked
Unit Testing C++ code using VS 2008 RRS feed

  • Question

  • I am very new to C# modules.

    I have a managed C++ dll( say,ManagedDll).  I want to Create the Unit Test for the ManagedDll.

    I created a mixed managed(compiled using /clr) wrapper dll ( of  ManagedDll) (say, ManagedDllClr).  
    I created a C# dll ( using VS 2008 Test Create wizard for Unit Test) (say, ManagedDllTest).All code complies. When I run the test case using Test->Run->test in current context I get following error.

    Failed TestMethod1 ManagedDllTest Unable to create instance of class ManagedDllTest.UnitTest1. Error:  System.IO.FileNotFoundException: The specified module could not be found. (Exception from HRESULT: 0x8007007E).

    I think that the problem is: The test case could not find all the necessary dlls ( Am I correct ?).

    I think that if i put all dlls in one directory it will work.

    I  set the of output directory of C# project (ManagedDllTest) to  $(SolutionDir)$(ConfigurationName). By default it was set to "bin\release".

    result : It created a directory with literally  "$(SolutionDir)$(ConfigurationName)"

    Question: Does'not a C# default Unit Test has default  vales for these properties? Is it OK if I manually write these properties by editing Visual C# project file?

    General question:

    1.Where shall I start debugging a unit test. Basically, looking for the "main"  that runs any (C#Module created by default)Unit Test.

    2. what path does a unit test searches when i looks for dlls?
    • Moved by Cece Dong Friday, October 11, 2013 2:43 AM the thread belongs to Unit Testing forum
    Thursday, October 10, 2013 5:53 PM

Answers

  • Hello,

    Based on your description, I am not sure about your scenario. If you plan to create unit test for the ManagedDLL, why do you create a mixed managed wrapper dll? Do you reference it in the MnagedDll?

    In this case, it is hard to say the problem is the test case could not find all the necessary dlls. Maybe you could share us a sample, we try to run it in our PC. Please attach your Visual Studio solution, you can upload it to the sky drive, and then share the download link in your post. Thanks for your understanding.

    I also would like to know where you set the output directory of C# project (ManagedDllTest) to  $(SolutionDir)$(ConfigurationName).

    As far as I know, we can debug a unit test through Test->Debug->Tests in current context.

    And for C# unit test, I think that it searches necessary DLLs when running from the build output folder, typically <your project>\bin\Debug.

    Best regards,


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Proposed as answer by Amanda Zhu Tuesday, October 22, 2013 1:33 AM
    • Marked as answer by Amanda Zhu Wednesday, October 23, 2013 1:30 AM
    Monday, October 14, 2013 5:57 AM

All replies

  • Hi,

    Thanks for your post.

    In order to get better response, I'm going to move your post to Unit Test forum.

    Thanks for your understanding.

    Best regards,

    Cece


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, October 11, 2013 2:42 AM
  • Hello,

    Based on your description, I am not sure about your scenario. If you plan to create unit test for the ManagedDLL, why do you create a mixed managed wrapper dll? Do you reference it in the MnagedDll?

    In this case, it is hard to say the problem is the test case could not find all the necessary dlls. Maybe you could share us a sample, we try to run it in our PC. Please attach your Visual Studio solution, you can upload it to the sky drive, and then share the download link in your post. Thanks for your understanding.

    I also would like to know where you set the output directory of C# project (ManagedDllTest) to  $(SolutionDir)$(ConfigurationName).

    As far as I know, we can debug a unit test through Test->Debug->Tests in current context.

    And for C# unit test, I think that it searches necessary DLLs when running from the build output folder, typically <your project>\bin\Debug.

    Best regards,


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Proposed as answer by Amanda Zhu Tuesday, October 22, 2013 1:33 AM
    • Marked as answer by Amanda Zhu Wednesday, October 23, 2013 1:30 AM
    Monday, October 14, 2013 5:57 AM