title: Verifying protected abstract methods are called using Moq
body: <p>Suppose I have the following class:</p>
  
  <pre><code>public class TestBase
  {
    public bool runMethod1 { get; set; }
  
    public void BaseMethod() 
    {
      if (runMethod1)
        ChildMethod1();
      else 
        ChildMethod2();
    }
  
    protected abstract void ChildMethod1();
    protected abstract void ChildMethod2();
  }
  </code></pre>
  
  <p>I also have the class</p>
  
  <pre><code>public class ChildTest : TestBase
  {
    protected override void ChildMethod1()
    {
      //do something
    } 
  
    protected override void ChildMethod2()
    {
      //do something completely different
    }
  
  }
  </code></pre>
  
  <p>I'm using Moq, and I'd like to write a test that verifies ChildMethod1() is being called when I call BaseMethod() and runMethod1 is true.  Is it possible to create an implemention of TestBase with Moq, call BaseMethod() and verify that ChildMethod was called on the Moq implementation?</p>
  
  <pre><code>[Test]
  public BaseMethod_should_call_correct_child_method()
  {
    TestBase testBase;
  
    //todo: get a mock of TestBase into testBase variable
  
    testBase.runMethod1 = true;
  
    testBase.BaseMethod();
  
    //todo: verify that ChildMethod1() was called
  
  }
  </code></pre>