public void ReadyAndRelease() { BaseKernel container = new BaseKernel(); container.ComponentReady += new ComponentInstanceDelegate(ComponentReady); container.ComponentReleased += new ComponentInstanceDelegate(ComponentReleased); container.AddComponent( "a", typeof(IMailService), typeof(SimpleMailService) ); Assert(!m_ready); Assert(!m_released); IHandler handler = container[ "a" ]; IMailService service = handler.Resolve() as IMailService; Assert(m_ready); Assert(!m_released); m_ready = false; service.Send("hammett at apache dot org", "johndoe at yahoo dot org", "Aloha!", "What's up?"); handler.Release( service ); Assert(!m_ready); Assert(m_released); }
public void ModelConstructed() { BaseKernel container = new BaseKernel(); container.ComponentModelConstructed += new ComponentModelDelegate(ComponentModelConstructed); Assert(!m_modelConstructed); container.AddComponent( "a", typeof(IMailService), typeof(SimpleMailService) ); Assert(m_modelConstructed); m_modelConstructed = false; container.RemoveComponent( "a" ); Assert(!m_modelConstructed); }
public void RegisteredAndUnregistered() { BaseKernel container = new BaseKernel(); container.ComponentRegistered += new ComponentDataDelegate(Registered); container.ComponentUnregistered += new ComponentDataDelegate(Unregistered); Assert(!m_registered); Assert(!m_unregistered); container.AddComponent( "a", typeof(IMailService), typeof(SimpleMailService) ); Assert(m_registered); Assert(!m_unregistered); m_registered = false; container.RemoveComponent( "a" ); Assert(!m_registered); Assert(m_unregistered); }
public void WrapAndUnwrap() { BaseKernel container = new BaseKernel(); container.ComponentWrap += new WrapDelegate(ComponentWrap); container.ComponentUnWrap += new WrapDelegate(ComponentUnWrap); container.AddComponent( "a", typeof(IMailService), typeof(SimpleMailService) ); Assert(!m_wrap); Assert(!m_unwrap); IHandler handler = container[ "a" ]; IMailService service = handler.Resolve() as IMailService; Assert(m_wrap); Assert(!m_unwrap); m_wrap = false; service.Send("hammett at apache dot org", "johndoe at yahoo dot org", "Aloha!", "What's up?"); handler.Release( service ); Assert(!m_wrap); Assert(m_unwrap); }