title: Mocking Async Task
body: <p>I have the following situation in my unit tests using Moq on .NET 4.0 using Microsoft BCL</p>
  
  <pre><code>Task&lt;MyClass&gt; mockTask = new Task&lt;MyClass&gt;(() =&gt; new MyClass());
  
  uploadHelper.Setup().Returns(mockTask);
  
  Task.WaitAll(mockTask);
  </code></pre>
  
  <p>The problem that I am facing is that Task.WaitAll(mockTask) simply blocks and never returns.</p>
  
  <p>What am I doing wrong here? </p>
  
  <p><strong>Edit</strong>
  Note that mockTask is async here in my context.</p>