title: Unit testing asynchronous code
body: <p>I have simple class with simple method like this:</p>
  
  <pre><code>partial class SimpleClass
  {
      private readonly ISimpleManager _simpleManager;
      public SimpleClass(ISimpleManager simpleManager)
      {
          _simpleManager = simpleManager;
      }
  
      public async void SimpleMethod()
      {
          IsInProgress = true;
          DoSomeWork();
          Task&lt;int&gt; hardWork0Task = _simpleManager.DoHardWork0Async();
          Task&lt;int&gt; hardWork1Task = _simpleManager.DoHardWork1Async();
          DoIndependentWork();
          int hardWork0Result = await hardWork0Task.ConfigureAwait(false);
          DoDependentWork(hardWork0Result);
          int hardWork1Result = await hardWork1Task.ConfigureAwait(false);
          DoDependentWork(hardWork1Result);
          IsInProgress = false;
      }
  }
  </code></pre>
  
  <p>Let's assume that property <code>IsInProgress</code> is just <code>bool</code> property notifying GUI about its state to allow refreshing progress bar. <code>DoSomeWork</code>, <code>DoDependentWork</code> and <code>DoIndependentWork</code> are some methods using or not results of hard work. </p>
  
  <p><code>ISimpleManager</code> is the most simple interface you can imagine in this case:</p>
  
  <pre><code>interface ISimpleManager
  {
      Task&lt;int&gt; DoHardWork0Async();
      Task&lt;int&gt; DoHardWork1Async();
  }
  </code></pre>
  
  <p>I have to write some unit tests using Moq and NUnit. How can I write unit tests for this case? I would like to check if state of <code>IsInProgress</code> property hasn't changed to false during entire code running asynchronously with GUI. Does it make sense? Is it possible? What if my <code>async</code> method returns <code>Task</code> or generic <code>Task&lt;T&gt;</code>? What if I configure awaits for <code>true</code>?</p>