title: How to mock an interface that extends IEnumerable
body: <p>I'm using Moq and I have the following interface:</p>
  
  <pre><code>public interface IGameBoard : IEnumerable&lt;PieceType&gt;
  {
      ...  
  }
  public class GameBoardNodeFactory
  {
      public virtual GameBoardNode Create (int row, int column, IGameBoard gameBoard)
      {
          ...
      }
  }
  </code></pre>
  
  <p>Then I have a test like this:</p>
  
  <pre><code>var clonedGameBoardMock = new Mock&lt;IGameBoard&gt; (MockBehavior.Loose);
  var gameBoardNodeFactoryMock = new Mock&lt;GameBoardNodeFactory&gt; ();
  gameBoardNodeFactoryMock.Setup (x =&gt;
      x.Create (
          position.Row,
          position.Column,
          clonedGameBoardMock.Object)).Returns (new GameBoardNode { Row = position.Row, Column = position.Column });
  </code></pre>
  
  <p>But then gameBoardNodeFactoryMock.Object.Create (position.Row, position.Column, clonedGameBoardMock.Object) throws a NullReferenceException. I tried to create a mock for the IGameBoard such that it doesn't extend IEnumerable&lt;PieceType&gt; interface and then it works.</p>
  
  <p>Any help is appreciated.</p>