I'm new to AutoFixture, so I don't know if the following idea is going to make sense or be a reasonable thing to do. I've got an application that I'm in charge of integration testing, and it makes heavy use of Castle Windsor. To simplify dependency management and make my tests more like the application code, I've been building the Windsor container in my test initialize method and the using container.Resolve to instantiate the code I'm testing. I'd like to move away from that approach since it has limited my flexibility in certain situations.
What I'd like to do is have tests that look something like this:
[Theory]
[Dependency]
public void TestWithDependencies(IThing thing)
{
thing.Hello();
}
To make this happen, I can do the following:
public sealed class DependencyAttribute : AutoDataAttribute
{
public DependencyAttribute()
: base(new Fixture().Customize(new WindsorCustomization()))
{
}
}
public class WindsorCustomization : ICustomization
{
public WindsorCustomization()
{
// build container here using SUT installers
}
public void Customize(IFixture fixture)
{
fixture.Inject<IThing>(new Thing());
}
}
Doing this does work, but what I'd like to avoid is needing to copy every interface to implementation mapping from the Windsor container into the AutoFixture IFixture.