title: How can I provide a methods implementation using Moq?
body: <p>I have an interface with a few methods. I have a default implementation of this interface. For the purpose of integration tests I would like to create a mock implementation that returns my custom value if one of these methods is called, and falls back to the default implementation otherwise. Is it possible with Moq, or should I create a simple stub myself?</p>
  
  <p>EXAMPLE</p>
  
  <pre><code>IInterface default = new DefaultImplementation();
  var mock = new Mock&lt;IInterface&gt;();
  mock.Setup(i =&gt; i.Method(It.IsAny&lt;&gt;())).Calls(p =&gt; p==0 ? return 5 : default.Method(p););
  
  TheMethodITest(mock.Object()); //if it calls the object with 0 then it should get 5, otherwise it should call the default object
  </code></pre>