public void HandlersCanChangeInputsBeforeTargetIsCalled()
        {
            TransparentProxyInterceptor factory = new TransparentProxyInterceptor();
            PolicySet policies = GetPolicies();

            CanChangeParametersTarget target = new CanChangeParametersTarget();
            IInterceptingProxy proxy = factory.CreateProxy(typeof(CanChangeParametersTarget), target);

            ApplyPolicies(factory, proxy, target, policies);

            CanChangeParametersTarget intercepted = (CanChangeParametersTarget)proxy;
            Assert.AreEqual(0, intercepted.MostRecentInput);
            intercepted.DoSomething(2);
            Assert.AreEqual(4, intercepted.MostRecentInput);
        }
Example #2
0
        public void HandlersCanChangeInputsBeforeTargetIsCalled()
        {
            TransparentProxyInterceptor factory = new TransparentProxyInterceptor();
            PolicySet policies = GetPolicies();

            CanChangeParametersTarget target = new CanChangeParametersTarget();
            IInterceptingProxy        proxy  = factory.CreateProxy(typeof(CanChangeParametersTarget), target);

            ApplyPolicies(factory, proxy, target, policies);

            CanChangeParametersTarget intercepted = (CanChangeParametersTarget)proxy;

            Assert.AreEqual(0, intercepted.MostRecentInput);
            intercepted.DoSomething(2);
            Assert.AreEqual(4, intercepted.MostRecentInput);
        }
        public void HandlersCanChangeRefsAfterTargetReturns()
        {
            TransparentProxyInterceptor factory = new TransparentProxyInterceptor();
            PolicySet policies = GetPolicies();


            CanChangeParametersTarget target = new CanChangeParametersTarget();
            IInterceptingProxy proxy = factory.CreateProxy(typeof(CanChangeParametersTarget), target);
            ApplyPolicies(factory, proxy, target, policies);
            CanChangeParametersTarget intercepted = (CanChangeParametersTarget)proxy;
            int output = 3;

            intercepted.DoSomethingElseWithRef(2, ref output);

            Assert.AreEqual((2 + 3 + 5) * 3, output);
        }
Example #4
0
        public void HandlersCanChangeRefsAfterTargetReturns()
        {
            TransparentProxyInterceptor factory = new TransparentProxyInterceptor();
            PolicySet policies = GetPolicies();


            CanChangeParametersTarget target = new CanChangeParametersTarget();
            IInterceptingProxy        proxy  = factory.CreateProxy(typeof(CanChangeParametersTarget), target);

            ApplyPolicies(factory, proxy, target, policies);
            CanChangeParametersTarget intercepted = (CanChangeParametersTarget)proxy;
            int output = 3;

            intercepted.DoSomethingElseWithRef(2, ref output);

            Assert.AreEqual((2 + 3 + 5) * 3, output);
        }