title: Dynamic assertions based on [InlineData] or [MemberData]
body: <p>currently we are developing some bigger component tests. These are relying on some rather more complex data generators, which are creating data basis of some templates.</p>
  
  <p><strong>Problem</strong></p>
  
  <p>While testing with xUnit we feeding the test with the help of <code>[InlineData]</code>:</p>
  
  <pre><code>[Theory]
  [InlineData(Device.Type1, DeviceConfig.VeryHotDevice)]
  [InlineData(Device.Type1, DeviceConfig.VeryColdDevice)]
  public async Task TestCalculation(string deviceType, DeviceConfig deviceConfig)
  </code></pre>
  
  <p>The problem I have is regarding the Assertions for the different <code>DeviceConfig</code> values. I have to create an <code>switch</code>-statement with cases for every single one in the test method:</p>
  
  <pre><code>switch (simConfig)
  {
      case DeviceConfig.VeryHotDevice:
          AssertVeryHotDevice(resultData);
      break;
      case DeviceConfig.VeryColdDevice:
          AssertVeryVoldDevice(resultData);
      break;
  }
  </code></pre>
  
  <p>What I would like to have is something like the following. So basically just pass the method with the assertions for the specific <code>[InlineData]</code> and <code>.Invoke</code> it inside the test method.</p>
  
  <pre><code>[Theory]
  [InlineData(Device.Type1, DeviceConfig.VeryHotDevice, )]
  [InlineData(Device.Type1, DeviceConfig.VeryColdDevice)]
  public async Task TestCalculation(string deviceType, DeviceConfig deviceConfig, Action&lt;ResultData&gt; assertAction)
  </code></pre>
  
  <p>Without going into details I already got this working by changing <code>[InlineData]</code> to <code>[MemberData]</code> with help of this answer (<a href="https://stackoverflow.com/a/45305323/1444145">Lambda expression as inline data in xUnit</a>).</p>
  
  <p>Sadly you then run into following issue (<a href="https://stackoverflow.com/q/30574322/1444145">MemberData tests show up as one test instead of many</a>), because the <code>Actions</code> are not <code>IXunitSerializable</code>.</p>
  
  <p>For me it's neither acceptable to show only one test (while it in reality are three to four), nor to implement some unconvenient clutter code to support <code>IXunitSerializable</code>.</p>
  
  <p><strong>Question</strong></p>
  
  <p>How would you keep the assertions here some kind of dynamic and pass them directly with the test data with the goal to keep the test method clean? Of course I would also be happy, if you propose something completely different.</p>