title: How to test for exceptions and a return value from a lambda expression in an NUnit Assert.That clause
body: <p>I'm performing a simple NUnit test, and want to confirm there is no exceptions in my method. However, this method will return something: and I want to test on the returned value <strong>as well</strong>.</p>
  
  <p>Here is my existing code which tests for exceptions (this works!):</p>
  
  <pre><code>// This works
  [Test]
  public void AbleToGetTheDatabaseNames()
  {
      Assert.That( () =&gt; GetTheDatabaseNames(), Throws.Nothing);
  }
  private List&lt;string&gt; GetTheDatabaseNames()
  {
      var mySql = new MySqlDb();
      return mySql.GetDatabaseNames();
  }
  </code></pre>
  
  <p>However, in the lambda expression <code>() =&gt; GetTheDatabaseNames()</code> how do I get at the returned value, so I can then go ahead and test the returned List of strings?</p>
  
  <pre><code>// This doesn't work
  [Test]
  public void AbleToGetTheDatabaseNames()
  {
      Assert.That( () =&gt; GetTheDatabaseNames(), Throws.Nothing);
      Assert.That( retVal, Has.Count.EqualTo(1));
  }
  private List&lt;string&gt; GetTheDatabaseNames()
  {
      var mySql = new MySqlDb();
      return mySql.GetDatabaseNames();
  }
  </code></pre>
  
  <p>How do I get <code>retVal</code> from the lambda expression so I can get at the returned <code>List&lt;string&gt;</code>? Is it even possible to do it here? If not, what would be the recommended pattern - should I call <code>GetTheDatabaseNames()</code> twice (which would seem superfluous) ?</p>