-
Notifications
You must be signed in to change notification settings - Fork 337
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Non-generic version of Create method #97
Comments
Perhaps this might help: public static object Create(this Fixture fixture, Type type)
{
var context = new SpecimenContext(fixture.Compose());
return context.Resolve(type);
} The code is from from this post by @ThomasArdal. |
Thanks. What's the benefit of calling |
Correct. I originaly wrote about this here: http://thomasardal.com/non-generic-createanonymous-method-for-autofixture/ But! Fixture were changed in AutoFixture 3.x. You now simply need to do this instead (no Compose): public static object Create(this Fixture fixture, Type type)
{
var context = new SpecimenContext(fixture);
return context.Resolve(type);
} |
Looks exactly like what I have - just with the difference that you use |
You are right. Fixture now implements ISpecimenBuilder. Constraining it to Fixture, doesn't make sense :) |
Thanks for the confirmation! :) |
Is there a simple way to create an anonymous instance from a
Type
instance?Looking through the code, I came up with this:
Is this correct? Is there a simpler way to do it? If not, would it be benefical to add this to AutoFixture?
The text was updated successfully, but these errors were encountered: