public void SelectiveApplication()
        {
            SerializablePerson target = new SerializablePerson();

            target.SetAge(27);
            NopInterceptor      nop             = new NopInterceptor();
            ControlFlowPointcut cflow           = new ControlFlowPointcut(typeof(One));
            IPointcut           settersUnderOne = Pointcuts.Intersection(SetterPointcut.Instance, cflow);
            ProxyFactory        pf      = new ProxyFactory(target);
            IPerson             proxied = (IPerson)pf.GetProxy();

            pf.AddAdvisor(new DefaultPointcutAdvisor(settersUnderOne, nop));

            // Not advised, not under One
            target.SetAge(16);
            Assert.AreEqual(0, nop.Count);

            // Not advised; under One but not a setter
            Assert.AreEqual(16, new One().GetAge(proxied));
            Assert.AreEqual(0, nop.Count);

            // Won't be advised
            new One().Set(proxied);
            Assert.AreEqual(1, nop.Count);

            // We saved most evaluations
            Assert.AreEqual(1, cflow.EvaluationCount);
        }
        public void Matches()
        {
            SerializablePerson target = new SerializablePerson();

            target.SetAge(27);
            ControlFlowPointcut cflow   = new ControlFlowPointcut(typeof(One), "GetAge");
            ProxyFactory        factory = new ProxyFactory(target);
            NopInterceptor      nop     = new NopInterceptor();
            IPerson             proxied = (IPerson)factory.GetProxy();

            factory.AddAdvisor(new DefaultPointcutAdvisor(cflow, nop));

            // not advised, not under One...
            Assert.AreEqual(target.GetAge(), proxied.GetAge());
            Assert.AreEqual(0, nop.Count, "Whoops, appear to be advising when not under One's cflow.");

            // will be advised...
            One one = new One();

            Assert.AreEqual(27, one.GetAge(proxied));
            Assert.AreEqual(1, nop.Count, "Not advising when under One's cflow (must be).");

            // won't be advised...
            Assert.AreEqual(target.GetAge(), new One().NoMatch(proxied));
            Assert.AreEqual(1, nop.Count, "Whoops, appear to be advising when under One's cflow scope, BUT NOT under a target method's cflow scope.");
            Assert.AreEqual(3, cflow.EvaluationCount, "Pointcut not invoked the correct number of times.");
        }