コード例 #1
0
        public void ProxyGenerator_CreateInterfaceProxyWithTarget_can_proceed_to_delegate_mixin()
        {
            var target = new Target();

            var options = new ProxyGenerationOptions();

            options.AddDelegateMixin(new Action(target.Method));

            var interceptor = new Interceptor(shouldProceed: true);

            var proxy  = generator.CreateInterfaceProxyWithTarget(typeof(IComparable), target, options, interceptor);
            var action = ProxyUtil.CreateDelegateToMixin <Action>(proxy);

            Assert.NotNull(action);

            action.Invoke();
            Assert.True(target.MethodInvoked);
        }
コード例 #2
0
        public void ProxyGenerationOptions_AddDelegateMixin_when_given_delegate_succeeds()
        {
            var options = new ProxyGenerationOptions();

            options.AddDelegateMixin(new Action(() => { }));
        }
コード例 #3
0
        public void ProxyGenerationOptions_AddDelegateMixin_when_given_null_throws_ArgumentNullException()
        {
            var options = new ProxyGenerationOptions();

            Assert.Throws <ArgumentNullException>(() => options.AddDelegateMixin(null));
        }