title: How to mock a class without default constructor using Mock.Of<T>()?
body: <p>Using Moq, I need to create a fake over an existing <strong>class</strong> (not interface*) that has <strong>no default ctor</strong>. </p>
  
  <p>I can do this using the "traditional" syntax:</p>
  
  <pre><code>var fakeResponsePacket = new Mock&lt;DataResponse&gt;(
      new object[]{0, 0, 0, new byte[0]}); //specify ctor arguments
  
  fakeResponsePacket.Setup(p =&gt; p.DataLength).Returns(5);
  
  var checkResult = sut.Check(fakeResponsePacket.Object);
  </code></pre>
  
  <p>My question is: Is there a way to do the same using the newer <code>Mock.Of&lt;T&gt;()</code> syntax ?</p>
  
  <p>From what I can see, there are only two overloads for <code>Mock.Of&lt;T&gt;</code>, none of which accept arguments:</p>
  
  <pre><code>//1 no params at all
  var fakeResponsePacket = Mock.Of&lt;DataResponse&gt;(/*??*/);
  fakeResponsePacket.DataLength = 5;
  
  //2 the touted 'linq to Moq'
  var fakeResponsePacket = Mock.Of&lt;DataResponse&gt;(/*??*/
      p =&gt; p.DataLength == 5
  );
  
  var checkResult = sut.Check(fakeResponsePacket);
  </code></pre>
  
  <p>--<br>
  * I <em>wanted</em> to use an interface. But then reality happened. Let's not go into it.</p>