コード例 #1
0
        public void GenericWrapperWorks()
        {
            PostCallCountHandler handler = new PostCallCountHandler();
            InterceptingGenericClass <DateTime> instance =
                new WrapperGeneric <DateTime>();

            PipelineManager pm      = new PipelineManager();
            MethodBase      reverse = typeof(InterceptingGenericClass <DateTime>).GetMethod("Reverse");

            pm.SetPipeline(reverse, new HandlerPipeline(Sequence.Collect <ICallHandler>(handler)));
            ((IInterceptingProxy)instance).AddInterceptionBehavior(new PolicyInjectionBehavior(pm));

            string result = instance.Reverse(137);

            Assert.AreEqual("731", result);
            Assert.AreEqual(1, handler.CallsCompleted);
        }
コード例 #2
0
        public void GenericWrapperWorks()
        {
            PostCallCountHandler handler = new PostCallCountHandler();
            InterceptingGenericClass <DateTime> instance =
                new WrapperGeneric <DateTime>();

            IInterceptingProxy pm      = (IInterceptingProxy)instance;
            MethodBase         reverse = typeof(InterceptingGenericClass <DateTime>).GetMethod("Reverse");

            pm.SetPipeline(reverse, new HandlerPipeline(Seq.Collect <ICallHandler>(handler)));

            DateTime now = DateTime.Now;

            string result = instance.Reverse(137);

            Assert.AreEqual("731", result);
            Assert.AreEqual(1, handler.CallsCompleted);
        }