title: How to force moq to call the constructor?
body: <p>I have a unit test to verify that an object (say <code>Foo</code>) will call certain method (say <code>Bar</code>) when an event is fired with certain eventArgs. To mock the said method, I use virtual and stub the <code>Foo</code> class</p>
  
  <pre><code>Mock&lt;Foo&gt; stubbedFoo = new Mock&lt;Foo&gt;(mockEventProvider);
  
  mockEventProvider.Raise( x =&gt; x.MyEvent += null, myEventArgs ) //fire the event
  stubbedFoo.Verify(foo =&gt; foo.Bar()); verify Bar is called as a result
  </code></pre>
  
  <p>However, the above failed, Bar will not be called, apparently because the Foo object is not event constructed. However if I add a line like below:</p>
  
  <pre><code>Mock&lt;Foo&gt; stubbedFoo = new Mock&lt;Foo&gt;(mockEventProvider);
  var workAround = stubbedFoo.Object //adding this workaround will work
  mockEventProvider.Raise( x =&gt; x.MyEvent += null, myEventArgs ) //fire the event
  stubbedFoo.Verify(foo =&gt; foo.Bar()); verify Bar is called as a result
  </code></pre>
  
  <p>It will work, because calling get on .Object apparently forces mock to construct the object. Is there a more elegant solution than adding this line ?</p>