public void NestedProxiesDontInvokeSameAdviceOrIntroductionTwice() { MultiProxyingTestClass testObj = new MultiProxyingTestClass(); ProxyFactory pf1 = new ProxyFactory(); pf1.Target = testObj; NopInterceptor di = new NopInterceptor(); NopInterceptor diUnused = new NopInterceptor(1); // // make instance unique (see SPRNET-847) TestCountingIntroduction countingMixin = new TestCountingIntroduction(); pf1.AddAdvice(diUnused); pf1.AddAdvisor(new DefaultPointcutAdvisor(di)); pf1.AddIntroduction(new DefaultIntroductionAdvisor(countingMixin)); object innerProxy = pf1.GetProxy(); ProxyFactory pf2 = new ProxyFactory(); pf2.Target = innerProxy; pf2.AddAdvice(diUnused); pf2.AddAdvisor(new DefaultPointcutAdvisor(di)); pf2.AddIntroduction(new DefaultIntroductionAdvisor(countingMixin)); object outerProxy = pf2.GetProxy(); // any advice instance is invoked once only string result = ((IMultiProxyingTestInterface)outerProxy).TestMethod("arg"); Assert.AreEqual(1, testObj.InvocationCounter); Assert.AreEqual("arg|arg", result); Assert.AreEqual(1, di.Count); // any introduction instance is invoked once only ((ICountingIntroduction)outerProxy).Inc(); Assert.AreEqual(1, countingMixin.Counter); }