Skip to content

Instantly share code, notes, and snippets.

@plioi
Created October 5, 2013 21:43
Show Gist options
  • Save plioi/6846415 to your computer and use it in GitHub Desktop.
Save plioi/6846415 to your computer and use it in GitHub Desktop.
public static class AutoFixtureExtensions
{
//Normal AutoFixture usage is to write:
//
// var thing = autoFixture.Create<MyClass>();
//
//If all you have is an arbitrary Type object, though,
//this extension method lets you write:
//
// var thing = autoFixture.Create(type);
public static object Create(this ISpecimenBuilder builder, Type type)
{
return new SpecimenContext(builder).Resolve(type);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment