title: C# Unit Test DynamicDataDisplayName using MSTest
body: <p>I am performing some unit test using MSTest and I learned that I can use the <code>[DynamicData]</code> attribute to input different cases for testing, but I can't use the attribute property: <code>DynamicDataDisplayName</code> to set a name for the different cases.</p>
  <p>My test code is:</p>
  <pre><code>    [TestMethod]
      [DynamicData(nameof(TestInputs_BeReady), DynamicDataSourceType.Method,
          DynamicDataDisplayName = nameof(GetTestDisplayNames),
          DynamicDataDisplayNameDeclaringType = typeof(List&lt;string&gt;))]
      public void Should_BeReady(object expValue, object[] inputs)
      {
          // Arrange
  
          // Act
          ui.InputID = (string)inputs[0];
          ui.InputName = (string)inputs[1];
          ui.InputList = (List&lt;string&gt;)inputs[2];
  
          // Assert
          Assert.AreEqual(expValue, onReadyStateChangeArgs.Ready);
      }
  
      public static IEnumerable&lt;object[]&gt; TestInputs_BeReady()
      {
          return new[]
          {
              new object[] { true, new object[] { &quot;UTSZ0&quot;, &quot;Unit Test Size List&quot; , new List&lt;string&gt; { &quot;entry_01&quot;, &quot;entry_02&quot; } } },
              new object[] { false, new object[] { &quot;STEST&quot;, &quot;Unit Test Size List&quot; , new List&lt;string&gt; { &quot;entry_01&quot;, &quot;entry_02&quot; } } },
              new object[] { false, new object[] { &quot;&quot;, &quot;Unit Test Size List&quot; , new List&lt;string&gt; { &quot;entry_01&quot;, &quot;entry_02&quot; } } },
              new object[] { false, new object[] { &quot;UTSZ0&quot;, &quot;&quot; , new List&lt;string&gt; { &quot;entry_01&quot;, &quot;entry_02&quot; } } },
              new object[] { false, new object[] { &quot;UTSZ0&quot;, &quot;Unit Test Size List&quot;, new List&lt;string&gt;() } },
              new object[] { false, new object[] { &quot;UTSZ0&quot;, &quot;Unit Test Size List&quot;, null } }
          };
      }
  
      public static IEnumerable&lt;string&gt; GetTestDisplayNames() =&gt; new List&lt;string&gt; {
          &quot;All Valid&quot;, &quot;Duplicate ID&quot;, &quot;Missing ID&quot;, &quot;Missing Name&quot;, &quot;Empty List&quot;, &quot;Null List&quot;
      };
  </code></pre>
  <p>And I am getting this message in the test explorer result:</p>
  <blockquote>
  <p>Message: Value cannot be null.</p>
  <p>Parameter name: Method GetTestDisplayNames</p>
  </blockquote>
  <p>I searched the web on how to use the <code>DynamicDataDisplayName</code> but I was unable to come with something; all I found is how to use <code>DynamicData</code></p>
  <hr />
  <h2>EDIT</h2>
  <p>I used this code to add a customized names for the test inputs, thanks to</p>
  <blockquote>
  <p>Matěj Pokorný</p>
  </blockquote>
  <pre><code>    [TestMethod]
      [DynamicData(nameof(TestInputs_BeReady), DynamicDataSourceType.Method,
          DynamicDataDisplayName = nameof(GetTestDisplayName))]
      public void Should_DoSomething(object expValue, object[] inputs, string _)
      {
          // Arrange
          // Act
          // Assert
      }
      public static IEnumerable&lt;object[]&gt; TestInputs_BeReady()
      {
          List&lt;string&gt; ITEMS_LIST = new List&lt;string&gt; { &quot;entry_01&quot;, &quot;entry_02&quot; };
          List&lt;string&gt; BLANK_LIST = new List&lt;string&gt;();
  
          return new[]
          {
              new object[] {  true, new object[] { UQID, NAME, ITEMS_LIST }, &quot;All Valid&quot; },
              new object[] { false, new object[] { DPID, NAME, ITEMS_LIST }, &quot;Duplicate ID&quot; },
              new object[] { false, new object[] { BLNK, NAME, ITEMS_LIST }, &quot;Missing ID&quot; },
              new object[] { false, new object[] { UQID, BLNK, ITEMS_LIST }, &quot;Missing Name&quot; },
              new object[] { false, new object[] { UQID, NAME, BLANK_LIST }, &quot;Empty List&quot; },
              new object[] { false, new object[] { UQID, NAME, null }, &quot;Null List&quot; }
          };
      }
  </code></pre>