title: Unit testing a method that uses an external dll
body: <p>I have a project named <strong>A</strong> that has a class named <strong>ClassA</strong>.
  <strong>ClassA</strong> has a method named <strong>ReadBlock()</strong> which creates a <strong>CloudBlockBlob</strong> object and calls one of its methods.</p>
  
  <p><strong>CloudBlockBlob</strong> is a class which is located in <strong>Microsoft.WindowsAzure.Storage.Blob</strong> namespace which is in <strong>Microsoft.WindowsAzure.Storage.dll</strong>.</p>
  
  <p>My project <strong>A</strong> has a unit testing project named <strong>A.Tests</strong>.
  Now, I want to test method <strong>ReadBlock()</strong>. To test it, I need to mock the <strong>CloudBlockBlob</strong> object and intercept the calls to its methods, return custom values and verify that the methods were called. </p>
  
  <ul>
  <li>How can I mock an object that is fully created inside a method? </li>
  <li>Can I somehow change project <strong>A</strong>'s dll reference and reference it to a mock dll that creates a mock object instead the real one?</li>
  <li>Can I override project <strong>A</strong>'s call for classes inside the <strong>Microsoft.WindowsAzure.Storage.Blob</strong> with an implementation of my own in <strong>A.Tests</strong> class?</li>
  </ul>
  
  <p><strong>UPDATE:</strong> 
  The question is whether I can do this without modifying project <strong>A</strong>'s code.</p>
  
  <p>Thanks!</p>