ipjohnson / SimpleFixture

Testing fixture for .Net
MIT License
11 stars 2 forks source link

add CustomizationAttribute #14

Closed ipjohnson closed 8 years ago

ipjohnson commented 8 years ago
public class CustomizationAttribute : FixtureInitializationAttribute
{
    private Type[] _types;

    public CustomizationAttribute(params Type[] types)
    {
        _types = types;
    }

    public override void Initialize(Fixture fixture)
    {
        foreach(var type in _types)
        {
            object initializer = fixture.Locate(type);

            if(initializer is IConvention)
            {
                fixture.Add(initializer as IConvention);
            }
            else if(initializer is IFixtureCustomization)
            {
                fixture.Add(initializer as IFixtureCustomization);
            }
        }
    }
}
ipjohnson commented 8 years ago

This has been released as part of 1.4.5