Voglio scrivere test che verifica i mapping in windsor del castello. Sto usando ASP MVC2 dove sto usando windsor del castello per mappare i miei repository.Testing nhibernate Castle Windsor mapping in httpModules non è registrato
Ho letto questo articolo:
e sulla base di questo ho creato il mio MS test
[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);
}
}
I dati per target.getcontainer() implementa
this._windsorContainer.Register(Component.For<TInterfaceType>()
.ImplementedBy(typeof(TConcreteType)).LifeStyle.PerWebRequest);
Ottengo il messaggio come fol bassi:
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>
Grazie! Esattamente quello di cui avevo bisogno. –
Haha, alcuni mesi dopo vengo a questo stesso problema in un altro progetto e lo risolve di nuovo per me. Grazie! PS Ricorda solo di fare questa registrazione dell'evento ComponentModelCreated prima di ogni chiamata di Installer o Register! –