title: Partial mocking a class internal method with Moq
body: <p>I have a class that contains a public method, that relies on a internal method in order to properly return its value.</p>
  
  <p>Let's consider the following class and test file:</p>
  
  <pre class="lang-cs prettyprint-override"><code>public class ClassUnderTest
  {
      public string NotMockedPublicMethod()
      {
          return MockedMethod();
      }
  
      virtual public string MockedMethod()
      {
          return "original";
      }
  }
  </code></pre>
  
  <p>The following test case would work:</p>
  
  <pre class="lang-cs prettyprint-override"><code>var mock = new Mock&lt;ClassUnderTest&gt; { CallBase = true };
  mock.Setup(m =&gt; m.MockedMethod()).Returns("mocked");
  
  Assert.AreEqual("mocked", mock.Object.NotMockedPublicMethod());
  </code></pre>
  
  <p>But let's say this <code>MockedMethod()</code> of mine has no utility externally. The problem is that marking this method as <code>internal</code> (even using <code>InternalsVisibleTo()</code> properly):</p>
  
  <pre class="lang-cs prettyprint-override"><code>virtual internal string MockedMethod()
  </code></pre>
  
  <p>will make the exactly same test fails with the message <code>Assert.AreEqual failed. Expected:&lt;mocked&gt;. Actual:&lt;original&gt;</code>.</p>
  
  <p>Is this a Moq bug or some limitation?</p>