コード例 #1
0
        public void ChildContainerResolvesInParent()
        {
            var container = new UnityContainer();
            container.StandardConfiguration();
            container.LoadConfiguration();
            container.ConfigureRegistrars();

            var expected = container.ConfigureChildContainer("test");

            var candidate = container.Resolve<IUnityContainer>("test");

            Assert.AreSame(expected, candidate);
        }
コード例 #2
0
        public void ChildResolveChildServiceDirectly()
        {
            var container = new UnityContainer();
            container.StandardConfiguration();
            container.LoadConfiguration();
            container.ConfigureRegistrars();

            var child = container.ConfigureChildContainer("test");

            var expected = typeof(ChildTestClass);
            var candidate = child.Resolve<ITest>("direct2");

            Assert.AreSame(expected, candidate.GetType());  
        }
コード例 #3
0
        public void FactoryCallInChild()
        {
            var container = new UnityContainer();
            container.StandardConfiguration();
            container.LoadConfiguration();
            container.ConfigureRegistrars();

            var child = container.ConfigureChildContainer("test");

            var factory = child.Resolve<ITestFactory>();

            var expected = typeof(ChildTestClass);
            var candidate = factory.Get();

            Assert.AreSame(expected, candidate.GetType());
        }