title: Unit Testing a c# project which uses native code
body: <p>I have three projects</p>
  
  <p>1)unmanaged c++ containing full business logic</p>
  
  <p>2)C++/CLI (<strong>Project name managed</strong>)</p>
  
  <p>3)C# GUI</p>
  
  <p>I have added the library file of unmanaged c++ in C++/CLI and then dll of C++/CLI in C# project.This this all is working fine and execution is trouble-less.</p>
  
  <p>Now i want to do unit testing of C# function that does call the C++/CLI wrapper and then get the results back.I created a unit test using Visual Studio 2010.I added the dll of C++/CLI in my test project.Now when i am trying to execute the test it throws the <strong>exception managed.dll not found</strong></p>
  
  <p>Here is the code</p>
  
  <pre><code>   [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;
      }
  }
  </code></pre>
  
  <p>}</p>
  
  <p>Same thing works fine when i run the application but on running the test project it says the dll is missing</p>
  
  <p>Sorry if i made it confusing.Please ask if you need more information.Thanks in advance</p>