title: Unit testing Void method which calls another void, starts Task()
body: <p>I'm looking for some advice on writing some unit tests for the code below. Implementation aside (it's not my code, but I've been tasked to retroactively write some tests for it) could someone suggest how I might test this? I'm not using nUnit or a similar framework; I am using the testing tools built into Visual Studio.</p>
  
  <p>I'm fairly new to writing unit tests, but I imagine I should at least test the following:</p>
  
  <ul>
  <li>Valid response passed into <code>SaveFormBrokerResponse()</code> method</li>
  <li>Test for valid exceptions thrown by the <code>catch()</code> </li>
  <li>Testing the started <code>Task</code>, but not sure how to do this</li>
  </ul>
  
  <p>I've stripped just a bit out of this function, mostly to do with instantiation and population of some objects:</p>
  
  <pre><code>public void SaveResponse(IForm form, bool isLive, HttpRequestBase request)
  {
      try
      {
          var response = new FormBrokerResponses();
          // Initialize some vars on response
  
          using (var memory = new MemoryStream())
          {
              var serializer = new DataContractSerializer(typeof(FormKeyValue[]));
              serializer.WriteObject(memory, request.Form.AllKeys.Select(r =&gt; new FormKeyValue(r, request.Form[r])).ToArray());
              memory.Flush();
              memory.Seek(0, SeekOrigin.Begin);
              response.Values = Encoding.UTF8.GetString(memory.ToArray());
          }
  
          _dataHandler.SaveFormBrokerResponses(response);
      }
      catch (Exception ex)
      {
          throw new Exception("boom explosions");
      }
  
      Task.Factory.StartNew(() =&gt; DispatchFormResponseViaEmail(form, isLive, request.Form.AllKeys.ToDictionary(r =&gt; r, r =&gt; (object)request.Form[r])));
  }
  </code></pre>
  
  <p>I realize that testing <code>void</code> implementations is tricky and questionable and that there are some integration test concerns here, but that said I can't (currently) change the implementation and need to write tests for what I have.</p>