title: How to mock a method that returns List<T>?
body: <p>I have below method :</p>
  
  <pre><code>public List&lt;ITestKeyword&gt; AddTests(TestEntity testEntity)
  {
      var DesignSteps = new List&lt;ITestKeyword&gt;();
      foreach (var testCase in testEntity.TestCases)
      {
          DesignSteps.AddRange(testCase.GetTestStepKeywords());
      }
      return DesignSteps;
  }
  </code></pre>
  
  <p>It is invoked as below:</p>
  
  <pre><code>var listCount= _TestHelper.AddTests(testEntity).Count;
  </code></pre>
  
  <p>Here is how I try to mock it :</p>
  
  <pre><code>_mockTestHelper
      .Setup(s =&gt; s.AddTests(It.IsAny&lt;TestEntity&gt;()))
      .Returns(It.IsAny&lt;List&lt;ITestKeyword&gt;&gt;());
  </code></pre>
  
  <p>But it doesn't seem to work. It is throwing null reference exception. I'm not able to figure out. Could anyone please help?</p>