title: c# inheritance multiple parents
body: <pre><code>   namespace NUnitTestAbstract
  {
      public abstract class BaseTestClass1
      {
          public abstract void BaseTestClass1Method();
      }
  
      public abstract class BaseTestClass2 : BaseTestClass1
      {
          // not overriding BaseTestClass1Method, child classes should do
          public void SomeTestMethodA() { }
  
          public void SomeTestMethodB() { }
      }
  
      public abstract class BaseTestClass3 : BaseTestClass1
      {
          // not overriding BaseTestClass1Method, child classes should do
          public void SomeTestMethodX() { }
  
          public void SomeTestMethodY() { }
      }
  
      public class TestClass2A : BaseTestClass2
      {
          public override void BaseTestClass1Method()
          {
              // do stuff
          }
      }
  
      public class TestClass2B : BaseTestClass2
      {
          public override void BaseTestClass1Method()
          {
              // do same stuff as TestClassA
          }
      }
  
  
      public class TestClass3A : BaseTestClass3
      {
          public override void BaseTestClass1Method()
          {
              // do stuff
          }
      }
  
      public class TestClass3B : BaseTestClass3
      {
          public override void BaseTestClass1Method()
          {
              // do same stuff as TestClass3A
          }
      }
  }
  </code></pre>
  
  <p>At this moment I have the above construction. A base class extending another base class. The base class is extended by two child classes. The implementation of <code>BaseTestClass1Method</code> is the same for the two child classes. If it was possible to extends from two parents I would create a class extending <code>BaseTestClass1</code> implementing <code>BaseTestClass1Method</code>. The two child classes would then extend <code>BaseTestClass2</code> and the new class so that I only have to implement <code>BaseTestClass1Method</code> once
  When I add another BaseTestClass3 (same level as BaseTestClass2) extending from BaseTestClass1 and create child classes from it, I have more duplicate code for the implementation of BasetestClass1Method.
  How can I solve this with the correct pattern? </p>
  
  <p>Here's a more implemented example:</p>
  
  <pre><code>namespace NUnitTestAbstract
  {
      public interface IServer { }
  
      public abstract class ServerBase
      {
          public abstract IServer GetServerInstance();
      }
  
      public abstract class SomeTests1Base : ServerBase
      {
          // not overriding BaseTestClass1Method, child classes should do
          public void SomeTestMethodA() { }
  
          public void SomeTestMethodB() { }
      }
  
      public abstract class SomeTests2Base : ServerBase
      {
          // not overriding BaseTestClass1Method, child classes should do
          public void SomeTestMethodX() { }
  
          public void SomeTestMethodY() { }
      }
  
      public class TestClass2A : SomeTests1Base
      {
          public override IServer GetServerInstance()
          {
              IServer serverX = null;
              return serverX;
          }
      }
  
      public class TestClass2B : SomeTests1Base
      {
          public override IServer GetServerInstance()
          {
              IServer serverX = null;
              return serverX;
          }
      }
  
  
      public class TestClass3A : SomeTests2Base
      {
          public override IServer GetServerInstance()
          {
              IServer serverY = null;
              return serverY;
          }
      }
  
      public class TestClass3B : SomeTests2Base
      {
          public override IServer GetServerInstance()
          {
              IServer serverY = null;
              return serverY;
          }
      }
  }
  </code></pre>