title: Why am I getting an Exception with the message "Invalid setup on a non-virtual (overridable in VB) member..."?
body: <p>I have a unit test where I have to mock a non-virtual method that returns a bool type</p>
  
  <pre><code>public class XmlCupboardAccess
  {
      public bool IsDataEntityInXmlCupboard(string dataId,
                                            out string nameInCupboard,
                                            out string refTypeInCupboard,
                                            string nameTemplate = null)
      {
          return IsDataEntityInXmlCupboard(_theDb, dataId, out nameInCupboard, out refTypeInCupboard, nameTemplate);
      }
  }
  </code></pre>
  
  <p>So I have a mock object of <code>XmlCupboardAccess</code> class and I am trying to setup mock for this method in my test case as shown below</p>
  
  <pre><code>[TestMethod]
  Public void Test()
  {
      private string temp1;
      private string temp2;
      private Mock&lt;XmlCupboardAccess&gt; _xmlCupboardAccess = new Mock&lt;XmlCupboardAccess&gt;();
      _xmlCupboardAccess.Setup(x =&gt; x.IsDataEntityInXmlCupboard(It.IsAny&lt;string&gt;(), out temp1, out temp2, It.IsAny&lt;string&gt;())).Returns(false); 
      //exception is thrown by this line of code
  }
  </code></pre>
  
  <p>But this line throws exception </p>
  
  <pre><code>Invalid setup on a non-virtual (overridable in VB) member: 
  x =&gt; x.IsDataEntityInXmlCupboard(It.IsAny&lt;String&gt;(), .temp1, .temp2, 
  It.IsAny&lt;String&gt;())
  </code></pre>
  
  <p>Any suggestion how to get around this exception?</p>