Ejemplo n.º 1
0
        public void ProviderRegisteredWithHttpModule()
        {
            var container = new ContainerBuilder().Build();
            var provider  = new RequestLifetimeScopeProvider(container);

            Assert.Equal(provider, RequestLifetimeHttpModule.LifetimeScopeProvider);
        }
Ejemplo n.º 2
0
        public void EndLifetimeScopeDoesNotThrowExceptionWhenHttpContextNotAvailable()
        {
            var container = new ContainerBuilder().Build();
            var provider  = new RequestLifetimeScopeProvider(container);
            var ex        = Record.Exception(() => provider.EndLifetimeScope());

            Assert.Null(ex);
        }
Ejemplo n.º 3
0
        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;
        }
Ejemplo n.º 5
0
        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);
        }