public void ComponentIsDisposedAtTheEndOfRequest(IContainerAdapter adapter)
        {
            adapter.RegisterPerWebRequest<DisposableService>();

            BeginRequest(adapter);
            var service = adapter.Resolve<DisposableService>();
            EndRequest(adapter);

            Assert.True(service.Disposed);
        }
        public void ComponentIsDisposedAtTheEndOfRequest(IContainerAdapter adapter)
        {
            adapter.RegisterPerWebRequest <DisposableService>();

            BeginRequest(adapter);
            var service = adapter.Resolve <DisposableService>();

            EndRequest(adapter);

            Assert.True(service.Disposed);
        }
        public void ReuseWithinRequest(IContainerAdapter adapter)
        {
            adapter.RegisterPerWebRequest <IndependentService>();

            BeginRequest(adapter);
            var first  = adapter.Resolve <IndependentService>();
            var second = adapter.Resolve <IndependentService>();

            EndRequest(adapter);

            Assert.Same(first, second);
        }
        public void FactoryNoReuseBetweenRequests(IContainerAdapter adapter)
        {
            adapter.RegisterPerWebRequest<IService, IndependentService>();
            adapter.RegisterSingleton<ServiceWithFuncConstructorDependency>();

            var service = adapter.Resolve<ServiceWithFuncConstructorDependency>();

            BeginRequest(adapter);
            var first = service.Factory();
            EndRequest(adapter);

            BeginRequest(adapter);
            var second = service.Factory();
            EndRequest(adapter);

            Assert.NotSame(first, second);
        }
        public void FactoryNoReuseBetweenRequests(IContainerAdapter adapter)
        {
            adapter.RegisterPerWebRequest <IService, IndependentService>();
            adapter.RegisterSingleton <ServiceWithFuncConstructorDependency>();

            var service = adapter.Resolve <ServiceWithFuncConstructorDependency>();

            BeginRequest(adapter);
            var first = service.Factory();

            EndRequest(adapter);

            BeginRequest(adapter);
            var second = service.Factory();

            EndRequest(adapter);

            Assert.NotSame(first, second);
        }
示例#6
0
 public static void RegisterPerWebRequest <TService, TImplementation>(this IContainerAdapter container)
     where TImplementation : TService
 {
     container.RegisterPerWebRequest(typeof(TService), typeof(TImplementation));
 }
示例#7
0
 public static void RegisterPerWebRequest <TService>(this IContainerAdapter container)
 {
     container.RegisterPerWebRequest <TService, TService>();
 }
        public void NoReuseBetweenRequests(IContainerAdapter adapter)
        {
            adapter.RegisterPerWebRequest<IndependentService>();

            BeginRequest(adapter);
            var first = adapter.Resolve<IndependentService>();
            EndRequest(adapter);

            BeginRequest(adapter);
            var second = adapter.Resolve<IndependentService>();
            EndRequest(adapter);

            Assert.NotSame(first, second);
        }
 public void PerRequestSupport(IContainerAdapter adapter)
 {
     adapter.RegisterPerWebRequest<IndependentService>();
 }
 public void PerRequestSupport(IContainerAdapter adapter)
 {
     adapter.RegisterPerWebRequest <IndependentService>();
 }