Spring.Aop.Framework.ProxyFactoryTests.RemoveAdvisorByIndex C# (CSharp) Метод

RemoveAdvisorByIndex() приватный Метод

private RemoveAdvisorByIndex ( ) : void
Результат void
        public void RemoveAdvisorByIndex()
        {
            TestObject target = new TestObject();
            ProxyFactory pf = new ProxyFactory(target);
            NopInterceptor nop = new NopInterceptor();
            CountingBeforeAdvice cba = new CountingBeforeAdvice();
            IAdvisor advisor = new DefaultPointcutAdvisor(cba);
            pf.AddAdvice(nop);
            pf.AddAdvisor(advisor);
            NopInterceptor nop2 = new NopInterceptor(2); // make instance unique (see SPRNET-847)
            pf.AddAdvice(nop2);
            ITestObject proxied = (ITestObject)pf.GetProxy();
            proxied.Age = 5;
            Assert.AreEqual(1, cba.GetCalls());
            Assert.AreEqual(1, nop.Count);
            Assert.AreEqual(1, nop2.Count);
            // Removes counting before advisor
            pf.RemoveAdvisor(1);
            Assert.AreEqual(5, proxied.Age);
            Assert.AreEqual(1, cba.GetCalls());
            Assert.AreEqual(2, nop.Count);
            Assert.AreEqual(2, nop2.Count);
            // Removes Nop1
            pf.RemoveAdvisor(0);
            Assert.AreEqual(5, proxied.Age);
            Assert.AreEqual(1, cba.GetCalls());
            Assert.AreEqual(2, nop.Count);
            Assert.AreEqual(3, nop2.Count);

            // Check out of bounds
            try
            {
                pf.RemoveAdvisor(-1);
                Assert.Fail("Supposed to throw exception");
            }
            catch (AopConfigException)
            {
                // Ok
            }

            try
            {
                pf.RemoveAdvisor(2);
                Assert.Fail("Supposed to throw exception");
            }
            catch (AopConfigException)
            {
                // Ok
            }

            Assert.AreEqual(5, proxied.Age);
            Assert.AreEqual(4, nop2.Count);
        }