title: Moq return value for object using Mock.of?
body: <p>I need to mock the return value of a method in an object. I have something like this:</p>
  
  <pre><code>var mock = Mock.Of&lt;IExample&gt;( x =&gt; x.GetAll() == new List&lt;IOtherExample&gt;()) ;
  </code></pre>
  
  <p>but I get an error. If I use GetAll as property instead it works:</p>
  
  <pre><code>var mock = Mock.Of&lt;IExample&gt;( x =&gt; x.GetAll == new List&lt;IOtherExample&gt;()) ;
  </code></pre>
  
  <p>I know I can do this using new Mock, Setup and Return like this:</p>
  
  <pre><code>mock.Setup(x =&gt; x.GetAll()).Returns(new List&lt;IOtherExample&gt;());
  </code></pre>
  
  <p>but I would like to learn how to do this using Mock.Of.</p>
  
  <p>The error looks something like this:</p>
  
  <pre><code> Expression of type 'System.Collections.Generic.List' cannot be used for parameter of type 'System.Collections.Generic.IList' of method 'Moq.Language.Flow.IReturnsResult' Returns(System.Collections.Generic.IList)'
  </code></pre>
  
  <p>Again keep in mind that it works if GetAll is a property.</p>
  
  <p>Thank you.</p>
  
  <pre><code>public interface IExample : IGenericExample&lt;IOtherExample&gt;
  {
  
  }
  
  public interface IGenericExample&lt;T&gt;
  {
     IList&lt;T&gt; GetAll()
  }
  </code></pre>