Esempio n. 1
0
 public void Should_create_a_proxy_using_a_target_object_and_an_interceptor()
 {
     var interceptor = new ForwardExecutionInterceptor();
     var target = new Goo();
     var factory = new ProxyFactory(AppConfig.ProxyBehavior);
     var proxy = factory.Create(target, interceptor);
     Assert.Equal("ack", proxy.Go());
 }
Esempio n. 2
0
        public void Should_create_a_proxy_using_a_target_object_and_an_interceptor_that_forwards_execution()
        {
            IFoo target      = new Foo();
            var  factory     = new ProxyFactory(AppConfig.ProxyBehavior);
            var  interceptor = new ForwardExecutionInterceptor();            //-> Example of how to create an interceptor implementing IInterceptor
            var  proxy       = factory.Create(target, interceptor);

            Assert.Equal("ack", proxy.Go());
        }
Esempio n. 3
0
        public void Should_create_a_proxy_using_a_target_object_and_an_interceptor()
        {
            var interceptor = new ForwardExecutionInterceptor();
            var target      = new Goo();
            var factory     = new ProxyFactory(AppConfig.ProxyBehavior);
            var proxy       = factory.Create(target, interceptor);

            Assert.Equal("ack", proxy.Go());
        }
Esempio n. 4
0
        public void Castle_behavior_does_not_support_class_proxies_without_default_ctor()
        {
            var hoo = new Hoo("Hoo", 1);
            var interceptor = new ForwardExecutionInterceptor();
            var castle = new ProxyFactory(ProxyBehavior.Castle);
            Assert.Throws <System.ArgumentException>(() => castle.Create<Hoo>(hoo, interceptor));

            // linfu does...
            var linfu = new ProxyFactory(ProxyBehavior.LinFu);
            Assert.Same("Hoo",linfu.Create<Hoo>(hoo, interceptor).Name);

            // spring does...
            var spring = new ProxyFactory(ProxyBehavior.Spring);
            Assert.Same("Hoo", spring.Create<Hoo>(hoo, interceptor).Name);
        }
Esempio n. 5
0
        public void Castle_behavior_does_not_support_class_proxies_without_default_ctor()
        {
            var hoo         = new Hoo("Hoo", 1);
            var interceptor = new ForwardExecutionInterceptor();
            var castle      = new ProxyFactory(ProxyBehavior.Castle);

            Assert.Throws <System.ArgumentException>(() => castle.Create <Hoo>(hoo, interceptor));

            // linfu does...
            var linfu = new ProxyFactory(ProxyBehavior.LinFu);

            Assert.Same("Hoo", linfu.Create <Hoo>(hoo, interceptor).Name);

            // spring does...
            var spring = new ProxyFactory(ProxyBehavior.Spring);

            Assert.Same("Hoo", spring.Create <Hoo>(hoo, interceptor).Name);
        }
Esempio n. 6
0
 public void Should_create_a_proxy_using_a_target_object_and_an_interceptor_that_forwards_execution()
 {
     IFoo target = new Foo();
     var factory = new ProxyFactory(AppConfig.ProxyBehavior);
     var interceptor = new ForwardExecutionInterceptor(); //-> Example of how to create an interceptor implementing IInterceptor
     var proxy = factory.Create(target, interceptor);
     Assert.Equal("ack", proxy.Go());
 }