public void TestStartableWithRegisteredCustomDependencies()
		{
			IKernel kernel = new DefaultKernel();
			kernel.ComponentCreated += new ComponentInstanceDelegate(OnStartableComponentStarted);

			kernel.AddFacility("startable", new StartableFacility());

			var dependencies = new Dictionary<string, object> { { "config", 1 } };
			kernel.Register(Component.For(typeof(StartableComponentCustomDependencies)).Named("a"));
			kernel.RegisterCustomDependencies(typeof(StartableComponentCustomDependencies), dependencies);

			Assert.IsTrue(startableCreatedBeforeResolved, "Component was not properly started");

			StartableComponentCustomDependencies component = kernel["a"] as StartableComponentCustomDependencies;

			Assert.IsNotNull(component);
			Assert.IsTrue(component.Started);
			Assert.IsFalse(component.Stopped);

			kernel.ReleaseComponent(component);
			Assert.IsTrue(component.Stopped);
		}
Ejemplo n.º 2
0
		public void TestStartableWithRegisteredCustomDependencies()
		{
			IKernel kernel = new DefaultKernel();
			kernel.ComponentCreated += new ComponentInstanceDelegate(OnStartableComponentStarted);

			kernel.AddFacility("startable", new StartableFacility());

			Hashtable dependencies = new Hashtable();
			dependencies.Add("config", 1);
			kernel.AddComponent("a", typeof(StartableComponentCustomDependencies));
			kernel.RegisterCustomDependencies(typeof(StartableComponentCustomDependencies), dependencies);

			Assert.IsTrue(startableCreatedBeforeResolved, "Component was not properly started");

			StartableComponentCustomDependencies component = kernel["a"] as StartableComponentCustomDependencies;

			Assert.IsNotNull(component);
			Assert.IsTrue(component.Started);
			Assert.IsFalse(component.Stopped);

			kernel.ReleaseComponent(component);
			Assert.IsTrue(component.Stopped);
		}