title: Using Moq with Linq Any()
body: <p>I have a setup similar to below:</p>
  
  <pre><code>    [TestMethod]
      public void NoIntegers()
      {
          Mock&lt;IBar&gt; mockBar = new Mock&lt;IBar&gt;(MockBehavior.Strict);
          Mock&lt;IEnumerable&lt;int&gt;&gt; mockIntegers = new Mock&lt;IEnumerable&lt;int&gt;&gt;(MockBehavior.Strict);
  
          mockBar
              .SetupGet(x =&gt; x.Integers)
              .Returns(mockIntegers.Object);
  
          mockIntegers
              .Setup(x =&gt; x.Any())
              .Returns(false);
  
          Assert.IsFalse(new Foo(mockBar.Object).AreThereIntegers());
      }
  
      public interface IBar
      {
          IEnumerable&lt;int&gt; Integers { get; }
      }
  
      public class Foo
      {
          private IBar _bar;
  
          public Foo(IBar bar)
          {
              _bar = bar;
          }
  
          public bool AreThereIntegers()
          {
              return _bar.Integers.Any();
          }
      }
  }
  </code></pre>
  
  <p>When it runs it fails to initialise the mock</p>
  
  <pre><code>Test method NoIntegers threw exception: System.NotSupportedException: Expression references a method that does not belong to the mocked object: x =&gt; x.Any&lt;Int32&gt;()
  </code></pre>
  
  <p>I have tries adding <code>It.IsAny()</code> in a few forms:</p>
  
  <pre><code>mockIntegers
      .Setup(x =&gt; x.Any(It.IsAny&lt;IEnumerable&lt;int&gt;&gt;(), It.IsAny&lt;Func&lt;int, bool&gt;&gt;()))
      .Returns(false);
  
  // No method with this signiture
  
  
  mockIntegers
      .Setup(x =&gt; x.Any(It.IsAny&lt;Func&lt;int, bool&gt;&gt;()))
      .Returns(false);
  
  // Throws: Test method NoIntegers threw exception: 
  // System.NotSupportedException: 
  // Expression references a method that does not belong to the mocked object:
  //  x =&gt; x.Any&lt;Int32&gt;(It.IsAny&lt;Func`2&gt;())
  </code></pre>
  
  <p>What do I need to mock in order for this to run?</p>