-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathTestRun.cs
45 lines (35 loc) · 1.24 KB
/
TestRun.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
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; }
}
}