title: Assert.ThrowsExceptionAsync isn't working
body: <h2>Question:</h2>
  <p>I haven't found much about <a href="https://blogs.msdn.microsoft.com/visualstudioalm/2016/06/17/taking-the-mstest-framework-forward-with-mstest-v2/" rel="noreferrer">MSTest V2</a> for examples or <a href="http://dotnetapis.com/pkg/MSTest.TestFramework/" rel="noreferrer">documentation</a>. What is the correct way to use Assert.ThrowsExceptionAsync?</p>
  <pre><code>public void GetPlaylistByIdAsync_NonExistingPlaylist_ThrowsPlaylistNotFoundException()
  {
      var playlistId = Guid.NewGuid().ToString();
      var manager = PlaylistTargetsFakeFactory.GetPlaylistTargetFusionManager();
      Assert.ThrowsException&lt;PlaylistNotFoundException&gt;(async () =&gt;
      {
         await manager.GetPlaylistByIdAsync(playlistId);
      });
  }
  </code></pre>
  <p>this also fails the test:</p>
  <pre><code>Assert.ThrowsException&lt;PlaylistNotFoundException&gt;(() =&gt;
  {
      return manager.GetPlaylistByIdAsync(playlistId);
  });
  </code></pre>
  <blockquote>
  <p>Message: Assert.ThrowsException failed. No exception thrown.
  PlaylistNotFoundException exception was expected.</p>
  </blockquote>
  <p>This is failing for me, even though I've debugged it and the exception is definitely thrown.</p>
  <p>Since this is still an RC, it's possible there is a bug. I've had this in 2 tests I'm trying to convert so I can use VS 2017.</p>
  <h2><em>Update:</em> This passes.</h2>
  <pre><code>[TestMethod]
  public async Task GetPlaylistByIdAsync_NonExistingPlaylist_ThrowsPlaylistNotFoundException()
  {
      var playlistId = Guid.NewGuid().ToString();
      var manager = PlaylistTargetsFakeFactory.GetPlaylistTargetFusionManager();
      //Assert.ThrowsException&lt;PlaylistNotFoundException&gt;(() =&gt;
      //{
  
      try
      {
          await manager.GetPlaylistByIdAsync(playlistId);
          Assert.Fail();
      }
      catch (PlaylistNotFoundException)
      {
          Assert.IsTrue(true);
      }
  
      //});
  }
  </code></pre>
  <p><strong>Update 2:</strong> After Stephen Cleary's answer, I made this change. Thanks for pointing out my mis-use. I had changed it awhile back because I get &quot;Message: Test method .Test.Models.Helpers.PlaylistTargetFusionManagerTests.GetPlaylistByIdAsync_NonExistingPlaylist_ThrowsPlaylistNotFoundException threw exception:
  System.MissingMethodException: Method not found: 'System.Threading.Tasks.Task<code>1&lt;!!0&gt; Microsoft.VisualStudio.TestTools.UnitTesting.Assert.ThrowsExceptionAsync(System.Func</code>1&lt;System.Threading.Tasks.Task&gt;)'.&quot; when I run the test.</p>
  <pre><code>[TestMethod]
  [TestCategory(TestCategories.CSharp)]
  [TestCategory(TestCategories.PlaylistTargets)]
  public async Task GetPlaylistByIdAsync_NonExistingPlaylist_ThrowsPlaylistNotFoundException()
  {
      var playlistId = Guid.NewGuid().ToString();
      var manager = PlaylistTargetsFakeFactory.GetPlaylistTargetFusionManager();
      await Assert.ThrowsExceptionAsync&lt;PlaylistNotFoundException&gt;(() =&gt; manager.GetPlaylistByIdAsync(playlistId));
  }
  </code></pre>
  <p>I have 2 packages in my packages.json</p>
  <pre><code> &lt;package id=&quot;MSTest.TestAdapter&quot; version=&quot;1.1.9-rc2&quot; targetFramework=&quot;net451&quot; /&gt;
   &lt;package id=&quot;MSTest.TestFramework&quot; version=&quot;1.0.8-rc2&quot; targetFramework=&quot;net451&quot; /&gt;
  </code></pre>