title: Unit test with Dependency Injection using struture map
body: <p>I am new to MVC and IoC and other related concepts.</p>
  
  <p>I have to write unit test cases for an old project. It uses Structure Map for Dependecy Injection. Third party dlls that I use expose some interfaces. Now I have to write unit test cases for methods in the controller class.</p>
  
  <p>The constructor of controller looks like this:</p>
  
  <pre><code>HomeController(IClientData clientdata)
  {
      _clientdata = clientdata;
  }
  //The clientdata was initialized
  </code></pre>
  
  <p>In my test case, how do I initialize the controller class and interface like <code>IClientData</code>? Passing <code>IClientData clientdata</code> to constructor says: <code>passing type as var</code>.</p>
  
  <p>How do I initialize/mock the data in <code>IClientData</code>? I don't know how the interface is implemented in the dll.</p>