コード例 #1
0
        public void ProxyMapsInterfaceMethodsToTheirImplementations()
        {
            MethodInfo something     = typeof(InterfaceOne).GetMethod("Something");
            MethodInfo somethingImpl = typeof(MBROWithInterface).GetMethod("Something");

            CallCountHandler handler = new CallCountHandler();

            MBROWithInterface original    = new MBROWithInterface();
            MBROWithInterface intercepted = new InterceptingRealProxy(original, typeof(MBROWithOneMethod))
                                            .GetTransparentProxy() as MBROWithInterface;

            HandlerPipeline    pipeline = new HandlerPipeline(Seq.Collect <ICallHandler>(handler));
            IInterceptingProxy proxy    = (IInterceptingProxy)intercepted;

            proxy.SetPipeline(something, pipeline);
            HandlerPipeline implPipeline = proxy.GetPipeline(somethingImpl);

            Assert.AreSame(pipeline, implPipeline);
        }