public void AddChildKernelToTwoParentsThrowsException() { IKernel kernel2 = new DefaultKernel(); IKernel subkernel = new DefaultKernel(); Kernel.AddChildKernel(subkernel); Assert.AreEqual(Kernel, subkernel.Parent); kernel2.AddChildKernel(subkernel); }
public void ChildDependenciesIsSatisfiedEvenWhenComponentTakesLongToBeAddedToParentContainer() { var container = new DefaultKernel(); var childContainer = new DefaultKernel(); container.AddChildKernel(childContainer); childContainer.Register(Component.For(typeof(UsesIEmptyService)).Named("component")); container.Register( Component.For(typeof(IEmptyService)).ImplementedBy(typeof(EmptyServiceA)).Named("service1")); childContainer.Resolve<UsesIEmptyService>(); }
public void Three_level_hierarchy([Values(0, 1, 2)] int parentComponentContainer, [Values(0, 1, 2)] int childComponentContainer) { var subKernel = new DefaultKernel(); var subSubKernel = new DefaultKernel(); Kernel.AddChildKernel(subKernel); subKernel.AddChildKernel(subSubKernel); var containers = new[] { Kernel, subKernel, subSubKernel }; containers[parentComponentContainer].Register(Component.For<UsesSimpleComponent1>()); containers[childComponentContainer].Register(Component.For<SimpleComponent1>()); subSubKernel.Resolve<UsesSimpleComponent1>(); }