public void TestFixtureSetup() { //Hackery in order to get the PerWebRequest lifecycle working in a test environment //Surely there must be a better way to do this? HttpContext.Current = new HttpContext(new HttpRequest("foo", "http://localhost", ""), new HttpResponse(new StringWriter())); HttpContext.Current.ApplicationInstance = new HttpApplication(); var module = new PerWebRequestLifestyleModule(); module.Init(HttpContext.Current.ApplicationInstance); container = ContainerBuilder.Build("Windsor.config"); }
public void SetUp() { container = new WindsorContainer() .Register(Component.For<INHibernateInstaller>().ImplementedBy<ExampleInstaller>()) .AddFacility<AutoTxFacility>() .AddFacility<NHibernateFacility>( fac => fac.DefaultLifeStyle = DefaultSessionLifeStyleOption.SessionPerWebRequest); var app = new HttpApplication(); var lifestyle = new PerWebRequestLifestyleModule(); lifestyle.Init(app); }