title: Task.Wait() deadlocks Xamarin.iOS NUnit runner
body: <p>I have a class with some methods like this:</p>
  
  <pre><code>private Task Sleep()
  {
      return Task.Delay(SleepDuration);
  }
  
  public async Task&lt;User&gt; Login(string username, string password)
  {
      await Sleep();
  
      return new User { Id = 1, Username = username };
  }
  </code></pre>
  
  <p>Note, <code>SleepDuration</code> is set to 0 during my tests.</p>
  
  <p>If I call the following in an iOS NUnit project test:</p>
  
  <p><code>myClass.Login("username", "password").Wait();</code></p>
  
  <p>The test runner's UI pauses and never completes. If I add break points, the code never reaches the line after the <code>await</code>. The same test works fine running in the standard NUnit runner in a .Net 4.5 Mono project. It also works fine in my application, although I never call <code>Wait</code> and always use async/await.</p>
  
  <p>Any ideas? Is there something else I can use instead of <code>Task.Delay</code> to prevent the deadlock? I tried <code>Task.Factory.StartNew(() =&gt; { })</code> already.</p>