title: How should I be Mocking this simple Service layer method?
body: <p>I have the following simple method, in my Service layer. I'm not sure how I should mock out the different chained parts, starting from the repository?</p>
  <pre><code>public ICollection&lt;GameFile&gt; FindAllActiveGamesFiles()
  {
      return _gameFileRepository // &lt;- this is an IRepository&lt;GameFile&gt;
          .Find() // &lt;-- returns an IQueryable&lt;T&gt; .. in this case, an IQueryable&lt;GameFile&gt;
          .WhereIsActive() // &lt;-- a simple Pipe/Filter; 'where x.IsActive'
          .ToList();
  }
  </code></pre>
  <p>My preference is to use Moq, but I'm very happy to see other implimentations .. mainly because i'm not after the exact syntax answer, but the theortical answer. Ie. U need to mock the <code>IRepository&lt;GameFile&gt;</code> and setup the <code>ToList()</code> method only .. blah blah blah...</p>
  <p>That's the stuff I don't get what I should be mocking.</p>
  <p>Cheers :)</p>
  <h2>--- Update : to clarify my question</h2>
  <p>What i'm trying to test is that the method 'FindAllActiveGamesFiles()' works. As such, I believe I need to mock the gameFileRepository (which is an interface). I'm not sure if this is the ONLY thing i should be mocking in this example.</p>
  <p>eg.</p>
  <pre><code>[TestMethod]
  public void MyTest()
  {
      // Arrange.
      Mock&lt;IRepository&lt;GameFile&gt;&gt; mockRepository = new Mock&lt;IRepository&lt;GameFile&gt;&gt;();
      mockRepository.Setup(....).MoreStuffToDo(...); // &lt;-- that's what i'm unsure about.
      IGameFileService = new GameFileService(mockRepository, fakeLoggingService);
  
      // Act.
      var gameFiles = gameFileService.FindAllActiveGamesFiles();
  
      // Asserts.
      Assert.IsNotNull(gameFiles);
      CollectionAssert.AllItemsAreNotNull(gameFiles.ToArray());
      // .. and more asserts ///
      // What about expectations? eg. that ToList() was entered/called?
  }
  </code></pre>