Пример #1
0
        public void BasicCase()
        {
            ProxyGenerationOptions options = new ProxyGenerationOptions();

            options.Selector = new AllInterceptorSelector();
            ISimpleInterface target =
                generator.CreateInterfaceProxyWithTarget(typeof(ISimpleInterface), new SimpleClass(), options,
                                                         new StandardInterceptor()) as ISimpleInterface;

            Assert.IsNotNull(target);
            target.Do();
        }
Пример #2
0
        public void SelectorWorksForMethods()
        {
            ProxyGenerationOptions  options             = new ProxyGenerationOptions();
            CallCountingInterceptor countingInterceptor = new CallCountingInterceptor();

            options.Selector = new TypeInterceptorSelector <CallCountingInterceptor>();
            ISimpleInterface target =
                generator.CreateInterfaceProxyWithTarget(typeof(ISimpleInterface), new SimpleClass(), options,
                                                         new AddTwoInterceptor(), countingInterceptor) as ISimpleInterface;

            Assert.IsNotNull(target);
            int result = target.Do();

            Assert.AreEqual(3, result);
            Assert.AreEqual(1, countingInterceptor.Count);
        }