Ejemplo n.º 1
0
        public void VirtualInterceptionWithoutAdditionalInterfaces()
        {
            DoNothingInterceptionBehavior.Reset();
            IInterceptionBehavior[] behaviourArray = new IInterceptionBehavior[1];
            behaviourArray[0] = new DoNothingInterceptionBehavior();

            var proxy = Intercept.NewInstance <HasVirtualMethods>(new VirtualMethodInterceptor(), behaviourArray);

            proxy.TargetMethod();
            Assert.AreEqual("Called", DoNothingInterceptionBehavior.PreCalled);
            Assert.AreEqual("Called", DoNothingInterceptionBehavior.PostCalled);
        }
Ejemplo n.º 2
0
        public void MBROInterceptionWithoutAdditionalInterfaces()
        {
            DoNothingInterceptionBehavior.Reset();
            IInterceptionBehavior[] behaviourArray = new IInterceptionBehavior[1];
            behaviourArray[0] = new DoNothingInterceptionBehavior();
            ImplementsMBRO target = new ImplementsMBRO();
            ImplementsMBRO proxy  = Intercept.ThroughProxy(target, new TransparentProxyInterceptor(), behaviourArray);

            proxy.TargetMethod();
            Assert.AreEqual("Called", DoNothingInterceptionBehavior.PreCalled);
            Assert.AreEqual("Called", DoNothingInterceptionBehavior.PostCalled);
        }
        public void CanUseTransparentProxyInterceptionThroughConfiguration()
        {
            IUnityContainer container = GetContainer("CanUseTransparentProxyInterceptionThroughConfiguration");

            DoNothingInterceptionBehavior.Reset();
            ImplementsMBRO abc = container.Resolve <ImplementsMBRO>();

            abc.TargetMethod();

            Assert.AreEqual <string>("Called", DoNothingInterceptionBehavior.PreCalled);
            Assert.AreEqual <string>("Called", DoNothingInterceptionBehavior.PostCalled);
        }
        public void CanUseVirtualMethodInterceptionThroughConfiguration()
        {
            IUnityContainer container = GetContainer("CanUseVirtualMethodInterceptionThroughConfiguration");

            DoNothingInterceptionBehavior.Reset();
            HasVirtualMethods abc = container.Resolve <HasVirtualMethods>();

            abc.TargetMethod();

            Assert.AreEqual <string>("Called", DoNothingInterceptionBehavior.PreCalled);
            Assert.AreEqual <string>("Called", DoNothingInterceptionBehavior.PostCalled);
        }
        public void CanUseInterfaceInterceptorThroughConfiguration()
        {
            IUnityContainer container = GetContainer("CanUseInterfaceInterceptorThroughConfiguration");

            DoNothingInterceptionBehavior.Reset();
            IInterfaceA abc = container.Resolve <IInterfaceA>();

            abc.TargetMethod();

            Assert.AreEqual <string>("Called", DoNothingInterceptionBehavior.PreCalled);
            Assert.AreEqual <string>("Called", DoNothingInterceptionBehavior.PostCalled);
        }