public void StartStopStopCausingBarf() { DefaultPicoContainer pico = new DefaultPicoContainer(); pico.Start(); pico.Stop(); try { pico.Stop(); Assert.Fail("Should have barfed"); } catch (Exception) { // expected; } }
public void StartStopOfDaemonizedThread() { DefaultPicoContainer pico = new DefaultPicoContainer(); pico.RegisterComponentImplementation(typeof(FooRunnable)); object i = pico.ComponentInstances; pico.Start(); Thread.Sleep(100); pico.Stop(); FooRunnable foo = (FooRunnable)pico.GetComponentInstance(typeof(FooRunnable)); Assert.AreEqual(1, foo.runCount()); pico.Start(); Thread.Sleep(100); pico.Stop(); Assert.AreEqual(2, foo.runCount()); }
public void OnlyStartableComponentsAreInstantiatedOnStart() { IMutablePicoContainer pico = new DefaultPicoContainer(); pico.RegisterComponentImplementation("recording", typeof(StringBuilder)); pico.RegisterComponentImplementation(typeof(A)); pico.RegisterComponentImplementation(typeof(NotStartable)); pico.Start(); pico.Stop(); pico.Dispose(); Assert.AreEqual("<AA>!A", pico.GetComponentInstance("recording").ToString()); }
public void ComponentsAreStartedBreadthFirstAndStoppedDepthFirst() { IMutablePicoContainer parent = new DefaultPicoContainer(); parent.RegisterComponentImplementation("recording", typeof(StringBuilder)); parent.RegisterComponentImplementation(typeof(A)); IMutablePicoContainer child = parent.MakeChildContainer(); child.RegisterComponentImplementation(typeof(B)); parent.Start(); parent.Stop(); Assert.AreEqual("<A<BB>A>", parent.GetComponentInstance("recording").ToString()); }
public void StartStopDisposeDisposeCausingBarf() { DefaultPicoContainer pico = new DefaultPicoContainer(); object o = pico.ComponentInstances; pico.Start(); pico.Stop(); pico.Dispose(); try { pico.Dispose(); Assert.Fail("Should have barfed"); } catch (Exception) { // expected; } }
public void StartStopOfDaemonizedThread() { DefaultPicoContainer pico = new DefaultPicoContainer(); pico.RegisterComponentImplementation(typeof (FooRunnable)); object i = pico.ComponentInstances; pico.Start(); Thread.Sleep(100); pico.Stop(); FooRunnable foo = (FooRunnable) pico.GetComponentInstance(typeof (FooRunnable)); Assert.AreEqual(1, foo.runCount()); pico.Start(); Thread.Sleep(100); pico.Stop(); Assert.AreEqual(2, foo.runCount()); }
public void OnlyStartableComponentsAreInstantiatedOnStart() { IMutablePicoContainer pico = new DefaultPicoContainer(); pico.RegisterComponentImplementation("recording", typeof (StringBuilder)); pico.RegisterComponentImplementation(typeof (A)); pico.RegisterComponentImplementation(typeof (NotStartable)); pico.Start(); pico.Stop(); pico.Dispose(); Assert.AreEqual("<AA>!A", pico.GetComponentInstance("recording").ToString()); }
public void ComponentsAreStartedBreadthFirstAndStoppedDepthFirst() { IMutablePicoContainer parent = new DefaultPicoContainer(); parent.RegisterComponentImplementation("recording", typeof (StringBuilder)); parent.RegisterComponentImplementation(typeof (A)); IMutablePicoContainer child = parent.MakeChildContainer(); child.RegisterComponentImplementation(typeof (B)); parent.Start(); parent.Stop(); Assert.AreEqual("<A<BB>A>", parent.GetComponentInstance("recording").ToString()); }