title: Moq.Mock<T> - how to set up a method that takes an expression
body: <p>I am Mocking my repository interface and am not sure how to set up a method that takes an expression and returns an object? I am using Moq and NUnit.</p>
  
  <p>Interface:</p>
  
  <pre><code>public interface IReadOnlyRepository : IDisposable
  {
      IQueryable&lt;T&gt; All&lt;T&gt;() where T : class;
      T Single&lt;T&gt;(Expression&lt;Func&lt;T, bool&gt;&gt; expression) where T : class;
  }
  </code></pre>
  
  <p>Test with IQueryable is already set up, but don't know how to set up the T Single:</p>
  
  <pre><code>private Moq.Mock&lt;IReadOnlyRepository&gt; _mockRepos;
  private AdminController _controller;
  [SetUp]
  public void SetUp()
  {
      var allPages = new List&lt;Page&gt;();
      for (var i = 0; i &lt; 10; i++)
      {
          allPages.Add(new Page { Id = i, Title = "Page Title " + i, Slug = "Page-Title-" + i, Content = "Page " + i + " on page content." });
      }
      _mockRepos = new Moq.Mock&lt;IReadOnlyRepository&gt;();
      _mockRepos.Setup(x =&gt; x.All&lt;Page&gt;()).Returns(allPages.AsQueryable());
      //Not sure what to do here???
      _mockRepos.Setup(x =&gt; x.Single&lt;Page&gt;()
      //----
      _controller = new AdminController(_mockRepos.Object);
  }
  </code></pre>