Beispiel #1
0
 public void Should_catch_an_exception_and_run_a_callback_before_and_after_the_exception_is_rethrown()
 {
     int ack = 0;
     var target = new Foo();
     var interceptor = new OnCatchAndOnFinallyInterceptor{ Action = ()=> { Assert.True(target.Executed); ++ack; } };
     var factory = new ProxyFactory(AppConfig.ProxyBehavior);
     var proxy = factory.Create<IFoo>(target, interceptor);
     Assert.Throws<InvalidOperationException>(() => proxy.Fail());
     Assert.Equal(2, ack);
 }
Beispiel #2
0
        public void Should_catch_an_exception_and_run_a_callback_before_and_after_the_exception_is_rethrown()
        {
            int ack         = 0;
            var target      = new Foo();
            var interceptor = new OnCatchAndOnFinallyInterceptor {
                Action = () => { Assert.True(target.Executed); ++ack; }
            };
            var factory = new ProxyFactory(AppConfig.ProxyBehavior);
            var proxy   = factory.Create <IFoo>(target, interceptor);

            Assert.Throws <InvalidOperationException>(() => proxy.Fail());
            Assert.Equal(2, ack);
        }