title: How do I return a new object from a mocked repository using a LINQ Expression?
body: <p>I am using Rhino Mocks and have created a Mock Repository. </p>
  
  <pre><code>var salesForcePolicies = MockRepository.GenerateMock&lt;IRepository&lt;SalesForcePolicy&gt;&gt;();
  </code></pre>
  
  <p>I have a private method to return a <code>policy</code> item from the repository.</p>
  
  <pre><code>private SalesForcePolicy GetSalesForcePolicyByClientId(decimal clientId)
  {
      var policy = salesForcePolicies.FindByExp(x =&gt; x.IdNumber == clientId).FirstOrDefault();
      if (policy == null) throw new AccountUpdaterException("Policy Not Found in Sales Force Lookup Table.");
      return policy;
  }
  </code></pre>
  
  <p>I am trying to get the repository to return a new object with one property set when the query is called in the <code>private</code> method. I do not want to break the encapsulation and set to <code>public virtual</code>.</p>
  
  <p>The compiler is screaming when I write this...</p>
  
  <pre><code>var clientId = decimal.Parse("123456");
  salesForcePolicies.Stub(x =&gt; x.FindByExp(y =&gt; y.IdNumber == clientId)).Return(new SalesForcePolicy { PolicyNumber = "123456" });
  </code></pre>
  
  <p>How can I get this mocked repository to return a new object when it is queried?</p>
  
  <pre><code>Error: The best overloaded method match for 'Rhino.Mocks.Interfaces.IMethodOptions&lt;System.Linq.IQueryable&lt;Data.Models.Ussi.SalesForcePolicy&gt;&gt;.Return(System.Linq.IQueryable&lt;Data.Models.Ussi.SalesForcePolicy&gt;)' has some invalid arguments.
  </code></pre>