title: How to mock an object that extends a class and implements an interface?
body: <p>I have this class:</p>
  
  <pre><code>public class BaseFoo
  {
      public bool BoolProp { get; set; }
  }
  
  public interface IFoo {
      void Method();
  }
  
  public class FooClass : BaseFoo, IFoo
  {
      public void Method()
      {
          // DoSomething
      }
  }
  
  public class MyClass
  {
      IFoo foo; // 
      public MyClass(IFoo foo)
      {
          this.foo = foo;
      }
  
      public void DoSomething()
      {
          if (((FooClass)foo).BoolProp)
          {
              // yeah
          }
          else
          {
              //bad
          }
      }
  }
  </code></pre>
  
  <p>My scenario is:</p>
  
  <pre><code>    void main()
      {
          MyClass obj = new MyClass(new FooClass());
          obj.DoSomething();
      } 
  </code></pre>
  
  <p>I'd like to create a mock object for the IFoo interface that allows me to mock the BaseFoo class too because I need to always avoid running the "else" branch of the "if (((FooClass)foo).BoolProp)" in the MyClass.DoSomething() method.<br />
  So, how can I create a mock object that allows me to mock the behaviour of BaseFoo.BoolProp used in MyClass (that will take a mock object of IFoo)? <br/>
  I did that without any result because the "BoolProp" is not virtual and I can't change it as it is part of a .NET Framework class:</p>
  
  <pre><code>  var cMock = new Mock&lt;BaseFoo&gt;();
    var iMock = cMock.As&lt;IFoo&gt;();
  
    cMock.Setup(c =&gt; c.BaseProp).Returns(true);
    MyClass myClass = new MyClass(iMock.Object);
  </code></pre>