public void DependencyOverrideOccursAcrossObjectGraphReferences()
        {
            MyIndependentFoo overrideFoo = new MyIndependentFoo();

            overrideFoo.X = -9999;

            IUnityContainer container = new UnityContainer();

            container.RegisterType <TopLevelDependentFoo>().RegisterType <SecondLevelDependentFoo>().RegisterType <MyIndependentFoo>(new InjectionProperty("X", 111));

            var defaultResult  = container.Resolve <TopLevelDependentFoo>();
            var overrideResult = container.Resolve <TopLevelDependentFoo>(new DependencyOverride(typeof(MyIndependentFoo), overrideFoo));

            Assert.AreEqual <int>(111, defaultResult.MyIndependentFooTopLevelDependentFoo.X);
            Assert.AreEqual <int>(111, defaultResult.SecondLevelDependentFoo.MyIndependentFooSecondLevelDependentFoo.X);
            Assert.AreEqual <int>(-9999, overrideResult.MyIndependentFooTopLevelDependentFoo.X);
            Assert.AreEqual <int>(-9999, overrideResult.SecondLevelDependentFoo.MyIndependentFooSecondLevelDependentFoo.X);
        }
        public void DependencyOverrideOccursAcrossObjectGraphReferences()
        {
            MyIndependentFoo overrideFoo = new MyIndependentFoo();
            overrideFoo.X = -9999;

            IUnityContainer container = new UnityContainer();
            
            container.RegisterType<TopLevelDependentFoo>().RegisterType<SecondLevelDependentFoo>().RegisterType<MyIndependentFoo>(new InjectionProperty("X", 111));

            var defaultResult = container.Resolve<TopLevelDependentFoo>();
            var overrideResult = container.Resolve<TopLevelDependentFoo>(new DependencyOverride(typeof(MyIndependentFoo), overrideFoo));
            
            Assert.AreEqual<int>(111, defaultResult.MyIndependentFooTopLevelDependentFoo.X);
            Assert.AreEqual<int>(111, defaultResult.SecondLevelDependentFoo.MyIndependentFooSecondLevelDependentFoo.X);
            Assert.AreEqual<int>(-9999, overrideResult.MyIndependentFooTopLevelDependentFoo.X);
            Assert.AreEqual<int>(-9999, overrideResult.SecondLevelDependentFoo.MyIndependentFooSecondLevelDependentFoo.X);
        }