title: Create object with name to inject into unit test
body: <p>I'm unit testing a class that takes a factory as one of it's dependencies and uses this to build objects that the <code>SUT</code> effectively controls:</p>
  
  <pre><code>class SystemUnderTest
  {
      private readonly IFoo foo1;
  
      private readonly IFoo foo2;
  
      public SystemUnderTest(IFooFactory fooFactory)
      {
          this.foo1 = fooFactory.Build("Bar1");
          this.foo2 = fooFactory.Build("Bar2");
      }
  
      public IFoo Foo1
      {
          get 
          {
              return this.foo1;
          }
      }
  
      ...
  }
  </code></pre>
  
  <p>The <code>SystemUnderTest</code> object has a singleton lifetime that is injected into multiple <code>ViewModels</code> that use it's properties/method to perform different actions, so this effectively rules out defining a <code>Provider</code> class so that I could inject <code>foo1</code> and <code>foo2</code> without interfacing with the factory within the constructor which is what I would normally do when facing this issue.</p>
  
  <p>But by injecting the factory I am unable to figure out with <code>AutoFixture</code> how I could correctly configure the <code>fooFactory</code> to provide the correct <code>IFoo</code> and pass this as a method parameter into my test such as:</p>
  
  <pre><code>[Theory]
  [AutoData]
  internal void Foo1_IsCorrectlyPopulated_Test(
      [Frozen] IFoo foo1,
      SystemUnderTest systemUnderTest)
  {
      var actual = systemUnderTest.Foo1;
  
      Assert.Same(foo1, actual);
  }
  </code></pre>
  
  <p>I understand that I can extend the <code>AutoData</code> attribute and provide my own customization to the Fixture such as:</p>
  
  <pre><code>class SystemUnderTestAutoDataAttribute : AutoDataAttribute
  {
      public SystemUnderTestAutoData()
      {
          var fooFactory = this.Fixture.Freeze&lt;IFooFactory&gt;();
          var foo1 = this.Fixture.Create&lt;IFoo&gt;();
  
          Mock.Get(fooFactory).Setup(m =&gt; m.Build("Bar1")).Returns(foo1);
      }
  }
  </code></pre>
  
  <p>But I'm wondering if there is the ability to get the <code>foo1</code> object that I created within the attribute constructor and have this passed into the test method as a parameter? I understand that I could <code>Freeze</code> the <code>foo1</code> object but this means that I would need to have two attribute classes for <code>foo1</code> and <code>foo2</code> to supply the correct information to my test method and this falls over when I have to use both objects within my test case.</p>
  
  <p>I was hoping that there was a way that I could create the object with a particular name (or some other matching method) and match that within the test case like (does not compile):</p>
  
  <pre><code>[Theory]
  [SystemUnderTestAutoData]
  internal void Foo1_IsCorrectlyPopulated_Test(
      [Frozen(Matching.CreationName)] IFoo foo1,
      SystemUnderTest systemUnderTest)
  {
      ...
  }
  
  class SystemUnderTestAutoDataAttribute : AutoDataAttribute
  {
      public SystemUnderTestAutoData()
      {
          var fooFactory = this.Fixture.Freeze&lt;IFooFactory&gt;();
          var foo1 = this.Fixture.Create&lt;IFoo&gt;(creationName: @"foo1");
  
          Mock.Get(fooFactory).Setup(m =&gt; m.Build("Bar1")).Returns(foo1);
      }
  }
  </code></pre>
  
  <p>So that any matching registered instances with the name (or some other matching method) can be resolved as part of the test case parameters?</p>