title: Assert an Exception using XUnit
body: <p>I am a newbie to XUnit and Moq. I have a method which takes string as an argument.How to handle an exception using XUnit.</p>
  
  <pre><code>[Fact]
  public void ProfileRepository_GetSettingsForUserIDWithInvalidArguments_ThrowsArgumentException() {
      //arrange
      ProfileRepository profiles = new ProfileRepository();
      //act
      var result = profiles.GetSettingsForUserID("");
      //assert
      //The below statement is not working as expected.
      Assert.Throws&lt;ArgumentException&gt;(() =&gt; profiles.GetSettingsForUserID(""));
  }
  </code></pre>
  
  <p>Method under test</p>
  
  <pre><code>public IEnumerable&lt;Setting&gt; GetSettingsForUserID(string userid)
  {            
      if (string.IsNullOrWhiteSpace(userid)) throw new ArgumentException("User Id Cannot be null");
      var s = profiles.Where(e =&gt; e.UserID == userid).SelectMany(e =&gt; e.Settings);
      return s;
  }
  </code></pre>