title: Mock IRavenQueryable with a Where() expression appended
body: <p>I'm trying to do some basic proof of concept type code for a new mvc3 project.  We are using Moq with RavenDB.</p>
  
  <p>Action:</p>
  
  <pre><code>public ActionResult Index(string id)
  {
      var model = DocumentSession.Query&lt;FinancialTransaction&gt;()
          .Where(f =&gt; f.ResponsibleBusinessId == id);
      return View(model);
  }
  </code></pre>
  
  <p>Test:</p>
  
  <pre><code>private readonly Fixture _fixture = new Fixture();
  
  [Test]
  public void Index_Action_Returns_List_Of_FinancialTransactions_For_Business([Random(0, 50, 5)]int numberOfTransactionsToCreate)
  {
      // Arrange
      var session = new Mock&lt;IDocumentSession&gt;();
      var financialController = new FinancialController { DocumentSession = session.Object };
  
      var businessId = _fixture.CreateAnonymous&lt;string&gt;();
      var transactions = _fixture.Build&lt;FinancialTransaction&gt;()
          .With(f =&gt; f.ResponsibleBusinessId, businessId)
          .CreateMany(numberOfTransactionsToCreate);
  
      // Mock
      var ravenQueryableMock = new Mock&lt;IRavenQueryable&lt;FinancialTransaction&gt;&gt;();
      ravenQueryableMock.Setup(x =&gt; x.GetEnumerator()).Returns(transactions.GetEnumerator);
      ravenQueryableMock.Setup(x =&gt; x.Customize(It.IsAny&lt;Action&lt;Object&gt;&gt;()).GetEnumerator()).Returns(() =&gt; transactions.GetEnumerator());
  
      session.Setup(s =&gt; s.Query&lt;FinancialTransaction&gt;()).Returns(ravenQueryableMock.Object).Verifiable(); 
  
      // Act
      var actual = financialController.Index(businessId) as ViewResult;
  
      // Assert
      Assert.IsNotNull(actual);
      Assert.That(actual.Model, Is.InstanceOf&lt;List&lt;FinancialTransaction&gt;&gt;());
  
      var result = actual.Model as List&lt;FinancialTransaction&gt;;
      Assert.That(result.Count, Is.EqualTo(numberOfTransactionsToCreate));
      session.VerifyAll();
  }
  </code></pre>
  
  <p>It would appear the problem is in the .Where(f => f.ResponsibleBusinessId == id).  From the mocked IRavenQueryable, I'm returning a list of FinancialTransactions, so one would think the .Where() would filter based on that.  But since it's IQueryable, I'm guessing it's trying to execute the expression all as one, when it's enumerating.</p>
  
  <p>To verify, I changed the action's query to this:</p>
  
  <pre><code>var model = DocumentSession.Query&lt;FinancialTransaction&gt;()
      .ToList()
      .Where(f =&gt; f.ResponsibleBusinessId == id);
  </code></pre>
  
  <p>This does let the test pass, however, it's not ideal, as that means it's going to enumerate all the records, then filter them.</p>
  
  <p>Is there any way to get Moq work with this?</p>