public void Context_Inherits_Parent_Injector() { AddRootToStage(); parentContext .Install(typeof(SupportParentFinderExtension)) .Install(typeof(TestSupportViewStateWatcherExtension)) .Install(typeof(ModularityExtension)) .Configure(new ContextView(parentView)); childContext .Install(typeof(TestSupportViewStateWatcherExtension)) .Install(typeof(ModularityExtension)) .Install(typeof(SupportParentFinderExtension)) .Configure(new ContextView(childView)); ContainerRegistry cr = new ContainerRegistry(); cr.SetParentFinder(new SupportParentFinder()); parentContext.injector.Map(typeof(ContainerRegistry)).ToValue(cr); childContext.injector.Map(typeof(ContainerRegistry)).ToValue(cr); cr.AddContainer(parentView); cr.AddContainer(childView); root.AddChild(parentView); parentView.AddChild(childView); Assert.That(childContext.injector.parent, Is.EqualTo(parentContext.injector)); }
public void Multiple_Depths_Of_Children_Only_Inherit_The_First_Parents_Injector() { AddRootToStage(); parentContext .Install(typeof(TestSupportViewStateWatcherExtension)) .Install(typeof(SupportParentFinderExtension)) .Install(typeof(ModularityExtension)) .Configure(new ContextView(parentView)); childContext .Install(typeof(TestSupportViewStateWatcherExtension)) .Install(typeof(ModularityExtension)) .Install(typeof(SupportParentFinderExtension)) .Configure(new ContextView(childView)); SupportView anotherChildView = new SupportView(); IContext anotherChildContext = new Context() .Install(typeof(TestSupportViewStateWatcherExtension)) .Install(typeof(StageSyncExtension)) .Install(typeof(ContextViewExtension)) .Install(typeof(ModularityExtension)) .Install(typeof(SupportParentFinderExtension)) .Configure(new ContextView(anotherChildView)); ContainerRegistry cr = new ContainerRegistry(); parentContext.injector.Map(typeof(ContainerRegistry)).ToValue(cr); childContext.injector.Map(typeof(ContainerRegistry)).ToValue(cr); anotherChildContext.injector.Map(typeof(ContainerRegistry)).ToValue(cr); cr.AddContainer(parentView); cr.AddContainer(childView); cr.AddContainer(anotherChildView); root.AddChild(parentView); parentView.AddChild(childView); childView.AddChild(anotherChildView); Assert.That(childContext.injector.parent, Is.EqualTo(parentContext.injector)); Assert.That(anotherChildContext.injector.parent, Is.EqualTo(childContext.injector)); Assert.That(anotherChildContext.injector.parent, Is.Not.EqualTo(parentContext.injector)); }