public void InterceptorCanInterceptProxyInstances()
        {
            CallCountInterceptionBehavior callCounter = new CallCountInterceptionBehavior();

            ProxiedInterfaceImpl impl = new ProxiedInterfaceImpl();
            IProxiedInterface instance = (IProxiedInterface)new MyProxy(typeof(IProxiedInterface), impl).GetTransparentProxy();

            IInstanceInterceptor interceptor = new InterfaceInterceptor();

            IInterceptingProxy proxy = (IInterceptingProxy)interceptor.CreateProxy(typeof(IProxiedInterface), (IProxiedInterface)instance);
            proxy.AddInterceptionBehavior(callCounter);

            IProxiedInterface inter = (IProxiedInterface)proxy;

            Assert.AreEqual("hello world", inter.DoSomething());
            Assert.AreEqual(1, callCounter.CallCount);
        }
        public void CanSetUpInterceptorThroughInjectionMemberForExistingInterceptor()
        {
            CallCountInterceptionBehavior interceptionBehavior = new CallCountInterceptionBehavior();

            IUnityContainer container = new UnityContainer();
            container.AddNewExtension<Interception>();

            container.RegisterType<IInterface, BaseClass>(
                "test",
                new Interceptor<InterfaceInterceptor>(),
                new InterceptionBehavior(interceptionBehavior));

            IInterface instance = container.Resolve<IInterface>("test");

            instance.DoSomething("1");

            Assert.AreEqual(1, interceptionBehavior.CallCount);
        }