Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
34 lines (29 sloc) 1.21 KB
using Microsoft.Practices.Unity;
using SpecFlow.Unity;
using TechTalk.SpecFlow.Infrastructure;
using TechTalk.SpecFlow.Plugins;
[assembly: RuntimePlugin(typeof(UnityPlugin))]
namespace SpecFlow.Unity
{
public class UnityPlugin : IRuntimePlugin
{
public void Initialize(RuntimePluginEvents runtimePluginEvents, RuntimePluginParameters runtimePluginParameters)
{
runtimePluginEvents.CustomizeGlobalDependencies += (sender, args) =>
{
args.ObjectContainer.RegisterTypeAs<UnityBindingInstanceResolver, ITestObjectResolver>();
args.ObjectContainer.RegisterTypeAs<ContainerFinder, IContainerFinder>();
};
runtimePluginEvents.CustomizeScenarioDependencies += (sender, args) =>
{
args.ObjectContainer.RegisterFactoryAs<IUnityContainer>(() =>
{
var containerBuilderFinder = args.ObjectContainer.Resolve<IContainerFinder>();
var containerBuilder = containerBuilderFinder.GetCreateScenarioContainer();
var container = containerBuilder.Invoke();
return container;
});
};
}
}
}