예제 #1
0
        public void StartStopAndDisposeNotCascadedtoRemovedChildren()
        {
            IMutablePicoContainer parent = CreatePicoContainer(null);

            parent.RegisterComponentInstance(new StringBuilder());
            StringBuilder sb =
                (StringBuilder)
                ((IComponentAdapter)parent.GetComponentAdaptersOfType(typeof(StringBuilder))[0]).GetComponentInstance(
                    parent);

            IMutablePicoContainer child = CreatePicoContainer(parent);

            Assert.IsTrue(parent.AddChildContainer(child));
            child.RegisterComponentImplementation(typeof(LifeCycleMonitoring));
            Assert.IsTrue(parent.RemoveChildContainer(child));
            parent.Start();
            Assert.IsTrue(sb.ToString().IndexOf("-started") == -1);
            parent.Stop();
            Assert.IsTrue(sb.ToString().IndexOf("-stopped") == -1);
            parent.Dispose();
            Assert.IsTrue(sb.ToString().IndexOf("-disposed") == -1);
        }
 public virtual bool AddChildContainer(IPicoContainer child)
 {
     return(delegateContainer.AddChildContainer(child));
 }