title: Async unit testing with portable class libraries
body: <p>I have a portable class library that needs to target at least .net 4.5 and Silverlight 5. I'm running into an issue trying to write MSTest unit tests in VS 2012 because my library does not use the new async/await paradigm. Is there any way I can test this method?</p>
  
  <pre><code>public static void Get(string uri, string acceptHeader, Action&lt;string&gt; callback)
  {
      var request = (HttpWebRequest)WebRequest.Create(uri);
      request.Accept = acceptHeader;        
  
      request.BeginGetResponse(o =&gt;
      {
          var r = o.AsyncState as HttpWebRequest;
          try
          {
              var response = r.EndGetResponse(o);
              using (var sr = new StreamReader(response.GetResponseStream()))
              {
                  callback(sr.ReadToEnd());
              }
          }
          catch (Exception ex)
          {
              throw new WebException(string.Format("Unable to access {0}", uri), ex);
          }
      }, request);
  }
  </code></pre>