This project is read-only.

IFixture CreateFixture(Type type) method

Jul 20, 2011 at 6: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 assembly?

Jul 20, 2011 at 11:28 PM

Why are you creating a CompositeAutoDataAttribute?

Jul 21, 2011 at 7:48 AM

I am not actually.

Jul 21, 2011 at 4:33 PM

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

Jul 21, 2011 at 8:59 PM

I was making some tests (in my fork) trying to implement a CompositeAutoDataAttribute but after the discussion we had ( 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.

Jul 22, 2011 at 2: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 :)

Jul 22, 2011 at 2: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). :)