public void CanInterceptMBROWithDependencyOnOtherMBRO() { GlobalCountCallHandler.Calls.Clear(); IUnityContainer container = new UnityContainer(); container.AddNewExtension <Interception>(); container .RegisterInstance <IMatchingRule>( "parentRule", new TypeMatchingRule(typeof(WrappableWithProperty))) .RegisterInstance <IMatchingRule>( "childRule", new TypeMatchingRule(typeof(Wrappable))) .RegisterInstance <ICallHandler>( "parentCallHandler", new GlobalCountCallHandler("parent")) .RegisterInstance <ICallHandler>( "childCallHandler", new GlobalCountCallHandler("child")) .RegisterType <InjectionPolicy, RuleDrivenPolicy>("parentPolicy") .RegisterType <InjectionPolicy, RuleDrivenPolicy>("childPolicy") .Configure <InjectedMembers>() .ConfigureInjectionFor <RuleDrivenPolicy>( "parentPolicy", new InjectionConstructor( new ResolvedArrayParameter <IMatchingRule>( new ResolvedParameter <IMatchingRule>("parentRule")), new string[] { "parentCallHandler" })) .ConfigureInjectionFor <RuleDrivenPolicy>( "childPolicy", new InjectionConstructor( new ResolvedArrayParameter <IMatchingRule>( new ResolvedParameter <IMatchingRule>("childRule")), new string[] { "childCallHandler" })) .ConfigureInjectionFor <WrappableWithProperty>( new InjectionProperty("Wrappable")) .Container .Configure <Interception>() .SetDefaultInterceptorFor <WrappableWithProperty>(new TransparentProxyInterceptor()) .SetDefaultInterceptorFor <Wrappable>(new TransparentProxyInterceptor()); WrappableWithProperty instance = container.Resolve <WrappableWithProperty>(); instance.Method(); Assert.AreEqual(1, GlobalCountCallHandler.Calls["parent"]); // method instance.Wrappable.Method(); Assert.AreEqual(2, GlobalCountCallHandler.Calls["parent"]); // method and getter Assert.AreEqual(1, GlobalCountCallHandler.Calls["child"]); }