title: Why doesn't framework detour?
body: <p>I am unit testing code that depends on iTextSharp open source Pdf library. One of the classes inTextSharp is PdfReader with one of the constructors that accepts byte array. I simplified the problem to the following:</p>
  
  <pre><code>    [TestMethod]
      [HostType("Moles")]
      public void ReadPdf()
      {
          MPdfReader.ConstructorByteArray = (@this, pdfIn) =&gt;
          {
              new MPdfReader(@this)
              {                    
              };
          };
  
          PdfReader reader = new PdfReader(new byte[] { 10, 20, 30 });
      }
  </code></pre>
  
  <p>However, this code still calls the real PdfReader and not the mock:</p>
  
  <p>iTextSharp.text.pdf.PdfReader.CheckPdfHeader
  iTextSharp.text.pdf.PdfReader.ReadPdf()
  iTextSharp.text.pdf.PdfReader..ctor(Byte[] pdfIn, Byte[] ownerPassword)
  iTextSharp.text.pdf.PdfReader..ctor(Byte[] pdfIn)</p>
  
  <p>and not surprisedly, it blows up with "..System.IO.IOException: PDF header signature not found..    "</p>
  
  <p>Not sure what I'm doing wrong....</p>
  
  <p>-Stan</p>