Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
using System;
using Autofac;
namespace SeleniumWithXunit.Infrastructure
{
public class TestRun
{
public static void Setup()
{
SetupContainer();
SetupCleanup();
}
private static void SetupCleanup()
{
AppDomain.CurrentDomain.DomainUnload += (sender, args) => Container.Dispose();
}
private static void SetupContainer()
{
var builder = new ContainerBuilder();
var thisAssembly = typeof (TestRun).Assembly;
builder.RegisterType<BrowserFactory>().AsSelf().SingleInstance();
builder.RegisterType<BrowserPool>().AsSelf().SingleInstance();
builder.RegisterAssemblyTypes(thisAssembly)
.Where(t => t.Implements<IPageObject>())
.AsSelf()
.PropertiesAutowired()
.InstancePerDependency();
builder.Register(c => c.Resolve<BrowserPool>().TakeOne())
.OnRelease(browser => Container.Resolve<BrowserPool>().Return(browser))
.AsSelf()
.InstancePerLifetimeScope();
Container = builder.Build();
}
public static IContainer Container { get; private set; }
}
}