예제 #1
0
        public void RefsAndOutsAreProperlyHandled()
        {
            IInstanceInterceptor          interceptor = new InterfaceInterceptor();
            ImplementsHaveSomeRefsAndOuts target      = new ImplementsHaveSomeRefsAndOuts();

            IInterceptingProxy proxy   = interceptor.CreateProxy(typeof(IHaveSomeRefsAndOuts), target);
            CallCountHandler   handler = new CallCountHandler();

            proxy.SetPipeline(typeof(IHaveSomeRefsAndOuts).GetMethod("DoSomething"), new HandlerPipeline(new ICallHandler[] { handler }));

            IHaveSomeRefsAndOuts intercepted = (IHaveSomeRefsAndOuts)proxy;

            int    a;
            string s = "something";

            intercepted.DoSomething(out a, ref s);

            Assert.AreEqual(37, a);
            Assert.AreEqual("+++something***", s);
            Assert.AreEqual(1, handler.CallCount);
        }
예제 #2
0
        public void RefsAndOutsAreProperlyHandled()
        {
            IInstanceInterceptor          interceptor = new InterfaceInterceptor();
            ImplementsHaveSomeRefsAndOuts target      = new ImplementsHaveSomeRefsAndOuts();

            IInterceptingProxy            proxy = interceptor.CreateProxy(typeof(IHaveSomeRefsAndOuts), target);
            CallCountInterceptionBehavior interceptionBehavior = new CallCountInterceptionBehavior();

            proxy.AddInterceptionBehavior(interceptionBehavior);

            IHaveSomeRefsAndOuts intercepted = (IHaveSomeRefsAndOuts)proxy;

            int    a;
            string s = "something";

            intercepted.DoSomething(out a, ref s);

            Assert.AreEqual(37, a);
            Assert.AreEqual("+++something***", s);
            Assert.AreEqual(1, interceptionBehavior.CallCount);
        }