title: Customization for creating implementations of a base type
body: <p>So I have the following types:</p>
  
  
  
  <pre class="lang-cs prettyprint-override"><code>public abstract class Base
  {
      public string Text { get; set; }
      public abstract int Value { get; set; }
  }
  
  public class BaseImplA : Base
  {
      public override int Value { get; set; }
  }
  
  public class BaseImplB : Base
  {
      public override int Value
      {
          get { return 1; }
          set { throw new NotImplementedException(); }
      }
  }
  </code></pre>
  
  <p>I want AutoFixture to alternate creating BaseImplA and BaseImplB when Base is requested.</p>
  
  <pre class="lang-cs prettyprint-override"><code>var fixture = new Fixture().Customize(new TestCustomization());
  var b1 = fixture.Create&lt;Base&gt;();
  var b2 = fixture.Create&lt;Base&gt;();
  </code></pre>
  
  <p>The issue is BaseImplB throws a NotImplementedException from the Value property setter. So I created the following customization:</p>
  
  <pre class="lang-cs prettyprint-override"><code>public class TestCustomization : ICustomization
  {
      private bool _flag;
      private IFixture _fixture;
  
      public void Customize(IFixture fixture)
      {
          _fixture = fixture;
  
          fixture.Customize&lt;BaseImplB&gt;(composer =&gt;
          {
              return composer.Without(x =&gt; x.Value);
          });
  
          fixture.Customize&lt;Base&gt;(composer =&gt;
          {
              return composer.FromFactory(CreateBase);
          });
      }
  
      private Base CreateBase()
      {
          _flag = !_flag;
  
          if (_flag)
          {
              return _fixture.Create&lt;BaseImplA&gt;();
          }
  
          return _fixture.Create&lt;BaseImplB&gt;();
      }
  }
  </code></pre>
  
  <p>But what's happening is that the Value is not being set for BaseImplA or BaseImplB. Can anyone point out where I'm going wrong?</p>