title: Mocking specific expression in repository
body: <p>I want to mock a specific expression in one of my repositories and I'm having some trouble.</p>
  
  <p>I currently have:  </p>
  
  <pre><code>Mock&lt;Container&gt; returnContainer = new Mock&lt;Container&gt;();
  Mock&lt;IRepository&lt;Container&gt;&gt; CntnrRepository =
      new Mock&lt;IRepository&lt;Container&gt;&gt;();
  
  CntnrRepository.Setup&lt;Container&gt;(repo =&gt; repo
      .Find(x =&gt; x.Name == "foo")
      .Returns(returnContainer.Object);
  </code></pre>
  
  <p>Whenever the following code runs it's returning null instead of my <code>Mock&lt;Container&gt;</code> above.</p>
  
  <pre><code>Container found = 
      containerRepository.Find(x =&gt; x.Name == cntnrName);
  </code></pre>
  
  <p>What am I doing wrong here?</p>
  
  <h2>Edit</h2>
  
  <p>Below is the code that is using the injected repository:  </p>
  
  <pre><code>public int Foo(Guid id, string name)
  {
      Container found = 
          containerRepository.Find(x =&gt; x.Name == name);
  
      if (found != null)
          return CONTAINER_NOT_FREE;
  
      Container cntnrToAssociate =
          containerRepository.Find(x =&gt; x.Id == cntnrId);
  
      if (cntnrToAssociate == null)
          return CONTAINER_NOT_FOUND;
  
      return OK;
  }
  </code></pre>
  
  <p>In the code above for one of my tests I need to return a value only in the first query (<code>Find</code>) to the <code>containerRepository</code></p>