title: Inheritence of common functionality for multiple classes with different base classes
body: <p>In this solution there is a <code>PageObjectModel</code>, which contains page classes for each webpage in a set of three services to be tested. The page classes provide the necessary properties and methods for interacting with the pages.</p>
  <p>Within each of the three services is a page which has an identical main body between the three services, but the surrounding pages are different.</p>
  <p>If we call the common functionality <code>Foo</code>, there is a <code>FooPage</code> for each of the services, <code>A.FooPage</code>, <code>B.FooPage</code>, <code>C.FooPage</code>. My current solution for extracting out the commonality involves creating a common class <code>Foo</code> which contains all the functionality for that tool, and then creating an instance of <code>Foo</code> in each <code>FooPage</code>, and pointing to <code>Foo</code> methods from each <code>FooPage</code>:</p>
  <pre><code>public class Foo : BasePage
  {
      public Foo(IWebDriver driver) : base(driver)
      {
          
      }
  
      public void DoThingOne()
      {
          // do something
      }
  
      public void DoThingTwo()
      {
          // do other thing
      }
  }
  </code></pre>
  <pre><code>public class FooPage : APage
  {
      private readonly Foo f;
      
      public FooPage(IWebDriver driver) : base(driver)
      {
          f = new Foo(driver);
      }
  
      public void DoThingOne() =&gt; f.DoThingOne();
      
      public void DoThingTwo() =&gt; f.DoThingTwo();
  }
  </code></pre>
  <p>and the same for <code>FooPage : BPage</code> and <code>FooPage : CPage</code>.</p>
  <p>Ideally I would just have each of the three <code>FooPage</code> have <code>Foo</code> as their base class, but the issue is that they would lose all functionality contained within their service specific base pages (<code>APage</code>, <code>BPage</code>, <code>CPage</code>).</p>
  <p>It seems logical to me that I would want <code>FooPage</code> to extend <code>Foo</code>, as <code>FooPage</code> really <em>is</em> a <code>Foo</code>, but <code>FooPage</code> is also an <code>APage</code>, <code>BPage</code>, or <code>CPage</code>.</p>
  <p>Is there any way to cleanly go about this in <code>C#</code>, or would it be more messy after the fact?</p>
  <p><em>For clarity, each of <code>APage</code>, <code>BPage</code>, and <code>CPage</code> are extended from <code>BasePage</code>.</em></p>