public void Null_target_is_valid()
        {
            var interceptor = new ChangeTargetInterceptor(new OneTwo());

            generator.CreateInterfaceProxyWithTargetInterface(typeof(IOne),
                                                              default(object),
                                                              new ProxyGenerationOptions(),
                                                              interceptor);
        }
        public void Invocation_should_be_IChangeInvocationTarget_for_AdditionalInterfaces_methods()
        {
            var interceptor = new ChangeTargetInterceptor(new Two());
            var proxy       = generator.CreateInterfaceProxyWithTargetInterface(typeof(IOne),
                                                                                new[] { typeof(ITwo) },
                                                                                new OneTwo(),
                                                                                interceptor);

            var result = (proxy as ITwo).TwoMethod();

            Assert.AreEqual(20, result);
        }
        public void Null_target_can_be_replaced()
        {
            var options = new ProxyGenerationOptions();

            options.AddMixinInstance(new Two());
            var interceptor = new ChangeTargetInterceptor(new OneTwo());
            var proxy       = generator.CreateInterfaceProxyWithTargetInterface(typeof(IOne),
                                                                                default(object),
                                                                                options,
                                                                                interceptor);

            Assert.AreEqual(3, ((IOne)proxy).OneMethod());
        }
        public void Invocation_should_be_IChangeInvocationTarget_for_target_methods()
        {
            var options = new ProxyGenerationOptions();

            options.AddMixinInstance(new Two());
            var interceptor = new ChangeTargetInterceptor(new OneTwo());
            var proxy       = generator.CreateInterfaceProxyWithTargetInterface(typeof(IOne),
                                                                                new One(),
                                                                                options,
                                                                                interceptor);
            var result = (proxy as IOne).OneMethod();

            Assert.AreEqual(3, result);
        }
        public void Should_detect_and_report_setting_null_as_target_for_Mixin_methods()
        {
            var options = new ProxyGenerationOptions();

            options.AddMixinInstance(new Two());
            var interceptor = new ChangeTargetInterceptor(null);
            var proxy       = generator.CreateInterfaceProxyWithTargetInterface(typeof(IOne),
                                                                                new One(),
                                                                                options,
                                                                                interceptor);

            Assert.Throws(typeof(NotImplementedException), () =>
                          (proxy as ITwo).TwoMethod());
        }