public void ConfigureContainerbyAddingPolicyHanlderRuleType()
        {
            IUnityContainer container = new UnityContainer();

            container.AddNewExtension <Interception>();
            GlobalCountCallHandler.Calls.Clear();
            container.Configure <Interception>().
            AddPolicy("myRDP").
            AddCallHandler(typeof(GlobalCountCallHandler)).
            AddMatchingRule(typeof(AlwaysMatchingRule));
            container.Configure <Interception>().
            SetInterceptorFor <InterceptionClass>("interceptionclass", new TransparentProxyInterceptor());
            InterceptionClass ic = container.Resolve <InterceptionClass>("interceptionclass");

            ic.MethodA();
            Assert.AreEqual(1, GlobalCountCallHandler.Calls["default"]);
        }
        public void ConfiguredContainerbyDefaultisContainerControlledLifeTimeManaged()
        {
            IUnityContainer container = new UnityContainer();

            container.AddNewExtension <Interception>();
            GlobalCountCallHandler.Calls.Clear();
            container.Configure <Interception>().
            AddPolicy("myRDP").
            AddCallHandler <GlobalCountCallHandler>(new ContainerControlledLifetimeManager(), new InjectionConstructor("myHandler1")).
            AddCallHandler <GlobalCountCallHandler>(new InjectionConstructor("myHandler3"), new InjectionProperty("Order", 1000)).
            AddMatchingRule <AlwaysMatchingRule>();
            container.Configure <Interception>().
            SetInterceptorFor <InterceptionClass>("interceptionclass", new TransparentProxyInterceptor());
            InterceptionClass ic = container.Resolve <InterceptionClass>("interceptionclass");

            ic.MethodA();
            Assert.AreEqual(1, GlobalCountCallHandler.Calls["myHandler1"]);
            Assert.AreEqual(1, GlobalCountCallHandler.Calls["myHandler3"]);
        }
        public void ConfigureContainerbyAddingPolicyHanlderRule()
        {
            ICallHandler  myHandler1      = new CallCountHandler();
            IMatchingRule myMatchingRule1 = new AlwaysMatchingRule();

            IUnityContainer container = new UnityContainer();

            container.AddNewExtension <Interception>();
            container.Configure <Interception>().
            AddPolicy("myRDP").
            AddCallHandler(myHandler1).
            AddMatchingRule(myMatchingRule1);
            container.Configure <Interception>().
            SetInterceptorFor <InterceptionClass>("interceptionclass", new TransparentProxyInterceptor());

            InterceptionClass ic = container.Resolve <InterceptionClass>("interceptionclass");

            ic.MethodA();
            Assert.AreEqual(1, ((CallCountHandler)myHandler1).CallCount);
        }
        public void ConfigureContainerbyInjectingPolicyHanlderRule()
        {
            IUnityContainer container = new UnityContainer();

            container.AddNewExtension <Interception>();
            GlobalCountCallHandler.Calls.Clear();
            container.Configure <Interception>().
            AddPolicy("myRDP").
            AddCallHandler <GlobalCountCallHandler>(new InjectionConstructor("myHandler1")).
            AddCallHandler <GlobalCountCallHandler>(new InjectionConstructor("myHandler2")).
            AddCallHandler <GlobalCountCallHandler>(new InjectionConstructor("myHandler3")).
            AddMatchingRule <AlwaysMatchingRule>();
            container.Configure <Interception>().
            SetInterceptorFor <InterceptionClass>("interceptionclass", new TransparentProxyInterceptor());
            InterceptionClass ic = container.Resolve <InterceptionClass>("interceptionclass");

            ic.MethodA();

            Assert.AreEqual(1, GlobalCountCallHandler.Calls["myHandler1"]);
        }