IFixture CreateFixture(Type type) method

Developer
Jul 20, 2011 at 5:33 PM

IFixture CreateFixture(Type type) is a private static method inside the AutoDataAttribute class. I think it would be a good idea to move it inside a helper class, or somewhere in order to be reusable. I am making some tests (in my fork) trying to implement a CompositeAutoDataAttribute and it doesn't feel natural to do this (even if I should not create a CompositeAutoDataAttribute at all):

public CompositeAutoDataAttribute(Type fixtureType)
            : this(AutoDataAttribute.CreateFixture(fixtureType))
        {
        }


Probably instead of AutoDataAttribute.CreateFixture would it be better to have FixtureHelper.CreateFixture(Type type) or FixtureFactory.CreateFrom(Type type) and also outside the AutoFixture.xUnit.net assembly?

Coordinator
Jul 20, 2011 at 10:28 PM

Why are you creating a CompositeAutoDataAttribute?

Developer
Jul 21, 2011 at 6:48 AM

I am not actually.

Coordinator
Jul 21, 2011 at 3:33 PM

I'm sorry, you just lost me there...

Developer
Jul 21, 2011 at 7:59 PM

I was making some tests (in my fork) trying to implement a CompositeAutoDataAttribute but after the discussion we had (http://autofixture.codeplex.com/workitem/4227) now I won't.  However, with this discussion here, I wanted to suggest that the IFixture CreateFixture(Type type) method could live in a helper class inside the AutoFixture assembly.

Coordinator
Jul 22, 2011 at 1:24 PM

Yes, the method could be moved to a class and made public if the need arises. However, I don't see any particular reason to do so right now.

I have nothing against this happening, but think it would be Gold Plating if there's no purpose. It would increase the size of the public API, so if it serves no particular purpose I think it would only make it more difficult to learn the API.

However, I'm open for arguments :)

Developer
Jul 22, 2011 at 1:40 PM

At least this discussion will act as a reminder, when the need arises to remember and move to a class and make public (else it will be Duplicate Code). :)