在httpModules中测试nhibernate Castle Windsor映射未注册

cpo*_*ign 7 unit-testing mstest asp.net-mvc-2

我想编写测试来验证城堡windsor中的映射.我正在使用ASP MVC2,我正在使用城堡windsor来映射我的存储库.

我读过这篇文章:

http://weblogs.asp.net/bsimser/archive/2008/06/04/the-first-spec-you-should-write-when-using-castle.aspx

并基于此我创建了我的MS测试

 [TestMethod()]
        public void GetContainerTest()
        {
            MooseMvc.Infrastructure.DependencyInjectionInitialiser target = new MooseMvc.Infrastructure.DependencyInjectionInitialiser(); // TODO: Initialize to an appropriate value
            IWindsorContainer container = target.GetContainer();
            foreach (IHandler assignableHandler in container.Kernel.GetAssignableHandlers(typeof(object)))
            {             
                container.Resolve(assignableHandler.ComponentModel.Service);
            }
        }
Run Code Online (Sandbox Code Playgroud)

target.getcontainer()的数据实现

 this._windsorContainer.Register(Component.For<TInterfaceType>()
                .ImplementedBy(typeof(TConcreteType)).LifeStyle.PerWebRequest);
Run Code Online (Sandbox Code Playgroud)

我收到如下消息:

 Looks like you forgot to register the http module 
Castle.MicroKernel.Lifestyle.PerWebRequestLifestyleModule Add '<add
name="PerRequestLifestyle"
type="Castle.MicroKernel.Lifestyle.PerWebRequestLifestyleModule,
Castle.Windsor" />' to the <httpModules> section on your web.config.
If you're running IIS7 in Integrated Mode you will need to  add it to
<modules> section under <system.webServer>
Run Code Online (Sandbox Code Playgroud)