public void ProviderRegisteredWithHttpModule() { var container = new ContainerBuilder().Build(); var provider = new RequestLifetimeScopeProvider(container); Assert.Equal(provider, RequestLifetimeHttpModule.LifetimeScopeProvider); }
public void EndLifetimeScopeDoesNotThrowExceptionWhenHttpContextNotAvailable() { var container = new ContainerBuilder().Build(); var provider = new RequestLifetimeScopeProvider(container); var ex = Record.Exception(() => provider.EndLifetimeScope()); Assert.Null(ex); }
public void MeaningfulExceptionThrowWhenHttpContextNotAvailable() { var container = new ContainerBuilder().Build(); var provider = new RequestLifetimeScopeProvider(container); var exception = Assert.Throws <InvalidOperationException>(() => provider.GetLifetimeScope(b => { })); Assert.Equal(RequestLifetimeScopeProviderResources.HttpContextNotAvailable, exception.Message); }
public AutofacIocAdapter(Autofac.IContainer container, Container funqContainer) { _container = container; // Register a RequestLifetimeScopeProvider (from Autofac.Integration.Mvc) with Funq var lifetimeScopeProvider = new RequestLifetimeScopeProvider(_container); funqContainer.Register <ILifetimeScopeProvider>(x => lifetimeScopeProvider); //Store the autofac application (root) container, and the funq container for later use _funqContainer = funqContainer; }
public override void BeforeAllWebRequests(WebRequestSupport.WebRequestTestHelper helper) { EnsureContainer(); // sets the provider on module as well // TODO: I am pretty sure there is a race condition (module's provider is in a static field) this.requestScopeProvider = new RequestLifetimeScopeProvider(this.container); var module = (IHttpModule)Activator.CreateInstance( Type.GetType("Autofac.Integration.Mvc.RequestLifetimeHttpModule, Autofac.Integration.Mvc", true) ); helper.RegisterModule(module); }