title: Moq.Mock<T> setting up expressions into a Mock using MOQ results in mock setups not being matched
body: <p>I am trying to mock out a data service context, as part of this I have a method which takes in </p>
  
  <ul>
  <li>an expression (predicate), </li>
  <li>an optional string parameter</li>
  <li>a params with an array of predicates.</li>
  </ul>
  
  <p>when I try to mock this method out, MOQ always returns a </p>
  
  <p>All invocations on the mock must have a corresponding setup.
  TearDown : Moq.MockException : The following setups were not matched:
  IContext m => m.Retrieve(It.IsAny() })</p>
  
  <p>code below of the interface/implementation</p>
  
  <pre><code>public interface IContext
  {
      IQueryable&lt;T&gt; Retrieve&lt;T&gt;(Expression&lt;Func&lt;T, bool&gt;&gt; predicate,
                                  string entitySetName = null,
                                  params Expression&lt;Func&lt;T, object&gt;&gt;[] eagerProperties);
  }
  
  public class Context : IContext
  {
      private readonly DataServiceContext _context;
  
      public Context(DataServiceContext context)
      {
          this._context = context;
      }
  
      public IQueryable&lt;T&gt; Retrieve&lt;T&gt;(Expression&lt;Func&lt;T, bool&gt;&gt; predicate,
                                          string entitySetName = null,
                                          params Expression&lt;Func&lt;T, object&gt;&gt;[] eagerProperties)
      {
          DataServiceQuery&lt;T&gt; query = _context.CreateQuery&lt;T&gt;(entitySetName ?? "Default");
          return eagerProperties.Aggregate(query, (current, e) =&gt; current.Expand(e.ToString())).Where(predicate);
      }
  }
  </code></pre>
  
  <p>The below is a test class that calls the above context method</p>
  
  <pre><code>public class Test
  {
      public string Prop1 { get; set; }
      public string Prop2 { get; set; }
      public string Prop3 { get; set; }
  }
  
  public class SomeController
  {
      private IContext _context = new Context(
          new DataServiceContext(new Uri("http://whatever/someservice.svc/")));
  
      public IContext ServiceContext
      {
          get
          {
              return _context ??
                     (_context = new Context(new DataServiceContext(new Uri("http://whatever/someservice.svc/"))));
          }
          set
          {
              _context = value;
          }
      }
  
      public Test RetrieveSomeInformation()
      {
          IQueryable&lt;Test&gt; tests = _context.Retrieve&lt;Test&gt;
                                                  (
                                                      //Param 1
                                                      t =&gt; t.Prop1 == "test" &amp;&amp; 1 == 1,
  
                                                      //Param 2
                                                      "Test",
  
                                                      //Param 3
                                                      t =&gt; t.Prop1,
                                                      t =&gt; t.Prop2,
                                                      t =&gt; t.Prop3
                                                    );
          return tests.First();
      }
  }
  </code></pre>
  
  <p>Below is the actual test that MOQ fails with a "All invocations on the mock must have a corresponding setup."  Can't see why on earth the setup wont be matched! any help would be appreciated.</p>
  
  <pre><code>[TestFixture]
  public class ControllerTests
  {
      public MockRepository Repository { get; set; }
      protected Mock&lt;IContext&gt; MockContext { get; set; }
      public SomeController Controller;
  
      public List&lt;Test&gt; Tests;
      public Test Test;
  
      [SetUp]
      public void SetUp()
      {
          Test = new Test { Prop1 = "1", Prop2 = "2", Prop3 = "3" };
          Tests = new List&lt;Test&gt; { Test };
  
          Repository = new MockRepository(MockBehavior.Strict);
  
          MockContext = Repository.Create&lt;IContext&gt;();
  
          Controller = new SomeController { ServiceContext = MockContext.Object };
      }
  
      [TearDown]
      public void TearDown()
      {
          Repository.VerifyAll();
      }
  
      [Test]
      public void DetailProgramme_Test()
      {
          MockContext.Setup(m =&gt; m.Retrieve&lt;Test&gt;
                              (
                                  //Param 1
                                  It.IsAny&lt;Expression&lt;Func&lt;Test, bool&gt;&gt;&gt;(),
  
                                  //Param 2
                                  It.IsAny&lt;string&gt;(),
  
                                  //Param 3
                                  It.IsAny&lt;Expression&lt;Func&lt;Test, object&gt;&gt;&gt;()
                              )
                            ).Returns(Tests.AsQueryable());
  
          Test info = Controller.RetrieveSomeInformation();
  
  
          //myMock.Setup(r =&gt; r.Find(It.IsAny&lt;Expression&lt;Func&lt;Person, bool&gt;&gt;&gt;())).Returns(new List&lt;Person&gt;() { new Person() }.AsQueryable());
          Assert.IsTrue(info == Test);
      }
  }
  </code></pre>